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
Skytim/nccuTEG
test/test_jobs/test_send_mail.py
6
1426
# -*- coding: utf8 -*- # This file is part of PyBossa. # # Copyright (C) 2014 SF Isle of Man Limited # # PyBossa 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. # # PyBossa 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 PyBossa. If not, see <http://www.gnu.org/licenses/>. from pybossa.jobs import send_mail from mock import patch @patch('pybossa.jobs.mail') @patch('pybossa.jobs.Message') class TestSendMailJob(object): def test_send_mail_craetes_message(self, Message, mail): mail_dict = dict(subject='Hello', recipients=['pepito@hotmail.con'], body='Hello Pepito!') send_mail(mail_dict) Message.assert_called_once_with(**mail_dict) def test_send_mail_sends_mail(self, Message, mail): mail_dict = dict(subject='Hello', recipients=['pepito@hotmail.con'], body='Hello Pepito!') send_mail(mail_dict) mail.send.assert_called_once_with(Message())
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 1611, 2208, 28023, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6927, 29531, 6596, 274, 402, 4688, 23954, 199, 3, 199, 3, 1611, 2208, 28023, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1611, 2208, 28023, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 1611, 2208, 28023, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 1134, 25020, 65, 14, 6920, 492, 3222, 63, 1198, 199, 504, 1683, 492, 3371, 199, 199, 32, 2068, 360, 647, 25020, 65, 14, 6920, 14, 1198, 358, 199, 32, 2068, 360, 647, 25020, 65, 14, 6920, 14, 2209, 358, 199, 533, 1379, 6795, 13681, 6694, 8, 785, 304, 339, 347, 511, 63, 2254, 63, 1198, 63, 67, 345, 69, 744, 63, 1188, 8, 277, 12, 6430, 12, 6016, 304, 267, 6016, 63, 807, 275, 1211, 8, 5875, 534, 6257, 297, 19255, 2968, 12636, 24308, 32, 8885, 1198, 14, 388, 995, 586, 2396, 534, 6257, 510, 1545, 24308, 10916, 267, 3222, 63, 1198, 8, 1198, 63, 807, 9, 267, 6430, 14, 479, 63, 3527, 63, 5089, 63, 1045, 3682, 1198, 63, 807, 9, 2378, 347, 511, 63, 2254, 63, 1198, 63, 2464, 795, 63, 1198, 8, 277, 12, 6430, 12, 6016, 304, 267, 6016, 63, 807, 275, 1211, 8, 5875, 534, 6257, 297, 19255, 2968, 12636, 24308, 32, 8885, 1198, 14, 388, 995, 586, 2396, 534, 6257, 510, 1545, 24308, 10916, 267, 3222, 63, 1198, 8, 1198, 63, 807, 9, 398, 6016, 14, 2254, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 2209, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 1611, 2208, 28023, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 6927, 29531, 6596, 274, 402, 4688, 23954, 199, 3, 199, 3, 1611, 2208, 28023, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1611, 2208, 28023, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 1611, 2208, 28023, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 504, 1134, 25020, 65, 14, 6920, 492, 3222, 63, 1198, 199, 504, 1683, 492, 3371, 199, 199, 32, 2068, 360, 647, 25020, 65, 14, 6920, 14, 1198, 358, 199, 32, 2068, 360, 647, 25020, 65, 14, 6920, 14, 2209, 358, 199, 533, 1379, 6795, 13681, 6694, 8, 785, 304, 339, 347, 511, 63, 2254, 63, 1198, 63, 67, 345, 69, 744, 63, 1188, 8, 277, 12, 6430, 12, 6016, 304, 267, 6016, 63, 807, 275, 1211, 8, 5875, 534, 6257, 297, 19255, 2968, 12636, 24308, 32, 8885, 1198, 14, 388, 995, 586, 2396, 534, 6257, 510, 1545, 24308, 10916, 267, 3222, 63, 1198, 8, 1198, 63, 807, 9, 267, 6430, 14, 479, 63, 3527, 63, 5089, 63, 1045, 3682, 1198, 63, 807, 9, 2378, 347, 511, 63, 2254, 63, 1198, 63, 2464, 795, 63, 1198, 8, 277, 12, 6430, 12, 6016, 304, 267, 6016, 63, 807, 275, 1211, 8, 5875, 534, 6257, 297, 19255, 2968, 12636, 24308, 32, 8885, 1198, 14, 388, 995, 586, 2396, 534, 6257, 510, 1545, 24308, 10916, 267, 3222, 63, 1198, 8, 1198, 63, 807, 9, 398, 6016, 14, 2254, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 2209, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wolfier/incubator-airflow
tests/contrib/operators/test_mysql_to_gcs_operator.py
8
1928
# -*- coding: utf-8 -*- # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import unittest import json from mock import MagicMock from airflow.contrib.operators.mysql_to_gcs import \ MySqlToGoogleCloudStorageOperator class MySqlToGoogleCloudStorageOperatorTest(unittest.TestCase): def test_write_local_data_files(self): # Configure task_id = "some_test_id" sql = "some_sql" bucket = "some_bucket" filename = "some_filename" row_iter = [[1, b'byte_str_1'], [2, b'byte_str_2']] schema = [] schema.append({ 'name': 'location', 'type': 'STRING', 'mode': 'nullable', }) schema.append({ 'name': 'uuid', 'type': 'BYTES', 'mode': 'nullable', }) schema_str = json.dumps(schema) op = MySqlToGoogleCloudStorageOperator( task_id=task_id, sql=sql, bucket=bucket, filename=filename, schema=schema_str) cursor_mock = MagicMock() cursor_mock.__iter__.return_value = row_iter # Run op._write_local_data_files(cursor_mock)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 646, 2022, 199, 504, 1683, 492, 10079, 199, 199, 504, 16321, 14, 2828, 14, 12688, 14, 8644, 63, 475, 63, 21757, 492, 971, 272, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 421, 199, 533, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 952, 63, 1832, 63, 576, 63, 1725, 8, 277, 304, 398, 327, 15453, 267, 2120, 63, 344, 275, 298, 3972, 63, 396, 63, 344, 2, 267, 3875, 275, 298, 3972, 63, 3009, 2, 267, 5315, 275, 298, 3972, 63, 4623, 2, 267, 1788, 275, 298, 3972, 63, 1501, 2, 267, 1962, 63, 1661, 275, 3474, 17, 12, 330, 7, 4414, 63, 495, 63, 17, 995, 359, 18, 12, 330, 7, 4414, 63, 495, 63, 18, 6538, 267, 4177, 275, 942, 267, 4177, 14, 740, 2561, 288, 283, 354, 356, 283, 1985, 297, 288, 283, 466, 356, 283, 5353, 297, 288, 283, 632, 356, 283, 16375, 297, 267, 3828, 267, 4177, 14, 740, 2561, 288, 283, 354, 356, 283, 2580, 297, 288, 283, 466, 356, 283, 20352, 297, 288, 283, 632, 356, 283, 16375, 297, 267, 3828, 267, 4177, 63, 495, 275, 2022, 14, 4180, 8, 3629, 9, 398, 1687, 275, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 8, 288, 2120, 63, 344, 29, 1765, 63, 344, 12, 288, 3875, 29, 3009, 12, 288, 5315, 29, 4623, 12, 288, 1788, 29, 1501, 12, 288, 4177, 29, 3629, 63, 495, 9, 398, 3920, 63, 1805, 275, 10079, 342, 267, 3920, 63, 1805, 855, 1661, 4343, 1107, 63, 585, 275, 1962, 63, 1661, 398, 327, 3378, 267, 1687, 423, 952, 63, 1832, 63, 576, 63, 1725, 8, 3937, 63, 1805, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 221, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 221, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 646, 2022, 199, 504, 1683, 492, 10079, 199, 199, 504, 16321, 14, 2828, 14, 12688, 14, 8644, 63, 475, 63, 21757, 492, 971, 272, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 421, 199, 533, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 774, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 952, 63, 1832, 63, 576, 63, 1725, 8, 277, 304, 398, 327, 15453, 267, 2120, 63, 344, 275, 298, 3972, 63, 396, 63, 344, 2, 267, 3875, 275, 298, 3972, 63, 3009, 2, 267, 5315, 275, 298, 3972, 63, 4623, 2, 267, 1788, 275, 298, 3972, 63, 1501, 2, 267, 1962, 63, 1661, 275, 3474, 17, 12, 330, 7, 4414, 63, 495, 63, 17, 995, 359, 18, 12, 330, 7, 4414, 63, 495, 63, 18, 6538, 267, 4177, 275, 942, 267, 4177, 14, 740, 2561, 288, 283, 354, 356, 283, 1985, 297, 288, 283, 466, 356, 283, 5353, 297, 288, 283, 632, 356, 283, 16375, 297, 267, 3828, 267, 4177, 14, 740, 2561, 288, 283, 354, 356, 283, 2580, 297, 288, 283, 466, 356, 283, 20352, 297, 288, 283, 632, 356, 283, 16375, 297, 267, 3828, 267, 4177, 63, 495, 275, 2022, 14, 4180, 8, 3629, 9, 398, 1687, 275, 4932, 16790, 1378, 13266, 9089, 6408, 7961, 8, 288, 2120, 63, 344, 29, 1765, 63, 344, 12, 288, 3875, 29, 3009, 12, 288, 5315, 29, 4623, 12, 288, 1788, 29, 1501, 12, 288, 4177, 29, 3629, 63, 495, 9, 398, 3920, 63, 1805, 275, 10079, 342, 267, 3920, 63, 1805, 855, 1661, 4343, 1107, 63, 585, 275, 1962, 63, 1661, 398, 327, 3378, 267, 1687, 423, 952, 63, 1832, 63, 576, 63, 1725, 8, 3937, 63, 1805, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
YuhangGe/node-freetype
src/freetype-2.5.3/src/tools/glnames.py
360
105239
#!/usr/bin/env python # # # FreeType 2 glyph name builder # # Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. """\ usage: %s <output-file> This python script generates the glyph names tables defined in the `psnames' module. Its single argument is the name of the header file to be created. """ import sys, string, struct, re, os.path # This table lists the glyphs according to the Macintosh specification. # It is used by the TrueType Postscript names table. # # See # # http://fonts.apple.com/TTRefMan/RM06/Chap6post.html # # for the official list. # mac_standard_names = \ [ # 0 ".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", # 10 "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", # 20 "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", # 30 "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", # 40 "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", # 50 "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", # 60 "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", # 70 "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", # 80 "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", # 90 "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", # 100 "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", # 110 "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", # 120 "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", # 130 "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", # 140 "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", # 150 "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", # 160 "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", # 170 "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", # 180 "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", # 190 "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", # 200 "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", # 210 "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", # 220 "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", # 230 "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", # 240 "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", # 250 "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat" ] # The list of standard `SID' glyph names. For the official list, # see Annex A of document at # # http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf . # sid_standard_names = \ [ # 0 ".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", # 10 "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", # 20 "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", # 30 "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", # 40 "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", # 50 "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", # 60 "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", # 70 "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", # 80 "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", # 90 "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", # 100 "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", # 110 "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", # 120 "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", # 130 "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", # 140 "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", # 150 "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", # 160 "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", # 170 "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", # 180 "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", # 190 "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", # 200 "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", # 210 "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", # 220 "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", # 230 "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", # 240 "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", # 250 "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", # 260 "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", # 270 "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", # 280 "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", # 290 "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", # 300 "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", # 310 "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", # 320 "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", # 330 "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", # 340 "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", # 350 "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", # 360 "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", # 370 "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", # 380 "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", # 390 "Semibold" ] # This table maps character codes of the Adobe Standard Type 1 # encoding to glyph indices in the sid_standard_names table. # t1_standard_encoding = \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 0, 111, 112, 113, 114, 0, 115, 116, 117, 118, 119, 120, 121, 122, 0, 123, 0, 124, 125, 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138, 0, 139, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, 0, 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0 ] # This table maps character codes of the Adobe Expert Type 1 # encoding to glyph indices in the sid_standard_names table. # t1_expert_encoding = \ [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 229, 230, 0, 231, 232, 233, 234, 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 252, 0, 253, 254, 255, 256, 257, 0, 0, 0, 258, 0, 0, 259, 260, 261, 262, 0, 0, 263, 264, 265, 0, 266, 109, 110, 267, 268, 269, 0, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 304, 305, 306, 0, 0, 307, 308, 309, 310, 311, 0, 312, 0, 0, 313, 0, 0, 314, 315, 0, 0, 316, 317, 318, 0, 0, 0, 158, 155, 163, 319, 320, 321, 322, 323, 324, 325, 0, 0, 326, 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378 ] # This data has been taken literally from the files `glyphlist.txt' # and `zapfdingbats.txt' version 2.0, Sept 2002. It is available from # # http://sourceforge.net/adobe/aglfn/ # adobe_glyph_list = """\ A;0041 AE;00C6 AEacute;01FC AEmacron;01E2 AEsmall;F7E6 Aacute;00C1 Aacutesmall;F7E1 Abreve;0102 Abreveacute;1EAE Abrevecyrillic;04D0 Abrevedotbelow;1EB6 Abrevegrave;1EB0 Abrevehookabove;1EB2 Abrevetilde;1EB4 Acaron;01CD Acircle;24B6 Acircumflex;00C2 Acircumflexacute;1EA4 Acircumflexdotbelow;1EAC Acircumflexgrave;1EA6 Acircumflexhookabove;1EA8 Acircumflexsmall;F7E2 Acircumflextilde;1EAA Acute;F6C9 Acutesmall;F7B4 Acyrillic;0410 Adblgrave;0200 Adieresis;00C4 Adieresiscyrillic;04D2 Adieresismacron;01DE Adieresissmall;F7E4 Adotbelow;1EA0 Adotmacron;01E0 Agrave;00C0 Agravesmall;F7E0 Ahookabove;1EA2 Aiecyrillic;04D4 Ainvertedbreve;0202 Alpha;0391 Alphatonos;0386 Amacron;0100 Amonospace;FF21 Aogonek;0104 Aring;00C5 Aringacute;01FA Aringbelow;1E00 Aringsmall;F7E5 Asmall;F761 Atilde;00C3 Atildesmall;F7E3 Aybarmenian;0531 B;0042 Bcircle;24B7 Bdotaccent;1E02 Bdotbelow;1E04 Becyrillic;0411 Benarmenian;0532 Beta;0392 Bhook;0181 Blinebelow;1E06 Bmonospace;FF22 Brevesmall;F6F4 Bsmall;F762 Btopbar;0182 C;0043 Caarmenian;053E Cacute;0106 Caron;F6CA Caronsmall;F6F5 Ccaron;010C Ccedilla;00C7 Ccedillaacute;1E08 Ccedillasmall;F7E7 Ccircle;24B8 Ccircumflex;0108 Cdot;010A Cdotaccent;010A Cedillasmall;F7B8 Chaarmenian;0549 Cheabkhasiancyrillic;04BC Checyrillic;0427 Chedescenderabkhasiancyrillic;04BE Chedescendercyrillic;04B6 Chedieresiscyrillic;04F4 Cheharmenian;0543 Chekhakassiancyrillic;04CB Cheverticalstrokecyrillic;04B8 Chi;03A7 Chook;0187 Circumflexsmall;F6F6 Cmonospace;FF23 Coarmenian;0551 Csmall;F763 D;0044 DZ;01F1 DZcaron;01C4 Daarmenian;0534 Dafrican;0189 Dcaron;010E Dcedilla;1E10 Dcircle;24B9 Dcircumflexbelow;1E12 Dcroat;0110 Ddotaccent;1E0A Ddotbelow;1E0C Decyrillic;0414 Deicoptic;03EE Delta;2206 Deltagreek;0394 Dhook;018A Dieresis;F6CB DieresisAcute;F6CC DieresisGrave;F6CD Dieresissmall;F7A8 Digammagreek;03DC Djecyrillic;0402 Dlinebelow;1E0E Dmonospace;FF24 Dotaccentsmall;F6F7 Dslash;0110 Dsmall;F764 Dtopbar;018B Dz;01F2 Dzcaron;01C5 Dzeabkhasiancyrillic;04E0 Dzecyrillic;0405 Dzhecyrillic;040F E;0045 Eacute;00C9 Eacutesmall;F7E9 Ebreve;0114 Ecaron;011A Ecedillabreve;1E1C Echarmenian;0535 Ecircle;24BA Ecircumflex;00CA Ecircumflexacute;1EBE Ecircumflexbelow;1E18 Ecircumflexdotbelow;1EC6 Ecircumflexgrave;1EC0 Ecircumflexhookabove;1EC2 Ecircumflexsmall;F7EA Ecircumflextilde;1EC4 Ecyrillic;0404 Edblgrave;0204 Edieresis;00CB Edieresissmall;F7EB Edot;0116 Edotaccent;0116 Edotbelow;1EB8 Efcyrillic;0424 Egrave;00C8 Egravesmall;F7E8 Eharmenian;0537 Ehookabove;1EBA Eightroman;2167 Einvertedbreve;0206 Eiotifiedcyrillic;0464 Elcyrillic;041B Elevenroman;216A Emacron;0112 Emacronacute;1E16 Emacrongrave;1E14 Emcyrillic;041C Emonospace;FF25 Encyrillic;041D Endescendercyrillic;04A2 Eng;014A Enghecyrillic;04A4 Enhookcyrillic;04C7 Eogonek;0118 Eopen;0190 Epsilon;0395 Epsilontonos;0388 Ercyrillic;0420 Ereversed;018E Ereversedcyrillic;042D Escyrillic;0421 Esdescendercyrillic;04AA Esh;01A9 Esmall;F765 Eta;0397 Etarmenian;0538 Etatonos;0389 Eth;00D0 Ethsmall;F7F0 Etilde;1EBC Etildebelow;1E1A Euro;20AC Ezh;01B7 Ezhcaron;01EE Ezhreversed;01B8 F;0046 Fcircle;24BB Fdotaccent;1E1E Feharmenian;0556 Feicoptic;03E4 Fhook;0191 Fitacyrillic;0472 Fiveroman;2164 Fmonospace;FF26 Fourroman;2163 Fsmall;F766 G;0047 GBsquare;3387 Gacute;01F4 Gamma;0393 Gammaafrican;0194 Gangiacoptic;03EA Gbreve;011E Gcaron;01E6 Gcedilla;0122 Gcircle;24BC Gcircumflex;011C Gcommaaccent;0122 Gdot;0120 Gdotaccent;0120 Gecyrillic;0413 Ghadarmenian;0542 Ghemiddlehookcyrillic;0494 Ghestrokecyrillic;0492 Gheupturncyrillic;0490 Ghook;0193 Gimarmenian;0533 Gjecyrillic;0403 Gmacron;1E20 Gmonospace;FF27 Grave;F6CE Gravesmall;F760 Gsmall;F767 Gsmallhook;029B Gstroke;01E4 H;0048 H18533;25CF H18543;25AA H18551;25AB H22073;25A1 HPsquare;33CB Haabkhasiancyrillic;04A8 Hadescendercyrillic;04B2 Hardsigncyrillic;042A Hbar;0126 Hbrevebelow;1E2A Hcedilla;1E28 Hcircle;24BD Hcircumflex;0124 Hdieresis;1E26 Hdotaccent;1E22 Hdotbelow;1E24 Hmonospace;FF28 Hoarmenian;0540 Horicoptic;03E8 Hsmall;F768 Hungarumlaut;F6CF Hungarumlautsmall;F6F8 Hzsquare;3390 I;0049 IAcyrillic;042F IJ;0132 IUcyrillic;042E Iacute;00CD Iacutesmall;F7ED Ibreve;012C Icaron;01CF Icircle;24BE Icircumflex;00CE Icircumflexsmall;F7EE Icyrillic;0406 Idblgrave;0208 Idieresis;00CF Idieresisacute;1E2E Idieresiscyrillic;04E4 Idieresissmall;F7EF Idot;0130 Idotaccent;0130 Idotbelow;1ECA Iebrevecyrillic;04D6 Iecyrillic;0415 Ifraktur;2111 Igrave;00CC Igravesmall;F7EC Ihookabove;1EC8 Iicyrillic;0418 Iinvertedbreve;020A Iishortcyrillic;0419 Imacron;012A Imacroncyrillic;04E2 Imonospace;FF29 Iniarmenian;053B Iocyrillic;0401 Iogonek;012E Iota;0399 Iotaafrican;0196 Iotadieresis;03AA Iotatonos;038A Ismall;F769 Istroke;0197 Itilde;0128 Itildebelow;1E2C Izhitsacyrillic;0474 Izhitsadblgravecyrillic;0476 J;004A Jaarmenian;0541 Jcircle;24BF Jcircumflex;0134 Jecyrillic;0408 Jheharmenian;054B Jmonospace;FF2A Jsmall;F76A K;004B KBsquare;3385 KKsquare;33CD Kabashkircyrillic;04A0 Kacute;1E30 Kacyrillic;041A Kadescendercyrillic;049A Kahookcyrillic;04C3 Kappa;039A Kastrokecyrillic;049E Kaverticalstrokecyrillic;049C Kcaron;01E8 Kcedilla;0136 Kcircle;24C0 Kcommaaccent;0136 Kdotbelow;1E32 Keharmenian;0554 Kenarmenian;053F Khacyrillic;0425 Kheicoptic;03E6 Khook;0198 Kjecyrillic;040C Klinebelow;1E34 Kmonospace;FF2B Koppacyrillic;0480 Koppagreek;03DE Ksicyrillic;046E Ksmall;F76B L;004C LJ;01C7 LL;F6BF Lacute;0139 Lambda;039B Lcaron;013D Lcedilla;013B Lcircle;24C1 Lcircumflexbelow;1E3C Lcommaaccent;013B Ldot;013F Ldotaccent;013F Ldotbelow;1E36 Ldotbelowmacron;1E38 Liwnarmenian;053C Lj;01C8 Ljecyrillic;0409 Llinebelow;1E3A Lmonospace;FF2C Lslash;0141 Lslashsmall;F6F9 Lsmall;F76C M;004D MBsquare;3386 Macron;F6D0 Macronsmall;F7AF Macute;1E3E Mcircle;24C2 Mdotaccent;1E40 Mdotbelow;1E42 Menarmenian;0544 Mmonospace;FF2D Msmall;F76D Mturned;019C Mu;039C N;004E NJ;01CA Nacute;0143 Ncaron;0147 Ncedilla;0145 Ncircle;24C3 Ncircumflexbelow;1E4A Ncommaaccent;0145 Ndotaccent;1E44 Ndotbelow;1E46 Nhookleft;019D Nineroman;2168 Nj;01CB Njecyrillic;040A Nlinebelow;1E48 Nmonospace;FF2E Nowarmenian;0546 Nsmall;F76E Ntilde;00D1 Ntildesmall;F7F1 Nu;039D O;004F OE;0152 OEsmall;F6FA Oacute;00D3 Oacutesmall;F7F3 Obarredcyrillic;04E8 Obarreddieresiscyrillic;04EA Obreve;014E Ocaron;01D1 Ocenteredtilde;019F Ocircle;24C4 Ocircumflex;00D4 Ocircumflexacute;1ED0 Ocircumflexdotbelow;1ED8 Ocircumflexgrave;1ED2 Ocircumflexhookabove;1ED4 Ocircumflexsmall;F7F4 Ocircumflextilde;1ED6 Ocyrillic;041E Odblacute;0150 Odblgrave;020C Odieresis;00D6 Odieresiscyrillic;04E6 Odieresissmall;F7F6 Odotbelow;1ECC Ogoneksmall;F6FB Ograve;00D2 Ogravesmall;F7F2 Oharmenian;0555 Ohm;2126 Ohookabove;1ECE Ohorn;01A0 Ohornacute;1EDA Ohorndotbelow;1EE2 Ohorngrave;1EDC Ohornhookabove;1EDE Ohorntilde;1EE0 Ohungarumlaut;0150 Oi;01A2 Oinvertedbreve;020E Omacron;014C Omacronacute;1E52 Omacrongrave;1E50 Omega;2126 Omegacyrillic;0460 Omegagreek;03A9 Omegaroundcyrillic;047A Omegatitlocyrillic;047C Omegatonos;038F Omicron;039F Omicrontonos;038C Omonospace;FF2F Oneroman;2160 Oogonek;01EA Oogonekmacron;01EC Oopen;0186 Oslash;00D8 Oslashacute;01FE Oslashsmall;F7F8 Osmall;F76F Ostrokeacute;01FE Otcyrillic;047E Otilde;00D5 Otildeacute;1E4C Otildedieresis;1E4E Otildesmall;F7F5 P;0050 Pacute;1E54 Pcircle;24C5 Pdotaccent;1E56 Pecyrillic;041F Peharmenian;054A Pemiddlehookcyrillic;04A6 Phi;03A6 Phook;01A4 Pi;03A0 Piwrarmenian;0553 Pmonospace;FF30 Psi;03A8 Psicyrillic;0470 Psmall;F770 Q;0051 Qcircle;24C6 Qmonospace;FF31 Qsmall;F771 R;0052 Raarmenian;054C Racute;0154 Rcaron;0158 Rcedilla;0156 Rcircle;24C7 Rcommaaccent;0156 Rdblgrave;0210 Rdotaccent;1E58 Rdotbelow;1E5A Rdotbelowmacron;1E5C Reharmenian;0550 Rfraktur;211C Rho;03A1 Ringsmall;F6FC Rinvertedbreve;0212 Rlinebelow;1E5E Rmonospace;FF32 Rsmall;F772 Rsmallinverted;0281 Rsmallinvertedsuperior;02B6 S;0053 SF010000;250C SF020000;2514 SF030000;2510 SF040000;2518 SF050000;253C SF060000;252C SF070000;2534 SF080000;251C SF090000;2524 SF100000;2500 SF110000;2502 SF190000;2561 SF200000;2562 SF210000;2556 SF220000;2555 SF230000;2563 SF240000;2551 SF250000;2557 SF260000;255D SF270000;255C SF280000;255B SF360000;255E SF370000;255F SF380000;255A SF390000;2554 SF400000;2569 SF410000;2566 SF420000;2560 SF430000;2550 SF440000;256C SF450000;2567 SF460000;2568 SF470000;2564 SF480000;2565 SF490000;2559 SF500000;2558 SF510000;2552 SF520000;2553 SF530000;256B SF540000;256A Sacute;015A Sacutedotaccent;1E64 Sampigreek;03E0 Scaron;0160 Scarondotaccent;1E66 Scaronsmall;F6FD Scedilla;015E Schwa;018F Schwacyrillic;04D8 Schwadieresiscyrillic;04DA Scircle;24C8 Scircumflex;015C Scommaaccent;0218 Sdotaccent;1E60 Sdotbelow;1E62 Sdotbelowdotaccent;1E68 Seharmenian;054D Sevenroman;2166 Shaarmenian;0547 Shacyrillic;0428 Shchacyrillic;0429 Sheicoptic;03E2 Shhacyrillic;04BA Shimacoptic;03EC Sigma;03A3 Sixroman;2165 Smonospace;FF33 Softsigncyrillic;042C Ssmall;F773 Stigmagreek;03DA T;0054 Tau;03A4 Tbar;0166 Tcaron;0164 Tcedilla;0162 Tcircle;24C9 Tcircumflexbelow;1E70 Tcommaaccent;0162 Tdotaccent;1E6A Tdotbelow;1E6C Tecyrillic;0422 Tedescendercyrillic;04AC Tenroman;2169 Tetsecyrillic;04B4 Theta;0398 Thook;01AC Thorn;00DE Thornsmall;F7FE Threeroman;2162 Tildesmall;F6FE Tiwnarmenian;054F Tlinebelow;1E6E Tmonospace;FF34 Toarmenian;0539 Tonefive;01BC Tonesix;0184 Tonetwo;01A7 Tretroflexhook;01AE Tsecyrillic;0426 Tshecyrillic;040B Tsmall;F774 Twelveroman;216B Tworoman;2161 U;0055 Uacute;00DA Uacutesmall;F7FA Ubreve;016C Ucaron;01D3 Ucircle;24CA Ucircumflex;00DB Ucircumflexbelow;1E76 Ucircumflexsmall;F7FB Ucyrillic;0423 Udblacute;0170 Udblgrave;0214 Udieresis;00DC Udieresisacute;01D7 Udieresisbelow;1E72 Udieresiscaron;01D9 Udieresiscyrillic;04F0 Udieresisgrave;01DB Udieresismacron;01D5 Udieresissmall;F7FC Udotbelow;1EE4 Ugrave;00D9 Ugravesmall;F7F9 Uhookabove;1EE6 Uhorn;01AF Uhornacute;1EE8 Uhorndotbelow;1EF0 Uhorngrave;1EEA Uhornhookabove;1EEC Uhorntilde;1EEE Uhungarumlaut;0170 Uhungarumlautcyrillic;04F2 Uinvertedbreve;0216 Ukcyrillic;0478 Umacron;016A Umacroncyrillic;04EE Umacrondieresis;1E7A Umonospace;FF35 Uogonek;0172 Upsilon;03A5 Upsilon1;03D2 Upsilonacutehooksymbolgreek;03D3 Upsilonafrican;01B1 Upsilondieresis;03AB Upsilondieresishooksymbolgreek;03D4 Upsilonhooksymbol;03D2 Upsilontonos;038E Uring;016E Ushortcyrillic;040E Usmall;F775 Ustraightcyrillic;04AE Ustraightstrokecyrillic;04B0 Utilde;0168 Utildeacute;1E78 Utildebelow;1E74 V;0056 Vcircle;24CB Vdotbelow;1E7E Vecyrillic;0412 Vewarmenian;054E Vhook;01B2 Vmonospace;FF36 Voarmenian;0548 Vsmall;F776 Vtilde;1E7C W;0057 Wacute;1E82 Wcircle;24CC Wcircumflex;0174 Wdieresis;1E84 Wdotaccent;1E86 Wdotbelow;1E88 Wgrave;1E80 Wmonospace;FF37 Wsmall;F777 X;0058 Xcircle;24CD Xdieresis;1E8C Xdotaccent;1E8A Xeharmenian;053D Xi;039E Xmonospace;FF38 Xsmall;F778 Y;0059 Yacute;00DD Yacutesmall;F7FD Yatcyrillic;0462 Ycircle;24CE Ycircumflex;0176 Ydieresis;0178 Ydieresissmall;F7FF Ydotaccent;1E8E Ydotbelow;1EF4 Yericyrillic;042B Yerudieresiscyrillic;04F8 Ygrave;1EF2 Yhook;01B3 Yhookabove;1EF6 Yiarmenian;0545 Yicyrillic;0407 Yiwnarmenian;0552 Ymonospace;FF39 Ysmall;F779 Ytilde;1EF8 Yusbigcyrillic;046A Yusbigiotifiedcyrillic;046C Yuslittlecyrillic;0466 Yuslittleiotifiedcyrillic;0468 Z;005A Zaarmenian;0536 Zacute;0179 Zcaron;017D Zcaronsmall;F6FF Zcircle;24CF Zcircumflex;1E90 Zdot;017B Zdotaccent;017B Zdotbelow;1E92 Zecyrillic;0417 Zedescendercyrillic;0498 Zedieresiscyrillic;04DE Zeta;0396 Zhearmenian;053A Zhebrevecyrillic;04C1 Zhecyrillic;0416 Zhedescendercyrillic;0496 Zhedieresiscyrillic;04DC Zlinebelow;1E94 Zmonospace;FF3A Zsmall;F77A Zstroke;01B5 a;0061 aabengali;0986 aacute;00E1 aadeva;0906 aagujarati;0A86 aagurmukhi;0A06 aamatragurmukhi;0A3E aarusquare;3303 aavowelsignbengali;09BE aavowelsigndeva;093E aavowelsigngujarati;0ABE abbreviationmarkarmenian;055F abbreviationsigndeva;0970 abengali;0985 abopomofo;311A abreve;0103 abreveacute;1EAF abrevecyrillic;04D1 abrevedotbelow;1EB7 abrevegrave;1EB1 abrevehookabove;1EB3 abrevetilde;1EB5 acaron;01CE acircle;24D0 acircumflex;00E2 acircumflexacute;1EA5 acircumflexdotbelow;1EAD acircumflexgrave;1EA7 acircumflexhookabove;1EA9 acircumflextilde;1EAB acute;00B4 acutebelowcmb;0317 acutecmb;0301 acutecomb;0301 acutedeva;0954 acutelowmod;02CF acutetonecmb;0341 acyrillic;0430 adblgrave;0201 addakgurmukhi;0A71 adeva;0905 adieresis;00E4 adieresiscyrillic;04D3 adieresismacron;01DF adotbelow;1EA1 adotmacron;01E1 ae;00E6 aeacute;01FD aekorean;3150 aemacron;01E3 afii00208;2015 afii08941;20A4 afii10017;0410 afii10018;0411 afii10019;0412 afii10020;0413 afii10021;0414 afii10022;0415 afii10023;0401 afii10024;0416 afii10025;0417 afii10026;0418 afii10027;0419 afii10028;041A afii10029;041B afii10030;041C afii10031;041D afii10032;041E afii10033;041F afii10034;0420 afii10035;0421 afii10036;0422 afii10037;0423 afii10038;0424 afii10039;0425 afii10040;0426 afii10041;0427 afii10042;0428 afii10043;0429 afii10044;042A afii10045;042B afii10046;042C afii10047;042D afii10048;042E afii10049;042F afii10050;0490 afii10051;0402 afii10052;0403 afii10053;0404 afii10054;0405 afii10055;0406 afii10056;0407 afii10057;0408 afii10058;0409 afii10059;040A afii10060;040B afii10061;040C afii10062;040E afii10063;F6C4 afii10064;F6C5 afii10065;0430 afii10066;0431 afii10067;0432 afii10068;0433 afii10069;0434 afii10070;0435 afii10071;0451 afii10072;0436 afii10073;0437 afii10074;0438 afii10075;0439 afii10076;043A afii10077;043B afii10078;043C afii10079;043D afii10080;043E afii10081;043F afii10082;0440 afii10083;0441 afii10084;0442 afii10085;0443 afii10086;0444 afii10087;0445 afii10088;0446 afii10089;0447 afii10090;0448 afii10091;0449 afii10092;044A afii10093;044B afii10094;044C afii10095;044D afii10096;044E afii10097;044F afii10098;0491 afii10099;0452 afii10100;0453 afii10101;0454 afii10102;0455 afii10103;0456 afii10104;0457 afii10105;0458 afii10106;0459 afii10107;045A afii10108;045B afii10109;045C afii10110;045E afii10145;040F afii10146;0462 afii10147;0472 afii10148;0474 afii10192;F6C6 afii10193;045F afii10194;0463 afii10195;0473 afii10196;0475 afii10831;F6C7 afii10832;F6C8 afii10846;04D9 afii299;200E afii300;200F afii301;200D afii57381;066A afii57388;060C afii57392;0660 afii57393;0661 afii57394;0662 afii57395;0663 afii57396;0664 afii57397;0665 afii57398;0666 afii57399;0667 afii57400;0668 afii57401;0669 afii57403;061B afii57407;061F afii57409;0621 afii57410;0622 afii57411;0623 afii57412;0624 afii57413;0625 afii57414;0626 afii57415;0627 afii57416;0628 afii57417;0629 afii57418;062A afii57419;062B afii57420;062C afii57421;062D afii57422;062E afii57423;062F afii57424;0630 afii57425;0631 afii57426;0632 afii57427;0633 afii57428;0634 afii57429;0635 afii57430;0636 afii57431;0637 afii57432;0638 afii57433;0639 afii57434;063A afii57440;0640 afii57441;0641 afii57442;0642 afii57443;0643 afii57444;0644 afii57445;0645 afii57446;0646 afii57448;0648 afii57449;0649 afii57450;064A afii57451;064B afii57452;064C afii57453;064D afii57454;064E afii57455;064F afii57456;0650 afii57457;0651 afii57458;0652 afii57470;0647 afii57505;06A4 afii57506;067E afii57507;0686 afii57508;0698 afii57509;06AF afii57511;0679 afii57512;0688 afii57513;0691 afii57514;06BA afii57519;06D2 afii57534;06D5 afii57636;20AA afii57645;05BE afii57658;05C3 afii57664;05D0 afii57665;05D1 afii57666;05D2 afii57667;05D3 afii57668;05D4 afii57669;05D5 afii57670;05D6 afii57671;05D7 afii57672;05D8 afii57673;05D9 afii57674;05DA afii57675;05DB afii57676;05DC afii57677;05DD afii57678;05DE afii57679;05DF afii57680;05E0 afii57681;05E1 afii57682;05E2 afii57683;05E3 afii57684;05E4 afii57685;05E5 afii57686;05E6 afii57687;05E7 afii57688;05E8 afii57689;05E9 afii57690;05EA afii57694;FB2A afii57695;FB2B afii57700;FB4B afii57705;FB1F afii57716;05F0 afii57717;05F1 afii57718;05F2 afii57723;FB35 afii57793;05B4 afii57794;05B5 afii57795;05B6 afii57796;05BB afii57797;05B8 afii57798;05B7 afii57799;05B0 afii57800;05B2 afii57801;05B1 afii57802;05B3 afii57803;05C2 afii57804;05C1 afii57806;05B9 afii57807;05BC afii57839;05BD afii57841;05BF afii57842;05C0 afii57929;02BC afii61248;2105 afii61289;2113 afii61352;2116 afii61573;202C afii61574;202D afii61575;202E afii61664;200C afii63167;066D afii64937;02BD agrave;00E0 agujarati;0A85 agurmukhi;0A05 ahiragana;3042 ahookabove;1EA3 aibengali;0990 aibopomofo;311E aideva;0910 aiecyrillic;04D5 aigujarati;0A90 aigurmukhi;0A10 aimatragurmukhi;0A48 ainarabic;0639 ainfinalarabic;FECA aininitialarabic;FECB ainmedialarabic;FECC ainvertedbreve;0203 aivowelsignbengali;09C8 aivowelsigndeva;0948 aivowelsigngujarati;0AC8 akatakana;30A2 akatakanahalfwidth;FF71 akorean;314F alef;05D0 alefarabic;0627 alefdageshhebrew;FB30 aleffinalarabic;FE8E alefhamzaabovearabic;0623 alefhamzaabovefinalarabic;FE84 alefhamzabelowarabic;0625 alefhamzabelowfinalarabic;FE88 alefhebrew;05D0 aleflamedhebrew;FB4F alefmaddaabovearabic;0622 alefmaddaabovefinalarabic;FE82 alefmaksuraarabic;0649 alefmaksurafinalarabic;FEF0 alefmaksurainitialarabic;FEF3 alefmaksuramedialarabic;FEF4 alefpatahhebrew;FB2E alefqamatshebrew;FB2F aleph;2135 allequal;224C alpha;03B1 alphatonos;03AC amacron;0101 amonospace;FF41 ampersand;0026 ampersandmonospace;FF06 ampersandsmall;F726 amsquare;33C2 anbopomofo;3122 angbopomofo;3124 angkhankhuthai;0E5A angle;2220 anglebracketleft;3008 anglebracketleftvertical;FE3F anglebracketright;3009 anglebracketrightvertical;FE40 angleleft;2329 angleright;232A angstrom;212B anoteleia;0387 anudattadeva;0952 anusvarabengali;0982 anusvaradeva;0902 anusvaragujarati;0A82 aogonek;0105 apaatosquare;3300 aparen;249C apostrophearmenian;055A apostrophemod;02BC apple;F8FF approaches;2250 approxequal;2248 approxequalorimage;2252 approximatelyequal;2245 araeaekorean;318E araeakorean;318D arc;2312 arighthalfring;1E9A aring;00E5 aringacute;01FB aringbelow;1E01 arrowboth;2194 arrowdashdown;21E3 arrowdashleft;21E0 arrowdashright;21E2 arrowdashup;21E1 arrowdblboth;21D4 arrowdbldown;21D3 arrowdblleft;21D0 arrowdblright;21D2 arrowdblup;21D1 arrowdown;2193 arrowdownleft;2199 arrowdownright;2198 arrowdownwhite;21E9 arrowheaddownmod;02C5 arrowheadleftmod;02C2 arrowheadrightmod;02C3 arrowheadupmod;02C4 arrowhorizex;F8E7 arrowleft;2190 arrowleftdbl;21D0 arrowleftdblstroke;21CD arrowleftoverright;21C6 arrowleftwhite;21E6 arrowright;2192 arrowrightdblstroke;21CF arrowrightheavy;279E arrowrightoverleft;21C4 arrowrightwhite;21E8 arrowtableft;21E4 arrowtabright;21E5 arrowup;2191 arrowupdn;2195 arrowupdnbse;21A8 arrowupdownbase;21A8 arrowupleft;2196 arrowupleftofdown;21C5 arrowupright;2197 arrowupwhite;21E7 arrowvertex;F8E6 asciicircum;005E asciicircummonospace;FF3E asciitilde;007E asciitildemonospace;FF5E ascript;0251 ascriptturned;0252 asmallhiragana;3041 asmallkatakana;30A1 asmallkatakanahalfwidth;FF67 asterisk;002A asteriskaltonearabic;066D asteriskarabic;066D asteriskmath;2217 asteriskmonospace;FF0A asterisksmall;FE61 asterism;2042 asuperior;F6E9 asymptoticallyequal;2243 at;0040 atilde;00E3 atmonospace;FF20 atsmall;FE6B aturned;0250 aubengali;0994 aubopomofo;3120 audeva;0914 augujarati;0A94 augurmukhi;0A14 aulengthmarkbengali;09D7 aumatragurmukhi;0A4C auvowelsignbengali;09CC auvowelsigndeva;094C auvowelsigngujarati;0ACC avagrahadeva;093D aybarmenian;0561 ayin;05E2 ayinaltonehebrew;FB20 ayinhebrew;05E2 b;0062 babengali;09AC backslash;005C backslashmonospace;FF3C badeva;092C bagujarati;0AAC bagurmukhi;0A2C bahiragana;3070 bahtthai;0E3F bakatakana;30D0 bar;007C barmonospace;FF5C bbopomofo;3105 bcircle;24D1 bdotaccent;1E03 bdotbelow;1E05 beamedsixteenthnotes;266C because;2235 becyrillic;0431 beharabic;0628 behfinalarabic;FE90 behinitialarabic;FE91 behiragana;3079 behmedialarabic;FE92 behmeeminitialarabic;FC9F behmeemisolatedarabic;FC08 behnoonfinalarabic;FC6D bekatakana;30D9 benarmenian;0562 bet;05D1 beta;03B2 betasymbolgreek;03D0 betdagesh;FB31 betdageshhebrew;FB31 bethebrew;05D1 betrafehebrew;FB4C bhabengali;09AD bhadeva;092D bhagujarati;0AAD bhagurmukhi;0A2D bhook;0253 bihiragana;3073 bikatakana;30D3 bilabialclick;0298 bindigurmukhi;0A02 birusquare;3331 blackcircle;25CF blackdiamond;25C6 blackdownpointingtriangle;25BC blackleftpointingpointer;25C4 blackleftpointingtriangle;25C0 blacklenticularbracketleft;3010 blacklenticularbracketleftvertical;FE3B blacklenticularbracketright;3011 blacklenticularbracketrightvertical;FE3C blacklowerlefttriangle;25E3 blacklowerrighttriangle;25E2 blackrectangle;25AC blackrightpointingpointer;25BA blackrightpointingtriangle;25B6 blacksmallsquare;25AA blacksmilingface;263B blacksquare;25A0 blackstar;2605 blackupperlefttriangle;25E4 blackupperrighttriangle;25E5 blackuppointingsmalltriangle;25B4 blackuppointingtriangle;25B2 blank;2423 blinebelow;1E07 block;2588 bmonospace;FF42 bobaimaithai;0E1A bohiragana;307C bokatakana;30DC bparen;249D bqsquare;33C3 braceex;F8F4 braceleft;007B braceleftbt;F8F3 braceleftmid;F8F2 braceleftmonospace;FF5B braceleftsmall;FE5B bracelefttp;F8F1 braceleftvertical;FE37 braceright;007D bracerightbt;F8FE bracerightmid;F8FD bracerightmonospace;FF5D bracerightsmall;FE5C bracerighttp;F8FC bracerightvertical;FE38 bracketleft;005B bracketleftbt;F8F0 bracketleftex;F8EF bracketleftmonospace;FF3B bracketlefttp;F8EE bracketright;005D bracketrightbt;F8FB bracketrightex;F8FA bracketrightmonospace;FF3D bracketrighttp;F8F9 breve;02D8 brevebelowcmb;032E brevecmb;0306 breveinvertedbelowcmb;032F breveinvertedcmb;0311 breveinverteddoublecmb;0361 bridgebelowcmb;032A bridgeinvertedbelowcmb;033A brokenbar;00A6 bstroke;0180 bsuperior;F6EA btopbar;0183 buhiragana;3076 bukatakana;30D6 bullet;2022 bulletinverse;25D8 bulletoperator;2219 bullseye;25CE c;0063 caarmenian;056E cabengali;099A cacute;0107 cadeva;091A cagujarati;0A9A cagurmukhi;0A1A calsquare;3388 candrabindubengali;0981 candrabinducmb;0310 candrabindudeva;0901 candrabindugujarati;0A81 capslock;21EA careof;2105 caron;02C7 caronbelowcmb;032C caroncmb;030C carriagereturn;21B5 cbopomofo;3118 ccaron;010D ccedilla;00E7 ccedillaacute;1E09 ccircle;24D2 ccircumflex;0109 ccurl;0255 cdot;010B cdotaccent;010B cdsquare;33C5 cedilla;00B8 cedillacmb;0327 cent;00A2 centigrade;2103 centinferior;F6DF centmonospace;FFE0 centoldstyle;F7A2 centsuperior;F6E0 chaarmenian;0579 chabengali;099B chadeva;091B chagujarati;0A9B chagurmukhi;0A1B chbopomofo;3114 cheabkhasiancyrillic;04BD checkmark;2713 checyrillic;0447 chedescenderabkhasiancyrillic;04BF chedescendercyrillic;04B7 chedieresiscyrillic;04F5 cheharmenian;0573 chekhakassiancyrillic;04CC cheverticalstrokecyrillic;04B9 chi;03C7 chieuchacirclekorean;3277 chieuchaparenkorean;3217 chieuchcirclekorean;3269 chieuchkorean;314A chieuchparenkorean;3209 chochangthai;0E0A chochanthai;0E08 chochingthai;0E09 chochoethai;0E0C chook;0188 cieucacirclekorean;3276 cieucaparenkorean;3216 cieuccirclekorean;3268 cieuckorean;3148 cieucparenkorean;3208 cieucuparenkorean;321C circle;25CB circlemultiply;2297 circleot;2299 circleplus;2295 circlepostalmark;3036 circlewithlefthalfblack;25D0 circlewithrighthalfblack;25D1 circumflex;02C6 circumflexbelowcmb;032D circumflexcmb;0302 clear;2327 clickalveolar;01C2 clickdental;01C0 clicklateral;01C1 clickretroflex;01C3 club;2663 clubsuitblack;2663 clubsuitwhite;2667 cmcubedsquare;33A4 cmonospace;FF43 cmsquaredsquare;33A0 coarmenian;0581 colon;003A colonmonetary;20A1 colonmonospace;FF1A colonsign;20A1 colonsmall;FE55 colontriangularhalfmod;02D1 colontriangularmod;02D0 comma;002C commaabovecmb;0313 commaaboverightcmb;0315 commaaccent;F6C3 commaarabic;060C commaarmenian;055D commainferior;F6E1 commamonospace;FF0C commareversedabovecmb;0314 commareversedmod;02BD commasmall;FE50 commasuperior;F6E2 commaturnedabovecmb;0312 commaturnedmod;02BB compass;263C congruent;2245 contourintegral;222E control;2303 controlACK;0006 controlBEL;0007 controlBS;0008 controlCAN;0018 controlCR;000D controlDC1;0011 controlDC2;0012 controlDC3;0013 controlDC4;0014 controlDEL;007F controlDLE;0010 controlEM;0019 controlENQ;0005 controlEOT;0004 controlESC;001B controlETB;0017 controlETX;0003 controlFF;000C controlFS;001C controlGS;001D controlHT;0009 controlLF;000A controlNAK;0015 controlRS;001E controlSI;000F controlSO;000E controlSOT;0002 controlSTX;0001 controlSUB;001A controlSYN;0016 controlUS;001F controlVT;000B copyright;00A9 copyrightsans;F8E9 copyrightserif;F6D9 cornerbracketleft;300C cornerbracketlefthalfwidth;FF62 cornerbracketleftvertical;FE41 cornerbracketright;300D cornerbracketrighthalfwidth;FF63 cornerbracketrightvertical;FE42 corporationsquare;337F cosquare;33C7 coverkgsquare;33C6 cparen;249E cruzeiro;20A2 cstretched;0297 curlyand;22CF curlyor;22CE currency;00A4 cyrBreve;F6D1 cyrFlex;F6D2 cyrbreve;F6D4 cyrflex;F6D5 d;0064 daarmenian;0564 dabengali;09A6 dadarabic;0636 dadeva;0926 dadfinalarabic;FEBE dadinitialarabic;FEBF dadmedialarabic;FEC0 dagesh;05BC dageshhebrew;05BC dagger;2020 daggerdbl;2021 dagujarati;0AA6 dagurmukhi;0A26 dahiragana;3060 dakatakana;30C0 dalarabic;062F dalet;05D3 daletdagesh;FB33 daletdageshhebrew;FB33 dalethatafpatah;05D3 05B2 dalethatafpatahhebrew;05D3 05B2 dalethatafsegol;05D3 05B1 dalethatafsegolhebrew;05D3 05B1 dalethebrew;05D3 dalethiriq;05D3 05B4 dalethiriqhebrew;05D3 05B4 daletholam;05D3 05B9 daletholamhebrew;05D3 05B9 daletpatah;05D3 05B7 daletpatahhebrew;05D3 05B7 daletqamats;05D3 05B8 daletqamatshebrew;05D3 05B8 daletqubuts;05D3 05BB daletqubutshebrew;05D3 05BB daletsegol;05D3 05B6 daletsegolhebrew;05D3 05B6 daletsheva;05D3 05B0 daletshevahebrew;05D3 05B0 dalettsere;05D3 05B5 dalettserehebrew;05D3 05B5 dalfinalarabic;FEAA dammaarabic;064F dammalowarabic;064F dammatanaltonearabic;064C dammatanarabic;064C danda;0964 dargahebrew;05A7 dargalefthebrew;05A7 dasiapneumatacyrilliccmb;0485 dblGrave;F6D3 dblanglebracketleft;300A dblanglebracketleftvertical;FE3D dblanglebracketright;300B dblanglebracketrightvertical;FE3E dblarchinvertedbelowcmb;032B dblarrowleft;21D4 dblarrowright;21D2 dbldanda;0965 dblgrave;F6D6 dblgravecmb;030F dblintegral;222C dbllowline;2017 dbllowlinecmb;0333 dbloverlinecmb;033F dblprimemod;02BA dblverticalbar;2016 dblverticallineabovecmb;030E dbopomofo;3109 dbsquare;33C8 dcaron;010F dcedilla;1E11 dcircle;24D3 dcircumflexbelow;1E13 dcroat;0111 ddabengali;09A1 ddadeva;0921 ddagujarati;0AA1 ddagurmukhi;0A21 ddalarabic;0688 ddalfinalarabic;FB89 dddhadeva;095C ddhabengali;09A2 ddhadeva;0922 ddhagujarati;0AA2 ddhagurmukhi;0A22 ddotaccent;1E0B ddotbelow;1E0D decimalseparatorarabic;066B decimalseparatorpersian;066B decyrillic;0434 degree;00B0 dehihebrew;05AD dehiragana;3067 deicoptic;03EF dekatakana;30C7 deleteleft;232B deleteright;2326 delta;03B4 deltaturned;018D denominatorminusonenumeratorbengali;09F8 dezh;02A4 dhabengali;09A7 dhadeva;0927 dhagujarati;0AA7 dhagurmukhi;0A27 dhook;0257 dialytikatonos;0385 dialytikatonoscmb;0344 diamond;2666 diamondsuitwhite;2662 dieresis;00A8 dieresisacute;F6D7 dieresisbelowcmb;0324 dieresiscmb;0308 dieresisgrave;F6D8 dieresistonos;0385 dihiragana;3062 dikatakana;30C2 dittomark;3003 divide;00F7 divides;2223 divisionslash;2215 djecyrillic;0452 dkshade;2593 dlinebelow;1E0F dlsquare;3397 dmacron;0111 dmonospace;FF44 dnblock;2584 dochadathai;0E0E dodekthai;0E14 dohiragana;3069 dokatakana;30C9 dollar;0024 dollarinferior;F6E3 dollarmonospace;FF04 dollaroldstyle;F724 dollarsmall;FE69 dollarsuperior;F6E4 dong;20AB dorusquare;3326 dotaccent;02D9 dotaccentcmb;0307 dotbelowcmb;0323 dotbelowcomb;0323 dotkatakana;30FB dotlessi;0131 dotlessj;F6BE dotlessjstrokehook;0284 dotmath;22C5 dottedcircle;25CC doubleyodpatah;FB1F doubleyodpatahhebrew;FB1F downtackbelowcmb;031E downtackmod;02D5 dparen;249F dsuperior;F6EB dtail;0256 dtopbar;018C duhiragana;3065 dukatakana;30C5 dz;01F3 dzaltone;02A3 dzcaron;01C6 dzcurl;02A5 dzeabkhasiancyrillic;04E1 dzecyrillic;0455 dzhecyrillic;045F e;0065 eacute;00E9 earth;2641 ebengali;098F ebopomofo;311C ebreve;0115 ecandradeva;090D ecandragujarati;0A8D ecandravowelsigndeva;0945 ecandravowelsigngujarati;0AC5 ecaron;011B ecedillabreve;1E1D echarmenian;0565 echyiwnarmenian;0587 ecircle;24D4 ecircumflex;00EA ecircumflexacute;1EBF ecircumflexbelow;1E19 ecircumflexdotbelow;1EC7 ecircumflexgrave;1EC1 ecircumflexhookabove;1EC3 ecircumflextilde;1EC5 ecyrillic;0454 edblgrave;0205 edeva;090F edieresis;00EB edot;0117 edotaccent;0117 edotbelow;1EB9 eegurmukhi;0A0F eematragurmukhi;0A47 efcyrillic;0444 egrave;00E8 egujarati;0A8F eharmenian;0567 ehbopomofo;311D ehiragana;3048 ehookabove;1EBB eibopomofo;311F eight;0038 eightarabic;0668 eightbengali;09EE eightcircle;2467 eightcircleinversesansserif;2791 eightdeva;096E eighteencircle;2471 eighteenparen;2485 eighteenperiod;2499 eightgujarati;0AEE eightgurmukhi;0A6E eighthackarabic;0668 eighthangzhou;3028 eighthnotebeamed;266B eightideographicparen;3227 eightinferior;2088 eightmonospace;FF18 eightoldstyle;F738 eightparen;247B eightperiod;248F eightpersian;06F8 eightroman;2177 eightsuperior;2078 eightthai;0E58 einvertedbreve;0207 eiotifiedcyrillic;0465 ekatakana;30A8 ekatakanahalfwidth;FF74 ekonkargurmukhi;0A74 ekorean;3154 elcyrillic;043B element;2208 elevencircle;246A elevenparen;247E elevenperiod;2492 elevenroman;217A ellipsis;2026 ellipsisvertical;22EE emacron;0113 emacronacute;1E17 emacrongrave;1E15 emcyrillic;043C emdash;2014 emdashvertical;FE31 emonospace;FF45 emphasismarkarmenian;055B emptyset;2205 enbopomofo;3123 encyrillic;043D endash;2013 endashvertical;FE32 endescendercyrillic;04A3 eng;014B engbopomofo;3125 enghecyrillic;04A5 enhookcyrillic;04C8 enspace;2002 eogonek;0119 eokorean;3153 eopen;025B eopenclosed;029A eopenreversed;025C eopenreversedclosed;025E eopenreversedhook;025D eparen;24A0 epsilon;03B5 epsilontonos;03AD equal;003D equalmonospace;FF1D equalsmall;FE66 equalsuperior;207C equivalence;2261 erbopomofo;3126 ercyrillic;0440 ereversed;0258 ereversedcyrillic;044D escyrillic;0441 esdescendercyrillic;04AB esh;0283 eshcurl;0286 eshortdeva;090E eshortvowelsigndeva;0946 eshreversedloop;01AA eshsquatreversed;0285 esmallhiragana;3047 esmallkatakana;30A7 esmallkatakanahalfwidth;FF6A estimated;212E esuperior;F6EC eta;03B7 etarmenian;0568 etatonos;03AE eth;00F0 etilde;1EBD etildebelow;1E1B etnahtafoukhhebrew;0591 etnahtafoukhlefthebrew;0591 etnahtahebrew;0591 etnahtalefthebrew;0591 eturned;01DD eukorean;3161 euro;20AC evowelsignbengali;09C7 evowelsigndeva;0947 evowelsigngujarati;0AC7 exclam;0021 exclamarmenian;055C exclamdbl;203C exclamdown;00A1 exclamdownsmall;F7A1 exclammonospace;FF01 exclamsmall;F721 existential;2203 ezh;0292 ezhcaron;01EF ezhcurl;0293 ezhreversed;01B9 ezhtail;01BA f;0066 fadeva;095E fagurmukhi;0A5E fahrenheit;2109 fathaarabic;064E fathalowarabic;064E fathatanarabic;064B fbopomofo;3108 fcircle;24D5 fdotaccent;1E1F feharabic;0641 feharmenian;0586 fehfinalarabic;FED2 fehinitialarabic;FED3 fehmedialarabic;FED4 feicoptic;03E5 female;2640 ff;FB00 ffi;FB03 ffl;FB04 fi;FB01 fifteencircle;246E fifteenparen;2482 fifteenperiod;2496 figuredash;2012 filledbox;25A0 filledrect;25AC finalkaf;05DA finalkafdagesh;FB3A finalkafdageshhebrew;FB3A finalkafhebrew;05DA finalkafqamats;05DA 05B8 finalkafqamatshebrew;05DA 05B8 finalkafsheva;05DA 05B0 finalkafshevahebrew;05DA 05B0 finalmem;05DD finalmemhebrew;05DD finalnun;05DF finalnunhebrew;05DF finalpe;05E3 finalpehebrew;05E3 finaltsadi;05E5 finaltsadihebrew;05E5 firsttonechinese;02C9 fisheye;25C9 fitacyrillic;0473 five;0035 fivearabic;0665 fivebengali;09EB fivecircle;2464 fivecircleinversesansserif;278E fivedeva;096B fiveeighths;215D fivegujarati;0AEB fivegurmukhi;0A6B fivehackarabic;0665 fivehangzhou;3025 fiveideographicparen;3224 fiveinferior;2085 fivemonospace;FF15 fiveoldstyle;F735 fiveparen;2478 fiveperiod;248C fivepersian;06F5 fiveroman;2174 fivesuperior;2075 fivethai;0E55 fl;FB02 florin;0192 fmonospace;FF46 fmsquare;3399 fofanthai;0E1F fofathai;0E1D fongmanthai;0E4F forall;2200 four;0034 fourarabic;0664 fourbengali;09EA fourcircle;2463 fourcircleinversesansserif;278D fourdeva;096A fourgujarati;0AEA fourgurmukhi;0A6A fourhackarabic;0664 fourhangzhou;3024 fourideographicparen;3223 fourinferior;2084 fourmonospace;FF14 fournumeratorbengali;09F7 fouroldstyle;F734 fourparen;2477 fourperiod;248B fourpersian;06F4 fourroman;2173 foursuperior;2074 fourteencircle;246D fourteenparen;2481 fourteenperiod;2495 fourthai;0E54 fourthtonechinese;02CB fparen;24A1 fraction;2044 franc;20A3 g;0067 gabengali;0997 gacute;01F5 gadeva;0917 gafarabic;06AF gaffinalarabic;FB93 gafinitialarabic;FB94 gafmedialarabic;FB95 gagujarati;0A97 gagurmukhi;0A17 gahiragana;304C gakatakana;30AC gamma;03B3 gammalatinsmall;0263 gammasuperior;02E0 gangiacoptic;03EB gbopomofo;310D gbreve;011F gcaron;01E7 gcedilla;0123 gcircle;24D6 gcircumflex;011D gcommaaccent;0123 gdot;0121 gdotaccent;0121 gecyrillic;0433 gehiragana;3052 gekatakana;30B2 geometricallyequal;2251 gereshaccenthebrew;059C gereshhebrew;05F3 gereshmuqdamhebrew;059D germandbls;00DF gershayimaccenthebrew;059E gershayimhebrew;05F4 getamark;3013 ghabengali;0998 ghadarmenian;0572 ghadeva;0918 ghagujarati;0A98 ghagurmukhi;0A18 ghainarabic;063A ghainfinalarabic;FECE ghaininitialarabic;FECF ghainmedialarabic;FED0 ghemiddlehookcyrillic;0495 ghestrokecyrillic;0493 gheupturncyrillic;0491 ghhadeva;095A ghhagurmukhi;0A5A ghook;0260 ghzsquare;3393 gihiragana;304E gikatakana;30AE gimarmenian;0563 gimel;05D2 gimeldagesh;FB32 gimeldageshhebrew;FB32 gimelhebrew;05D2 gjecyrillic;0453 glottalinvertedstroke;01BE glottalstop;0294 glottalstopinverted;0296 glottalstopmod;02C0 glottalstopreversed;0295 glottalstopreversedmod;02C1 glottalstopreversedsuperior;02E4 glottalstopstroke;02A1 glottalstopstrokereversed;02A2 gmacron;1E21 gmonospace;FF47 gohiragana;3054 gokatakana;30B4 gparen;24A2 gpasquare;33AC gradient;2207 grave;0060 gravebelowcmb;0316 gravecmb;0300 gravecomb;0300 gravedeva;0953 gravelowmod;02CE gravemonospace;FF40 gravetonecmb;0340 greater;003E greaterequal;2265 greaterequalorless;22DB greatermonospace;FF1E greaterorequivalent;2273 greaterorless;2277 greateroverequal;2267 greatersmall;FE65 gscript;0261 gstroke;01E5 guhiragana;3050 guillemotleft;00AB guillemotright;00BB guilsinglleft;2039 guilsinglright;203A gukatakana;30B0 guramusquare;3318 gysquare;33C9 h;0068 haabkhasiancyrillic;04A9 haaltonearabic;06C1 habengali;09B9 hadescendercyrillic;04B3 hadeva;0939 hagujarati;0AB9 hagurmukhi;0A39 haharabic;062D hahfinalarabic;FEA2 hahinitialarabic;FEA3 hahiragana;306F hahmedialarabic;FEA4 haitusquare;332A hakatakana;30CF hakatakanahalfwidth;FF8A halantgurmukhi;0A4D hamzaarabic;0621 hamzadammaarabic;0621 064F hamzadammatanarabic;0621 064C hamzafathaarabic;0621 064E hamzafathatanarabic;0621 064B hamzalowarabic;0621 hamzalowkasraarabic;0621 0650 hamzalowkasratanarabic;0621 064D hamzasukunarabic;0621 0652 hangulfiller;3164 hardsigncyrillic;044A harpoonleftbarbup;21BC harpoonrightbarbup;21C0 hasquare;33CA hatafpatah;05B2 hatafpatah16;05B2 hatafpatah23;05B2 hatafpatah2f;05B2 hatafpatahhebrew;05B2 hatafpatahnarrowhebrew;05B2 hatafpatahquarterhebrew;05B2 hatafpatahwidehebrew;05B2 hatafqamats;05B3 hatafqamats1b;05B3 hatafqamats28;05B3 hatafqamats34;05B3 hatafqamatshebrew;05B3 hatafqamatsnarrowhebrew;05B3 hatafqamatsquarterhebrew;05B3 hatafqamatswidehebrew;05B3 hatafsegol;05B1 hatafsegol17;05B1 hatafsegol24;05B1 hatafsegol30;05B1 hatafsegolhebrew;05B1 hatafsegolnarrowhebrew;05B1 hatafsegolquarterhebrew;05B1 hatafsegolwidehebrew;05B1 hbar;0127 hbopomofo;310F hbrevebelow;1E2B hcedilla;1E29 hcircle;24D7 hcircumflex;0125 hdieresis;1E27 hdotaccent;1E23 hdotbelow;1E25 he;05D4 heart;2665 heartsuitblack;2665 heartsuitwhite;2661 hedagesh;FB34 hedageshhebrew;FB34 hehaltonearabic;06C1 heharabic;0647 hehebrew;05D4 hehfinalaltonearabic;FBA7 hehfinalalttwoarabic;FEEA hehfinalarabic;FEEA hehhamzaabovefinalarabic;FBA5 hehhamzaaboveisolatedarabic;FBA4 hehinitialaltonearabic;FBA8 hehinitialarabic;FEEB hehiragana;3078 hehmedialaltonearabic;FBA9 hehmedialarabic;FEEC heiseierasquare;337B hekatakana;30D8 hekatakanahalfwidth;FF8D hekutaarusquare;3336 henghook;0267 herutusquare;3339 het;05D7 hethebrew;05D7 hhook;0266 hhooksuperior;02B1 hieuhacirclekorean;327B hieuhaparenkorean;321B hieuhcirclekorean;326D hieuhkorean;314E hieuhparenkorean;320D hihiragana;3072 hikatakana;30D2 hikatakanahalfwidth;FF8B hiriq;05B4 hiriq14;05B4 hiriq21;05B4 hiriq2d;05B4 hiriqhebrew;05B4 hiriqnarrowhebrew;05B4 hiriqquarterhebrew;05B4 hiriqwidehebrew;05B4 hlinebelow;1E96 hmonospace;FF48 hoarmenian;0570 hohipthai;0E2B hohiragana;307B hokatakana;30DB hokatakanahalfwidth;FF8E holam;05B9 holam19;05B9 holam26;05B9 holam32;05B9 holamhebrew;05B9 holamnarrowhebrew;05B9 holamquarterhebrew;05B9 holamwidehebrew;05B9 honokhukthai;0E2E hookabovecomb;0309 hookcmb;0309 hookpalatalizedbelowcmb;0321 hookretroflexbelowcmb;0322 hoonsquare;3342 horicoptic;03E9 horizontalbar;2015 horncmb;031B hotsprings;2668 house;2302 hparen;24A3 hsuperior;02B0 hturned;0265 huhiragana;3075 huiitosquare;3333 hukatakana;30D5 hukatakanahalfwidth;FF8C hungarumlaut;02DD hungarumlautcmb;030B hv;0195 hyphen;002D hypheninferior;F6E5 hyphenmonospace;FF0D hyphensmall;FE63 hyphensuperior;F6E6 hyphentwo;2010 i;0069 iacute;00ED iacyrillic;044F ibengali;0987 ibopomofo;3127 ibreve;012D icaron;01D0 icircle;24D8 icircumflex;00EE icyrillic;0456 idblgrave;0209 ideographearthcircle;328F ideographfirecircle;328B ideographicallianceparen;323F ideographiccallparen;323A ideographiccentrecircle;32A5 ideographicclose;3006 ideographiccomma;3001 ideographiccommaleft;FF64 ideographiccongratulationparen;3237 ideographiccorrectcircle;32A3 ideographicearthparen;322F ideographicenterpriseparen;323D ideographicexcellentcircle;329D ideographicfestivalparen;3240 ideographicfinancialcircle;3296 ideographicfinancialparen;3236 ideographicfireparen;322B ideographichaveparen;3232 ideographichighcircle;32A4 ideographiciterationmark;3005 ideographiclaborcircle;3298 ideographiclaborparen;3238 ideographicleftcircle;32A7 ideographiclowcircle;32A6 ideographicmedicinecircle;32A9 ideographicmetalparen;322E ideographicmoonparen;322A ideographicnameparen;3234 ideographicperiod;3002 ideographicprintcircle;329E ideographicreachparen;3243 ideographicrepresentparen;3239 ideographicresourceparen;323E ideographicrightcircle;32A8 ideographicsecretcircle;3299 ideographicselfparen;3242 ideographicsocietyparen;3233 ideographicspace;3000 ideographicspecialparen;3235 ideographicstockparen;3231 ideographicstudyparen;323B ideographicsunparen;3230 ideographicsuperviseparen;323C ideographicwaterparen;322C ideographicwoodparen;322D ideographiczero;3007 ideographmetalcircle;328E ideographmooncircle;328A ideographnamecircle;3294 ideographsuncircle;3290 ideographwatercircle;328C ideographwoodcircle;328D ideva;0907 idieresis;00EF idieresisacute;1E2F idieresiscyrillic;04E5 idotbelow;1ECB iebrevecyrillic;04D7 iecyrillic;0435 ieungacirclekorean;3275 ieungaparenkorean;3215 ieungcirclekorean;3267 ieungkorean;3147 ieungparenkorean;3207 igrave;00EC igujarati;0A87 igurmukhi;0A07 ihiragana;3044 ihookabove;1EC9 iibengali;0988 iicyrillic;0438 iideva;0908 iigujarati;0A88 iigurmukhi;0A08 iimatragurmukhi;0A40 iinvertedbreve;020B iishortcyrillic;0439 iivowelsignbengali;09C0 iivowelsigndeva;0940 iivowelsigngujarati;0AC0 ij;0133 ikatakana;30A4 ikatakanahalfwidth;FF72 ikorean;3163 ilde;02DC iluyhebrew;05AC imacron;012B imacroncyrillic;04E3 imageorapproximatelyequal;2253 imatragurmukhi;0A3F imonospace;FF49 increment;2206 infinity;221E iniarmenian;056B integral;222B integralbottom;2321 integralbt;2321 integralex;F8F5 integraltop;2320 integraltp;2320 intersection;2229 intisquare;3305 invbullet;25D8 invcircle;25D9 invsmileface;263B iocyrillic;0451 iogonek;012F iota;03B9 iotadieresis;03CA iotadieresistonos;0390 iotalatin;0269 iotatonos;03AF iparen;24A4 irigurmukhi;0A72 ismallhiragana;3043 ismallkatakana;30A3 ismallkatakanahalfwidth;FF68 issharbengali;09FA istroke;0268 isuperior;F6ED iterationhiragana;309D iterationkatakana;30FD itilde;0129 itildebelow;1E2D iubopomofo;3129 iucyrillic;044E ivowelsignbengali;09BF ivowelsigndeva;093F ivowelsigngujarati;0ABF izhitsacyrillic;0475 izhitsadblgravecyrillic;0477 j;006A jaarmenian;0571 jabengali;099C jadeva;091C jagujarati;0A9C jagurmukhi;0A1C jbopomofo;3110 jcaron;01F0 jcircle;24D9 jcircumflex;0135 jcrossedtail;029D jdotlessstroke;025F jecyrillic;0458 jeemarabic;062C jeemfinalarabic;FE9E jeeminitialarabic;FE9F jeemmedialarabic;FEA0 jeharabic;0698 jehfinalarabic;FB8B jhabengali;099D jhadeva;091D jhagujarati;0A9D jhagurmukhi;0A1D jheharmenian;057B jis;3004 jmonospace;FF4A jparen;24A5 jsuperior;02B2 k;006B kabashkircyrillic;04A1 kabengali;0995 kacute;1E31 kacyrillic;043A kadescendercyrillic;049B kadeva;0915 kaf;05DB kafarabic;0643 kafdagesh;FB3B kafdageshhebrew;FB3B kaffinalarabic;FEDA kafhebrew;05DB kafinitialarabic;FEDB kafmedialarabic;FEDC kafrafehebrew;FB4D kagujarati;0A95 kagurmukhi;0A15 kahiragana;304B kahookcyrillic;04C4 kakatakana;30AB kakatakanahalfwidth;FF76 kappa;03BA kappasymbolgreek;03F0 kapyeounmieumkorean;3171 kapyeounphieuphkorean;3184 kapyeounpieupkorean;3178 kapyeounssangpieupkorean;3179 karoriisquare;330D kashidaautoarabic;0640 kashidaautonosidebearingarabic;0640 kasmallkatakana;30F5 kasquare;3384 kasraarabic;0650 kasratanarabic;064D kastrokecyrillic;049F katahiraprolongmarkhalfwidth;FF70 kaverticalstrokecyrillic;049D kbopomofo;310E kcalsquare;3389 kcaron;01E9 kcedilla;0137 kcircle;24DA kcommaaccent;0137 kdotbelow;1E33 keharmenian;0584 kehiragana;3051 kekatakana;30B1 kekatakanahalfwidth;FF79 kenarmenian;056F kesmallkatakana;30F6 kgreenlandic;0138 khabengali;0996 khacyrillic;0445 khadeva;0916 khagujarati;0A96 khagurmukhi;0A16 khaharabic;062E khahfinalarabic;FEA6 khahinitialarabic;FEA7 khahmedialarabic;FEA8 kheicoptic;03E7 khhadeva;0959 khhagurmukhi;0A59 khieukhacirclekorean;3278 khieukhaparenkorean;3218 khieukhcirclekorean;326A khieukhkorean;314B khieukhparenkorean;320A khokhaithai;0E02 khokhonthai;0E05 khokhuatthai;0E03 khokhwaithai;0E04 khomutthai;0E5B khook;0199 khorakhangthai;0E06 khzsquare;3391 kihiragana;304D kikatakana;30AD kikatakanahalfwidth;FF77 kiroguramusquare;3315 kiromeetorusquare;3316 kirosquare;3314 kiyeokacirclekorean;326E kiyeokaparenkorean;320E kiyeokcirclekorean;3260 kiyeokkorean;3131 kiyeokparenkorean;3200 kiyeoksioskorean;3133 kjecyrillic;045C klinebelow;1E35 klsquare;3398 kmcubedsquare;33A6 kmonospace;FF4B kmsquaredsquare;33A2 kohiragana;3053 kohmsquare;33C0 kokaithai;0E01 kokatakana;30B3 kokatakanahalfwidth;FF7A kooposquare;331E koppacyrillic;0481 koreanstandardsymbol;327F koroniscmb;0343 kparen;24A6 kpasquare;33AA ksicyrillic;046F ktsquare;33CF kturned;029E kuhiragana;304F kukatakana;30AF kukatakanahalfwidth;FF78 kvsquare;33B8 kwsquare;33BE l;006C labengali;09B2 lacute;013A ladeva;0932 lagujarati;0AB2 lagurmukhi;0A32 lakkhangyaothai;0E45 lamaleffinalarabic;FEFC lamalefhamzaabovefinalarabic;FEF8 lamalefhamzaaboveisolatedarabic;FEF7 lamalefhamzabelowfinalarabic;FEFA lamalefhamzabelowisolatedarabic;FEF9 lamalefisolatedarabic;FEFB lamalefmaddaabovefinalarabic;FEF6 lamalefmaddaaboveisolatedarabic;FEF5 lamarabic;0644 lambda;03BB lambdastroke;019B lamed;05DC lameddagesh;FB3C lameddageshhebrew;FB3C lamedhebrew;05DC lamedholam;05DC 05B9 lamedholamdagesh;05DC 05B9 05BC lamedholamdageshhebrew;05DC 05B9 05BC lamedholamhebrew;05DC 05B9 lamfinalarabic;FEDE lamhahinitialarabic;FCCA laminitialarabic;FEDF lamjeeminitialarabic;FCC9 lamkhahinitialarabic;FCCB lamlamhehisolatedarabic;FDF2 lammedialarabic;FEE0 lammeemhahinitialarabic;FD88 lammeeminitialarabic;FCCC lammeemjeeminitialarabic;FEDF FEE4 FEA0 lammeemkhahinitialarabic;FEDF FEE4 FEA8 largecircle;25EF lbar;019A lbelt;026C lbopomofo;310C lcaron;013E lcedilla;013C lcircle;24DB lcircumflexbelow;1E3D lcommaaccent;013C ldot;0140 ldotaccent;0140 ldotbelow;1E37 ldotbelowmacron;1E39 leftangleabovecmb;031A lefttackbelowcmb;0318 less;003C lessequal;2264 lessequalorgreater;22DA lessmonospace;FF1C lessorequivalent;2272 lessorgreater;2276 lessoverequal;2266 lesssmall;FE64 lezh;026E lfblock;258C lhookretroflex;026D lira;20A4 liwnarmenian;056C lj;01C9 ljecyrillic;0459 ll;F6C0 lladeva;0933 llagujarati;0AB3 llinebelow;1E3B llladeva;0934 llvocalicbengali;09E1 llvocalicdeva;0961 llvocalicvowelsignbengali;09E3 llvocalicvowelsigndeva;0963 lmiddletilde;026B lmonospace;FF4C lmsquare;33D0 lochulathai;0E2C logicaland;2227 logicalnot;00AC logicalnotreversed;2310 logicalor;2228 lolingthai;0E25 longs;017F lowlinecenterline;FE4E lowlinecmb;0332 lowlinedashed;FE4D lozenge;25CA lparen;24A7 lslash;0142 lsquare;2113 lsuperior;F6EE ltshade;2591 luthai;0E26 lvocalicbengali;098C lvocalicdeva;090C lvocalicvowelsignbengali;09E2 lvocalicvowelsigndeva;0962 lxsquare;33D3 m;006D mabengali;09AE macron;00AF macronbelowcmb;0331 macroncmb;0304 macronlowmod;02CD macronmonospace;FFE3 macute;1E3F madeva;092E magujarati;0AAE magurmukhi;0A2E mahapakhhebrew;05A4 mahapakhlefthebrew;05A4 mahiragana;307E maichattawalowleftthai;F895 maichattawalowrightthai;F894 maichattawathai;0E4B maichattawaupperleftthai;F893 maieklowleftthai;F88C maieklowrightthai;F88B maiekthai;0E48 maiekupperleftthai;F88A maihanakatleftthai;F884 maihanakatthai;0E31 maitaikhuleftthai;F889 maitaikhuthai;0E47 maitholowleftthai;F88F maitholowrightthai;F88E maithothai;0E49 maithoupperleftthai;F88D maitrilowleftthai;F892 maitrilowrightthai;F891 maitrithai;0E4A maitriupperleftthai;F890 maiyamokthai;0E46 makatakana;30DE makatakanahalfwidth;FF8F male;2642 mansyonsquare;3347 maqafhebrew;05BE mars;2642 masoracirclehebrew;05AF masquare;3383 mbopomofo;3107 mbsquare;33D4 mcircle;24DC mcubedsquare;33A5 mdotaccent;1E41 mdotbelow;1E43 meemarabic;0645 meemfinalarabic;FEE2 meeminitialarabic;FEE3 meemmedialarabic;FEE4 meemmeeminitialarabic;FCD1 meemmeemisolatedarabic;FC48 meetorusquare;334D mehiragana;3081 meizierasquare;337E mekatakana;30E1 mekatakanahalfwidth;FF92 mem;05DE memdagesh;FB3E memdageshhebrew;FB3E memhebrew;05DE menarmenian;0574 merkhahebrew;05A5 merkhakefulahebrew;05A6 merkhakefulalefthebrew;05A6 merkhalefthebrew;05A5 mhook;0271 mhzsquare;3392 middledotkatakanahalfwidth;FF65 middot;00B7 mieumacirclekorean;3272 mieumaparenkorean;3212 mieumcirclekorean;3264 mieumkorean;3141 mieumpansioskorean;3170 mieumparenkorean;3204 mieumpieupkorean;316E mieumsioskorean;316F mihiragana;307F mikatakana;30DF mikatakanahalfwidth;FF90 minus;2212 minusbelowcmb;0320 minuscircle;2296 minusmod;02D7 minusplus;2213 minute;2032 miribaarusquare;334A mirisquare;3349 mlonglegturned;0270 mlsquare;3396 mmcubedsquare;33A3 mmonospace;FF4D mmsquaredsquare;339F mohiragana;3082 mohmsquare;33C1 mokatakana;30E2 mokatakanahalfwidth;FF93 molsquare;33D6 momathai;0E21 moverssquare;33A7 moverssquaredsquare;33A8 mparen;24A8 mpasquare;33AB mssquare;33B3 msuperior;F6EF mturned;026F mu;00B5 mu1;00B5 muasquare;3382 muchgreater;226B muchless;226A mufsquare;338C mugreek;03BC mugsquare;338D muhiragana;3080 mukatakana;30E0 mukatakanahalfwidth;FF91 mulsquare;3395 multiply;00D7 mumsquare;339B munahhebrew;05A3 munahlefthebrew;05A3 musicalnote;266A musicalnotedbl;266B musicflatsign;266D musicsharpsign;266F mussquare;33B2 muvsquare;33B6 muwsquare;33BC mvmegasquare;33B9 mvsquare;33B7 mwmegasquare;33BF mwsquare;33BD n;006E nabengali;09A8 nabla;2207 nacute;0144 nadeva;0928 nagujarati;0AA8 nagurmukhi;0A28 nahiragana;306A nakatakana;30CA nakatakanahalfwidth;FF85 napostrophe;0149 nasquare;3381 nbopomofo;310B nbspace;00A0 ncaron;0148 ncedilla;0146 ncircle;24DD ncircumflexbelow;1E4B ncommaaccent;0146 ndotaccent;1E45 ndotbelow;1E47 nehiragana;306D nekatakana;30CD nekatakanahalfwidth;FF88 newsheqelsign;20AA nfsquare;338B ngabengali;0999 ngadeva;0919 ngagujarati;0A99 ngagurmukhi;0A19 ngonguthai;0E07 nhiragana;3093 nhookleft;0272 nhookretroflex;0273 nieunacirclekorean;326F nieunaparenkorean;320F nieuncieuckorean;3135 nieuncirclekorean;3261 nieunhieuhkorean;3136 nieunkorean;3134 nieunpansioskorean;3168 nieunparenkorean;3201 nieunsioskorean;3167 nieuntikeutkorean;3166 nihiragana;306B nikatakana;30CB nikatakanahalfwidth;FF86 nikhahitleftthai;F899 nikhahitthai;0E4D nine;0039 ninearabic;0669 ninebengali;09EF ninecircle;2468 ninecircleinversesansserif;2792 ninedeva;096F ninegujarati;0AEF ninegurmukhi;0A6F ninehackarabic;0669 ninehangzhou;3029 nineideographicparen;3228 nineinferior;2089 ninemonospace;FF19 nineoldstyle;F739 nineparen;247C nineperiod;2490 ninepersian;06F9 nineroman;2178 ninesuperior;2079 nineteencircle;2472 nineteenparen;2486 nineteenperiod;249A ninethai;0E59 nj;01CC njecyrillic;045A nkatakana;30F3 nkatakanahalfwidth;FF9D nlegrightlong;019E nlinebelow;1E49 nmonospace;FF4E nmsquare;339A nnabengali;09A3 nnadeva;0923 nnagujarati;0AA3 nnagurmukhi;0A23 nnnadeva;0929 nohiragana;306E nokatakana;30CE nokatakanahalfwidth;FF89 nonbreakingspace;00A0 nonenthai;0E13 nonuthai;0E19 noonarabic;0646 noonfinalarabic;FEE6 noonghunnaarabic;06BA noonghunnafinalarabic;FB9F noonhehinitialarabic;FEE7 FEEC nooninitialarabic;FEE7 noonjeeminitialarabic;FCD2 noonjeemisolatedarabic;FC4B noonmedialarabic;FEE8 noonmeeminitialarabic;FCD5 noonmeemisolatedarabic;FC4E noonnoonfinalarabic;FC8D notcontains;220C notelement;2209 notelementof;2209 notequal;2260 notgreater;226F notgreaternorequal;2271 notgreaternorless;2279 notidentical;2262 notless;226E notlessnorequal;2270 notparallel;2226 notprecedes;2280 notsubset;2284 notsucceeds;2281 notsuperset;2285 nowarmenian;0576 nparen;24A9 nssquare;33B1 nsuperior;207F ntilde;00F1 nu;03BD nuhiragana;306C nukatakana;30CC nukatakanahalfwidth;FF87 nuktabengali;09BC nuktadeva;093C nuktagujarati;0ABC nuktagurmukhi;0A3C numbersign;0023 numbersignmonospace;FF03 numbersignsmall;FE5F numeralsigngreek;0374 numeralsignlowergreek;0375 numero;2116 nun;05E0 nundagesh;FB40 nundageshhebrew;FB40 nunhebrew;05E0 nvsquare;33B5 nwsquare;33BB nyabengali;099E nyadeva;091E nyagujarati;0A9E nyagurmukhi;0A1E o;006F oacute;00F3 oangthai;0E2D obarred;0275 obarredcyrillic;04E9 obarreddieresiscyrillic;04EB obengali;0993 obopomofo;311B obreve;014F ocandradeva;0911 ocandragujarati;0A91 ocandravowelsigndeva;0949 ocandravowelsigngujarati;0AC9 ocaron;01D2 ocircle;24DE ocircumflex;00F4 ocircumflexacute;1ED1 ocircumflexdotbelow;1ED9 ocircumflexgrave;1ED3 ocircumflexhookabove;1ED5 ocircumflextilde;1ED7 ocyrillic;043E odblacute;0151 odblgrave;020D odeva;0913 odieresis;00F6 odieresiscyrillic;04E7 odotbelow;1ECD oe;0153 oekorean;315A ogonek;02DB ogonekcmb;0328 ograve;00F2 ogujarati;0A93 oharmenian;0585 ohiragana;304A ohookabove;1ECF ohorn;01A1 ohornacute;1EDB ohorndotbelow;1EE3 ohorngrave;1EDD ohornhookabove;1EDF ohorntilde;1EE1 ohungarumlaut;0151 oi;01A3 oinvertedbreve;020F okatakana;30AA okatakanahalfwidth;FF75 okorean;3157 olehebrew;05AB omacron;014D omacronacute;1E53 omacrongrave;1E51 omdeva;0950 omega;03C9 omega1;03D6 omegacyrillic;0461 omegalatinclosed;0277 omegaroundcyrillic;047B omegatitlocyrillic;047D omegatonos;03CE omgujarati;0AD0 omicron;03BF omicrontonos;03CC omonospace;FF4F one;0031 onearabic;0661 onebengali;09E7 onecircle;2460 onecircleinversesansserif;278A onedeva;0967 onedotenleader;2024 oneeighth;215B onefitted;F6DC onegujarati;0AE7 onegurmukhi;0A67 onehackarabic;0661 onehalf;00BD onehangzhou;3021 oneideographicparen;3220 oneinferior;2081 onemonospace;FF11 onenumeratorbengali;09F4 oneoldstyle;F731 oneparen;2474 oneperiod;2488 onepersian;06F1 onequarter;00BC oneroman;2170 onesuperior;00B9 onethai;0E51 onethird;2153 oogonek;01EB oogonekmacron;01ED oogurmukhi;0A13 oomatragurmukhi;0A4B oopen;0254 oparen;24AA openbullet;25E6 option;2325 ordfeminine;00AA ordmasculine;00BA orthogonal;221F oshortdeva;0912 oshortvowelsigndeva;094A oslash;00F8 oslashacute;01FF osmallhiragana;3049 osmallkatakana;30A9 osmallkatakanahalfwidth;FF6B ostrokeacute;01FF osuperior;F6F0 otcyrillic;047F otilde;00F5 otildeacute;1E4D otildedieresis;1E4F oubopomofo;3121 overline;203E overlinecenterline;FE4A overlinecmb;0305 overlinedashed;FE49 overlinedblwavy;FE4C overlinewavy;FE4B overscore;00AF ovowelsignbengali;09CB ovowelsigndeva;094B ovowelsigngujarati;0ACB p;0070 paampssquare;3380 paasentosquare;332B pabengali;09AA pacute;1E55 padeva;092A pagedown;21DF pageup;21DE pagujarati;0AAA pagurmukhi;0A2A pahiragana;3071 paiyannoithai;0E2F pakatakana;30D1 palatalizationcyrilliccmb;0484 palochkacyrillic;04C0 pansioskorean;317F paragraph;00B6 parallel;2225 parenleft;0028 parenleftaltonearabic;FD3E parenleftbt;F8ED parenleftex;F8EC parenleftinferior;208D parenleftmonospace;FF08 parenleftsmall;FE59 parenleftsuperior;207D parenlefttp;F8EB parenleftvertical;FE35 parenright;0029 parenrightaltonearabic;FD3F parenrightbt;F8F8 parenrightex;F8F7 parenrightinferior;208E parenrightmonospace;FF09 parenrightsmall;FE5A parenrightsuperior;207E parenrighttp;F8F6 parenrightvertical;FE36 partialdiff;2202 paseqhebrew;05C0 pashtahebrew;0599 pasquare;33A9 patah;05B7 patah11;05B7 patah1d;05B7 patah2a;05B7 patahhebrew;05B7 patahnarrowhebrew;05B7 patahquarterhebrew;05B7 patahwidehebrew;05B7 pazerhebrew;05A1 pbopomofo;3106 pcircle;24DF pdotaccent;1E57 pe;05E4 pecyrillic;043F pedagesh;FB44 pedageshhebrew;FB44 peezisquare;333B pefinaldageshhebrew;FB43 peharabic;067E peharmenian;057A pehebrew;05E4 pehfinalarabic;FB57 pehinitialarabic;FB58 pehiragana;307A pehmedialarabic;FB59 pekatakana;30DA pemiddlehookcyrillic;04A7 perafehebrew;FB4E percent;0025 percentarabic;066A percentmonospace;FF05 percentsmall;FE6A period;002E periodarmenian;0589 periodcentered;00B7 periodhalfwidth;FF61 periodinferior;F6E7 periodmonospace;FF0E periodsmall;FE52 periodsuperior;F6E8 perispomenigreekcmb;0342 perpendicular;22A5 perthousand;2030 peseta;20A7 pfsquare;338A phabengali;09AB phadeva;092B phagujarati;0AAB phagurmukhi;0A2B phi;03C6 phi1;03D5 phieuphacirclekorean;327A phieuphaparenkorean;321A phieuphcirclekorean;326C phieuphkorean;314D phieuphparenkorean;320C philatin;0278 phinthuthai;0E3A phisymbolgreek;03D5 phook;01A5 phophanthai;0E1E phophungthai;0E1C phosamphaothai;0E20 pi;03C0 pieupacirclekorean;3273 pieupaparenkorean;3213 pieupcieuckorean;3176 pieupcirclekorean;3265 pieupkiyeokkorean;3172 pieupkorean;3142 pieupparenkorean;3205 pieupsioskiyeokkorean;3174 pieupsioskorean;3144 pieupsiostikeutkorean;3175 pieupthieuthkorean;3177 pieuptikeutkorean;3173 pihiragana;3074 pikatakana;30D4 pisymbolgreek;03D6 piwrarmenian;0583 plus;002B plusbelowcmb;031F pluscircle;2295 plusminus;00B1 plusmod;02D6 plusmonospace;FF0B plussmall;FE62 plussuperior;207A pmonospace;FF50 pmsquare;33D8 pohiragana;307D pointingindexdownwhite;261F pointingindexleftwhite;261C pointingindexrightwhite;261E pointingindexupwhite;261D pokatakana;30DD poplathai;0E1B postalmark;3012 postalmarkface;3020 pparen;24AB precedes;227A prescription;211E primemod;02B9 primereversed;2035 product;220F projective;2305 prolongedkana;30FC propellor;2318 propersubset;2282 propersuperset;2283 proportion;2237 proportional;221D psi;03C8 psicyrillic;0471 psilipneumatacyrilliccmb;0486 pssquare;33B0 puhiragana;3077 pukatakana;30D7 pvsquare;33B4 pwsquare;33BA q;0071 qadeva;0958 qadmahebrew;05A8 qafarabic;0642 qaffinalarabic;FED6 qafinitialarabic;FED7 qafmedialarabic;FED8 qamats;05B8 qamats10;05B8 qamats1a;05B8 qamats1c;05B8 qamats27;05B8 qamats29;05B8 qamats33;05B8 qamatsde;05B8 qamatshebrew;05B8 qamatsnarrowhebrew;05B8 qamatsqatanhebrew;05B8 qamatsqatannarrowhebrew;05B8 qamatsqatanquarterhebrew;05B8 qamatsqatanwidehebrew;05B8 qamatsquarterhebrew;05B8 qamatswidehebrew;05B8 qarneyparahebrew;059F qbopomofo;3111 qcircle;24E0 qhook;02A0 qmonospace;FF51 qof;05E7 qofdagesh;FB47 qofdageshhebrew;FB47 qofhatafpatah;05E7 05B2 qofhatafpatahhebrew;05E7 05B2 qofhatafsegol;05E7 05B1 qofhatafsegolhebrew;05E7 05B1 qofhebrew;05E7 qofhiriq;05E7 05B4 qofhiriqhebrew;05E7 05B4 qofholam;05E7 05B9 qofholamhebrew;05E7 05B9 qofpatah;05E7 05B7 qofpatahhebrew;05E7 05B7 qofqamats;05E7 05B8 qofqamatshebrew;05E7 05B8 qofqubuts;05E7 05BB qofqubutshebrew;05E7 05BB qofsegol;05E7 05B6 qofsegolhebrew;05E7 05B6 qofsheva;05E7 05B0 qofshevahebrew;05E7 05B0 qoftsere;05E7 05B5 qoftserehebrew;05E7 05B5 qparen;24AC quarternote;2669 qubuts;05BB qubuts18;05BB qubuts25;05BB qubuts31;05BB qubutshebrew;05BB qubutsnarrowhebrew;05BB qubutsquarterhebrew;05BB qubutswidehebrew;05BB question;003F questionarabic;061F questionarmenian;055E questiondown;00BF questiondownsmall;F7BF questiongreek;037E questionmonospace;FF1F questionsmall;F73F quotedbl;0022 quotedblbase;201E quotedblleft;201C quotedblmonospace;FF02 quotedblprime;301E quotedblprimereversed;301D quotedblright;201D quoteleft;2018 quoteleftreversed;201B quotereversed;201B quoteright;2019 quoterightn;0149 quotesinglbase;201A quotesingle;0027 quotesinglemonospace;FF07 r;0072 raarmenian;057C rabengali;09B0 racute;0155 radeva;0930 radical;221A radicalex;F8E5 radoverssquare;33AE radoverssquaredsquare;33AF radsquare;33AD rafe;05BF rafehebrew;05BF ragujarati;0AB0 ragurmukhi;0A30 rahiragana;3089 rakatakana;30E9 rakatakanahalfwidth;FF97 ralowerdiagonalbengali;09F1 ramiddlediagonalbengali;09F0 ramshorn;0264 ratio;2236 rbopomofo;3116 rcaron;0159 rcedilla;0157 rcircle;24E1 rcommaaccent;0157 rdblgrave;0211 rdotaccent;1E59 rdotbelow;1E5B rdotbelowmacron;1E5D referencemark;203B reflexsubset;2286 reflexsuperset;2287 registered;00AE registersans;F8E8 registerserif;F6DA reharabic;0631 reharmenian;0580 rehfinalarabic;FEAE rehiragana;308C rehyehaleflamarabic;0631 FEF3 FE8E 0644 rekatakana;30EC rekatakanahalfwidth;FF9A resh;05E8 reshdageshhebrew;FB48 reshhatafpatah;05E8 05B2 reshhatafpatahhebrew;05E8 05B2 reshhatafsegol;05E8 05B1 reshhatafsegolhebrew;05E8 05B1 reshhebrew;05E8 reshhiriq;05E8 05B4 reshhiriqhebrew;05E8 05B4 reshholam;05E8 05B9 reshholamhebrew;05E8 05B9 reshpatah;05E8 05B7 reshpatahhebrew;05E8 05B7 reshqamats;05E8 05B8 reshqamatshebrew;05E8 05B8 reshqubuts;05E8 05BB reshqubutshebrew;05E8 05BB reshsegol;05E8 05B6 reshsegolhebrew;05E8 05B6 reshsheva;05E8 05B0 reshshevahebrew;05E8 05B0 reshtsere;05E8 05B5 reshtserehebrew;05E8 05B5 reversedtilde;223D reviahebrew;0597 reviamugrashhebrew;0597 revlogicalnot;2310 rfishhook;027E rfishhookreversed;027F rhabengali;09DD rhadeva;095D rho;03C1 rhook;027D rhookturned;027B rhookturnedsuperior;02B5 rhosymbolgreek;03F1 rhotichookmod;02DE rieulacirclekorean;3271 rieulaparenkorean;3211 rieulcirclekorean;3263 rieulhieuhkorean;3140 rieulkiyeokkorean;313A rieulkiyeoksioskorean;3169 rieulkorean;3139 rieulmieumkorean;313B rieulpansioskorean;316C rieulparenkorean;3203 rieulphieuphkorean;313F rieulpieupkorean;313C rieulpieupsioskorean;316B rieulsioskorean;313D rieulthieuthkorean;313E rieultikeutkorean;316A rieulyeorinhieuhkorean;316D rightangle;221F righttackbelowcmb;0319 righttriangle;22BF rihiragana;308A rikatakana;30EA rikatakanahalfwidth;FF98 ring;02DA ringbelowcmb;0325 ringcmb;030A ringhalfleft;02BF ringhalfleftarmenian;0559 ringhalfleftbelowcmb;031C ringhalfleftcentered;02D3 ringhalfright;02BE ringhalfrightbelowcmb;0339 ringhalfrightcentered;02D2 rinvertedbreve;0213 rittorusquare;3351 rlinebelow;1E5F rlongleg;027C rlonglegturned;027A rmonospace;FF52 rohiragana;308D rokatakana;30ED rokatakanahalfwidth;FF9B roruathai;0E23 rparen;24AD rrabengali;09DC rradeva;0931 rragurmukhi;0A5C rreharabic;0691 rrehfinalarabic;FB8D rrvocalicbengali;09E0 rrvocalicdeva;0960 rrvocalicgujarati;0AE0 rrvocalicvowelsignbengali;09C4 rrvocalicvowelsigndeva;0944 rrvocalicvowelsigngujarati;0AC4 rsuperior;F6F1 rtblock;2590 rturned;0279 rturnedsuperior;02B4 ruhiragana;308B rukatakana;30EB rukatakanahalfwidth;FF99 rupeemarkbengali;09F2 rupeesignbengali;09F3 rupiah;F6DD ruthai;0E24 rvocalicbengali;098B rvocalicdeva;090B rvocalicgujarati;0A8B rvocalicvowelsignbengali;09C3 rvocalicvowelsigndeva;0943 rvocalicvowelsigngujarati;0AC3 s;0073 sabengali;09B8 sacute;015B sacutedotaccent;1E65 sadarabic;0635 sadeva;0938 sadfinalarabic;FEBA sadinitialarabic;FEBB sadmedialarabic;FEBC sagujarati;0AB8 sagurmukhi;0A38 sahiragana;3055 sakatakana;30B5 sakatakanahalfwidth;FF7B sallallahoualayhewasallamarabic;FDFA samekh;05E1 samekhdagesh;FB41 samekhdageshhebrew;FB41 samekhhebrew;05E1 saraaathai;0E32 saraaethai;0E41 saraaimaimalaithai;0E44 saraaimaimuanthai;0E43 saraamthai;0E33 saraathai;0E30 saraethai;0E40 saraiileftthai;F886 saraiithai;0E35 saraileftthai;F885 saraithai;0E34 saraothai;0E42 saraueeleftthai;F888 saraueethai;0E37 saraueleftthai;F887 sarauethai;0E36 sarauthai;0E38 sarauuthai;0E39 sbopomofo;3119 scaron;0161 scarondotaccent;1E67 scedilla;015F schwa;0259 schwacyrillic;04D9 schwadieresiscyrillic;04DB schwahook;025A scircle;24E2 scircumflex;015D scommaaccent;0219 sdotaccent;1E61 sdotbelow;1E63 sdotbelowdotaccent;1E69 seagullbelowcmb;033C second;2033 secondtonechinese;02CA section;00A7 seenarabic;0633 seenfinalarabic;FEB2 seeninitialarabic;FEB3 seenmedialarabic;FEB4 segol;05B6 segol13;05B6 segol1f;05B6 segol2c;05B6 segolhebrew;05B6 segolnarrowhebrew;05B6 segolquarterhebrew;05B6 segoltahebrew;0592 segolwidehebrew;05B6 seharmenian;057D sehiragana;305B sekatakana;30BB sekatakanahalfwidth;FF7E semicolon;003B semicolonarabic;061B semicolonmonospace;FF1B semicolonsmall;FE54 semivoicedmarkkana;309C semivoicedmarkkanahalfwidth;FF9F sentisquare;3322 sentosquare;3323 seven;0037 sevenarabic;0667 sevenbengali;09ED sevencircle;2466 sevencircleinversesansserif;2790 sevendeva;096D seveneighths;215E sevengujarati;0AED sevengurmukhi;0A6D sevenhackarabic;0667 sevenhangzhou;3027 sevenideographicparen;3226 seveninferior;2087 sevenmonospace;FF17 sevenoldstyle;F737 sevenparen;247A sevenperiod;248E sevenpersian;06F7 sevenroman;2176 sevensuperior;2077 seventeencircle;2470 seventeenparen;2484 seventeenperiod;2498 seventhai;0E57 sfthyphen;00AD shaarmenian;0577 shabengali;09B6 shacyrillic;0448 shaddaarabic;0651 shaddadammaarabic;FC61 shaddadammatanarabic;FC5E shaddafathaarabic;FC60 shaddafathatanarabic;0651 064B shaddakasraarabic;FC62 shaddakasratanarabic;FC5F shade;2592 shadedark;2593 shadelight;2591 shademedium;2592 shadeva;0936 shagujarati;0AB6 shagurmukhi;0A36 shalshelethebrew;0593 shbopomofo;3115 shchacyrillic;0449 sheenarabic;0634 sheenfinalarabic;FEB6 sheeninitialarabic;FEB7 sheenmedialarabic;FEB8 sheicoptic;03E3 sheqel;20AA sheqelhebrew;20AA sheva;05B0 sheva115;05B0 sheva15;05B0 sheva22;05B0 sheva2e;05B0 shevahebrew;05B0 shevanarrowhebrew;05B0 shevaquarterhebrew;05B0 shevawidehebrew;05B0 shhacyrillic;04BB shimacoptic;03ED shin;05E9 shindagesh;FB49 shindageshhebrew;FB49 shindageshshindot;FB2C shindageshshindothebrew;FB2C shindageshsindot;FB2D shindageshsindothebrew;FB2D shindothebrew;05C1 shinhebrew;05E9 shinshindot;FB2A shinshindothebrew;FB2A shinsindot;FB2B shinsindothebrew;FB2B shook;0282 sigma;03C3 sigma1;03C2 sigmafinal;03C2 sigmalunatesymbolgreek;03F2 sihiragana;3057 sikatakana;30B7 sikatakanahalfwidth;FF7C siluqhebrew;05BD siluqlefthebrew;05BD similar;223C sindothebrew;05C2 siosacirclekorean;3274 siosaparenkorean;3214 sioscieuckorean;317E sioscirclekorean;3266 sioskiyeokkorean;317A sioskorean;3145 siosnieunkorean;317B siosparenkorean;3206 siospieupkorean;317D siostikeutkorean;317C six;0036 sixarabic;0666 sixbengali;09EC sixcircle;2465 sixcircleinversesansserif;278F sixdeva;096C sixgujarati;0AEC sixgurmukhi;0A6C sixhackarabic;0666 sixhangzhou;3026 sixideographicparen;3225 sixinferior;2086 sixmonospace;FF16 sixoldstyle;F736 sixparen;2479 sixperiod;248D sixpersian;06F6 sixroman;2175 sixsuperior;2076 sixteencircle;246F sixteencurrencydenominatorbengali;09F9 sixteenparen;2483 sixteenperiod;2497 sixthai;0E56 slash;002F slashmonospace;FF0F slong;017F slongdotaccent;1E9B smileface;263A smonospace;FF53 sofpasuqhebrew;05C3 softhyphen;00AD softsigncyrillic;044C sohiragana;305D sokatakana;30BD sokatakanahalfwidth;FF7F soliduslongoverlaycmb;0338 solidusshortoverlaycmb;0337 sorusithai;0E29 sosalathai;0E28 sosothai;0E0B sosuathai;0E2A space;0020 spacehackarabic;0020 spade;2660 spadesuitblack;2660 spadesuitwhite;2664 sparen;24AE squarebelowcmb;033B squarecc;33C4 squarecm;339D squarediagonalcrosshatchfill;25A9 squarehorizontalfill;25A4 squarekg;338F squarekm;339E squarekmcapital;33CE squareln;33D1 squarelog;33D2 squaremg;338E squaremil;33D5 squaremm;339C squaremsquared;33A1 squareorthogonalcrosshatchfill;25A6 squareupperlefttolowerrightfill;25A7 squareupperrighttolowerleftfill;25A8 squareverticalfill;25A5 squarewhitewithsmallblack;25A3 srsquare;33DB ssabengali;09B7 ssadeva;0937 ssagujarati;0AB7 ssangcieuckorean;3149 ssanghieuhkorean;3185 ssangieungkorean;3180 ssangkiyeokkorean;3132 ssangnieunkorean;3165 ssangpieupkorean;3143 ssangsioskorean;3146 ssangtikeutkorean;3138 ssuperior;F6F2 sterling;00A3 sterlingmonospace;FFE1 strokelongoverlaycmb;0336 strokeshortoverlaycmb;0335 subset;2282 subsetnotequal;228A subsetorequal;2286 succeeds;227B suchthat;220B suhiragana;3059 sukatakana;30B9 sukatakanahalfwidth;FF7D sukunarabic;0652 summation;2211 sun;263C superset;2283 supersetnotequal;228B supersetorequal;2287 svsquare;33DC syouwaerasquare;337C t;0074 tabengali;09A4 tackdown;22A4 tackleft;22A3 tadeva;0924 tagujarati;0AA4 tagurmukhi;0A24 taharabic;0637 tahfinalarabic;FEC2 tahinitialarabic;FEC3 tahiragana;305F tahmedialarabic;FEC4 taisyouerasquare;337D takatakana;30BF takatakanahalfwidth;FF80 tatweelarabic;0640 tau;03C4 tav;05EA tavdages;FB4A tavdagesh;FB4A tavdageshhebrew;FB4A tavhebrew;05EA tbar;0167 tbopomofo;310A tcaron;0165 tccurl;02A8 tcedilla;0163 tcheharabic;0686 tchehfinalarabic;FB7B tchehinitialarabic;FB7C tchehmedialarabic;FB7D tchehmeeminitialarabic;FB7C FEE4 tcircle;24E3 tcircumflexbelow;1E71 tcommaaccent;0163 tdieresis;1E97 tdotaccent;1E6B tdotbelow;1E6D tecyrillic;0442 tedescendercyrillic;04AD teharabic;062A tehfinalarabic;FE96 tehhahinitialarabic;FCA2 tehhahisolatedarabic;FC0C tehinitialarabic;FE97 tehiragana;3066 tehjeeminitialarabic;FCA1 tehjeemisolatedarabic;FC0B tehmarbutaarabic;0629 tehmarbutafinalarabic;FE94 tehmedialarabic;FE98 tehmeeminitialarabic;FCA4 tehmeemisolatedarabic;FC0E tehnoonfinalarabic;FC73 tekatakana;30C6 tekatakanahalfwidth;FF83 telephone;2121 telephoneblack;260E telishagedolahebrew;05A0 telishaqetanahebrew;05A9 tencircle;2469 tenideographicparen;3229 tenparen;247D tenperiod;2491 tenroman;2179 tesh;02A7 tet;05D8 tetdagesh;FB38 tetdageshhebrew;FB38 tethebrew;05D8 tetsecyrillic;04B5 tevirhebrew;059B tevirlefthebrew;059B thabengali;09A5 thadeva;0925 thagujarati;0AA5 thagurmukhi;0A25 thalarabic;0630 thalfinalarabic;FEAC thanthakhatlowleftthai;F898 thanthakhatlowrightthai;F897 thanthakhatthai;0E4C thanthakhatupperleftthai;F896 theharabic;062B thehfinalarabic;FE9A thehinitialarabic;FE9B thehmedialarabic;FE9C thereexists;2203 therefore;2234 theta;03B8 theta1;03D1 thetasymbolgreek;03D1 thieuthacirclekorean;3279 thieuthaparenkorean;3219 thieuthcirclekorean;326B thieuthkorean;314C thieuthparenkorean;320B thirteencircle;246C thirteenparen;2480 thirteenperiod;2494 thonangmonthothai;0E11 thook;01AD thophuthaothai;0E12 thorn;00FE thothahanthai;0E17 thothanthai;0E10 thothongthai;0E18 thothungthai;0E16 thousandcyrillic;0482 thousandsseparatorarabic;066C thousandsseparatorpersian;066C three;0033 threearabic;0663 threebengali;09E9 threecircle;2462 threecircleinversesansserif;278C threedeva;0969 threeeighths;215C threegujarati;0AE9 threegurmukhi;0A69 threehackarabic;0663 threehangzhou;3023 threeideographicparen;3222 threeinferior;2083 threemonospace;FF13 threenumeratorbengali;09F6 threeoldstyle;F733 threeparen;2476 threeperiod;248A threepersian;06F3 threequarters;00BE threequartersemdash;F6DE threeroman;2172 threesuperior;00B3 threethai;0E53 thzsquare;3394 tihiragana;3061 tikatakana;30C1 tikatakanahalfwidth;FF81 tikeutacirclekorean;3270 tikeutaparenkorean;3210 tikeutcirclekorean;3262 tikeutkorean;3137 tikeutparenkorean;3202 tilde;02DC tildebelowcmb;0330 tildecmb;0303 tildecomb;0303 tildedoublecmb;0360 tildeoperator;223C tildeoverlaycmb;0334 tildeverticalcmb;033E timescircle;2297 tipehahebrew;0596 tipehalefthebrew;0596 tippigurmukhi;0A70 titlocyrilliccmb;0483 tiwnarmenian;057F tlinebelow;1E6F tmonospace;FF54 toarmenian;0569 tohiragana;3068 tokatakana;30C8 tokatakanahalfwidth;FF84 tonebarextrahighmod;02E5 tonebarextralowmod;02E9 tonebarhighmod;02E6 tonebarlowmod;02E8 tonebarmidmod;02E7 tonefive;01BD tonesix;0185 tonetwo;01A8 tonos;0384 tonsquare;3327 topatakthai;0E0F tortoiseshellbracketleft;3014 tortoiseshellbracketleftsmall;FE5D tortoiseshellbracketleftvertical;FE39 tortoiseshellbracketright;3015 tortoiseshellbracketrightsmall;FE5E tortoiseshellbracketrightvertical;FE3A totaothai;0E15 tpalatalhook;01AB tparen;24AF trademark;2122 trademarksans;F8EA trademarkserif;F6DB tretroflexhook;0288 triagdn;25BC triaglf;25C4 triagrt;25BA triagup;25B2 ts;02A6 tsadi;05E6 tsadidagesh;FB46 tsadidageshhebrew;FB46 tsadihebrew;05E6 tsecyrillic;0446 tsere;05B5 tsere12;05B5 tsere1e;05B5 tsere2b;05B5 tserehebrew;05B5 tserenarrowhebrew;05B5 tserequarterhebrew;05B5 tserewidehebrew;05B5 tshecyrillic;045B tsuperior;F6F3 ttabengali;099F ttadeva;091F ttagujarati;0A9F ttagurmukhi;0A1F tteharabic;0679 ttehfinalarabic;FB67 ttehinitialarabic;FB68 ttehmedialarabic;FB69 tthabengali;09A0 tthadeva;0920 tthagujarati;0AA0 tthagurmukhi;0A20 tturned;0287 tuhiragana;3064 tukatakana;30C4 tukatakanahalfwidth;FF82 tusmallhiragana;3063 tusmallkatakana;30C3 tusmallkatakanahalfwidth;FF6F twelvecircle;246B twelveparen;247F twelveperiod;2493 twelveroman;217B twentycircle;2473 twentyhangzhou;5344 twentyparen;2487 twentyperiod;249B two;0032 twoarabic;0662 twobengali;09E8 twocircle;2461 twocircleinversesansserif;278B twodeva;0968 twodotenleader;2025 twodotleader;2025 twodotleadervertical;FE30 twogujarati;0AE8 twogurmukhi;0A68 twohackarabic;0662 twohangzhou;3022 twoideographicparen;3221 twoinferior;2082 twomonospace;FF12 twonumeratorbengali;09F5 twooldstyle;F732 twoparen;2475 twoperiod;2489 twopersian;06F2 tworoman;2171 twostroke;01BB twosuperior;00B2 twothai;0E52 twothirds;2154 u;0075 uacute;00FA ubar;0289 ubengali;0989 ubopomofo;3128 ubreve;016D ucaron;01D4 ucircle;24E4 ucircumflex;00FB ucircumflexbelow;1E77 ucyrillic;0443 udattadeva;0951 udblacute;0171 udblgrave;0215 udeva;0909 udieresis;00FC udieresisacute;01D8 udieresisbelow;1E73 udieresiscaron;01DA udieresiscyrillic;04F1 udieresisgrave;01DC udieresismacron;01D6 udotbelow;1EE5 ugrave;00F9 ugujarati;0A89 ugurmukhi;0A09 uhiragana;3046 uhookabove;1EE7 uhorn;01B0 uhornacute;1EE9 uhorndotbelow;1EF1 uhorngrave;1EEB uhornhookabove;1EED uhorntilde;1EEF uhungarumlaut;0171 uhungarumlautcyrillic;04F3 uinvertedbreve;0217 ukatakana;30A6 ukatakanahalfwidth;FF73 ukcyrillic;0479 ukorean;315C umacron;016B umacroncyrillic;04EF umacrondieresis;1E7B umatragurmukhi;0A41 umonospace;FF55 underscore;005F underscoredbl;2017 underscoremonospace;FF3F underscorevertical;FE33 underscorewavy;FE4F union;222A universal;2200 uogonek;0173 uparen;24B0 upblock;2580 upperdothebrew;05C4 upsilon;03C5 upsilondieresis;03CB upsilondieresistonos;03B0 upsilonlatin;028A upsilontonos;03CD uptackbelowcmb;031D uptackmod;02D4 uragurmukhi;0A73 uring;016F ushortcyrillic;045E usmallhiragana;3045 usmallkatakana;30A5 usmallkatakanahalfwidth;FF69 ustraightcyrillic;04AF ustraightstrokecyrillic;04B1 utilde;0169 utildeacute;1E79 utildebelow;1E75 uubengali;098A uudeva;090A uugujarati;0A8A uugurmukhi;0A0A uumatragurmukhi;0A42 uuvowelsignbengali;09C2 uuvowelsigndeva;0942 uuvowelsigngujarati;0AC2 uvowelsignbengali;09C1 uvowelsigndeva;0941 uvowelsigngujarati;0AC1 v;0076 vadeva;0935 vagujarati;0AB5 vagurmukhi;0A35 vakatakana;30F7 vav;05D5 vavdagesh;FB35 vavdagesh65;FB35 vavdageshhebrew;FB35 vavhebrew;05D5 vavholam;FB4B vavholamhebrew;FB4B vavvavhebrew;05F0 vavyodhebrew;05F1 vcircle;24E5 vdotbelow;1E7F vecyrillic;0432 veharabic;06A4 vehfinalarabic;FB6B vehinitialarabic;FB6C vehmedialarabic;FB6D vekatakana;30F9 venus;2640 verticalbar;007C verticallineabovecmb;030D verticallinebelowcmb;0329 verticallinelowmod;02CC verticallinemod;02C8 vewarmenian;057E vhook;028B vikatakana;30F8 viramabengali;09CD viramadeva;094D viramagujarati;0ACD visargabengali;0983 visargadeva;0903 visargagujarati;0A83 vmonospace;FF56 voarmenian;0578 voicediterationhiragana;309E voicediterationkatakana;30FE voicedmarkkana;309B voicedmarkkanahalfwidth;FF9E vokatakana;30FA vparen;24B1 vtilde;1E7D vturned;028C vuhiragana;3094 vukatakana;30F4 w;0077 wacute;1E83 waekorean;3159 wahiragana;308F wakatakana;30EF wakatakanahalfwidth;FF9C wakorean;3158 wasmallhiragana;308E wasmallkatakana;30EE wattosquare;3357 wavedash;301C wavyunderscorevertical;FE34 wawarabic;0648 wawfinalarabic;FEEE wawhamzaabovearabic;0624 wawhamzaabovefinalarabic;FE86 wbsquare;33DD wcircle;24E6 wcircumflex;0175 wdieresis;1E85 wdotaccent;1E87 wdotbelow;1E89 wehiragana;3091 weierstrass;2118 wekatakana;30F1 wekorean;315E weokorean;315D wgrave;1E81 whitebullet;25E6 whitecircle;25CB whitecircleinverse;25D9 whitecornerbracketleft;300E whitecornerbracketleftvertical;FE43 whitecornerbracketright;300F whitecornerbracketrightvertical;FE44 whitediamond;25C7 whitediamondcontainingblacksmalldiamond;25C8 whitedownpointingsmalltriangle;25BF whitedownpointingtriangle;25BD whiteleftpointingsmalltriangle;25C3 whiteleftpointingtriangle;25C1 whitelenticularbracketleft;3016 whitelenticularbracketright;3017 whiterightpointingsmalltriangle;25B9 whiterightpointingtriangle;25B7 whitesmallsquare;25AB whitesmilingface;263A whitesquare;25A1 whitestar;2606 whitetelephone;260F whitetortoiseshellbracketleft;3018 whitetortoiseshellbracketright;3019 whiteuppointingsmalltriangle;25B5 whiteuppointingtriangle;25B3 wihiragana;3090 wikatakana;30F0 wikorean;315F wmonospace;FF57 wohiragana;3092 wokatakana;30F2 wokatakanahalfwidth;FF66 won;20A9 wonmonospace;FFE6 wowaenthai;0E27 wparen;24B2 wring;1E98 wsuperior;02B7 wturned;028D wynn;01BF x;0078 xabovecmb;033D xbopomofo;3112 xcircle;24E7 xdieresis;1E8D xdotaccent;1E8B xeharmenian;056D xi;03BE xmonospace;FF58 xparen;24B3 xsuperior;02E3 y;0079 yaadosquare;334E yabengali;09AF yacute;00FD yadeva;092F yaekorean;3152 yagujarati;0AAF yagurmukhi;0A2F yahiragana;3084 yakatakana;30E4 yakatakanahalfwidth;FF94 yakorean;3151 yamakkanthai;0E4E yasmallhiragana;3083 yasmallkatakana;30E3 yasmallkatakanahalfwidth;FF6C yatcyrillic;0463 ycircle;24E8 ycircumflex;0177 ydieresis;00FF ydotaccent;1E8F ydotbelow;1EF5 yeharabic;064A yehbarreearabic;06D2 yehbarreefinalarabic;FBAF yehfinalarabic;FEF2 yehhamzaabovearabic;0626 yehhamzaabovefinalarabic;FE8A yehhamzaaboveinitialarabic;FE8B yehhamzaabovemedialarabic;FE8C yehinitialarabic;FEF3 yehmedialarabic;FEF4 yehmeeminitialarabic;FCDD yehmeemisolatedarabic;FC58 yehnoonfinalarabic;FC94 yehthreedotsbelowarabic;06D1 yekorean;3156 yen;00A5 yenmonospace;FFE5 yeokorean;3155 yeorinhieuhkorean;3186 yerahbenyomohebrew;05AA yerahbenyomolefthebrew;05AA yericyrillic;044B yerudieresiscyrillic;04F9 yesieungkorean;3181 yesieungpansioskorean;3183 yesieungsioskorean;3182 yetivhebrew;059A ygrave;1EF3 yhook;01B4 yhookabove;1EF7 yiarmenian;0575 yicyrillic;0457 yikorean;3162 yinyang;262F yiwnarmenian;0582 ymonospace;FF59 yod;05D9 yoddagesh;FB39 yoddageshhebrew;FB39 yodhebrew;05D9 yodyodhebrew;05F2 yodyodpatahhebrew;FB1F yohiragana;3088 yoikorean;3189 yokatakana;30E8 yokatakanahalfwidth;FF96 yokorean;315B yosmallhiragana;3087 yosmallkatakana;30E7 yosmallkatakanahalfwidth;FF6E yotgreek;03F3 yoyaekorean;3188 yoyakorean;3187 yoyakthai;0E22 yoyingthai;0E0D yparen;24B4 ypogegrammeni;037A ypogegrammenigreekcmb;0345 yr;01A6 yring;1E99 ysuperior;02B8 ytilde;1EF9 yturned;028E yuhiragana;3086 yuikorean;318C yukatakana;30E6 yukatakanahalfwidth;FF95 yukorean;3160 yusbigcyrillic;046B yusbigiotifiedcyrillic;046D yuslittlecyrillic;0467 yuslittleiotifiedcyrillic;0469 yusmallhiragana;3085 yusmallkatakana;30E5 yusmallkatakanahalfwidth;FF6D yuyekorean;318B yuyeokorean;318A yyabengali;09DF yyadeva;095F z;007A zaarmenian;0566 zacute;017A zadeva;095B zagurmukhi;0A5B zaharabic;0638 zahfinalarabic;FEC6 zahinitialarabic;FEC7 zahiragana;3056 zahmedialarabic;FEC8 zainarabic;0632 zainfinalarabic;FEB0 zakatakana;30B6 zaqefgadolhebrew;0595 zaqefqatanhebrew;0594 zarqahebrew;0598 zayin;05D6 zayindagesh;FB36 zayindageshhebrew;FB36 zayinhebrew;05D6 zbopomofo;3117 zcaron;017E zcircle;24E9 zcircumflex;1E91 zcurl;0291 zdot;017C zdotaccent;017C zdotbelow;1E93 zecyrillic;0437 zedescendercyrillic;0499 zedieresiscyrillic;04DF zehiragana;305C zekatakana;30BC zero;0030 zeroarabic;0660 zerobengali;09E6 zerodeva;0966 zerogujarati;0AE6 zerogurmukhi;0A66 zerohackarabic;0660 zeroinferior;2080 zeromonospace;FF10 zerooldstyle;F730 zeropersian;06F0 zerosuperior;2070 zerothai;0E50 zerowidthjoiner;FEFF zerowidthnonjoiner;200C zerowidthspace;200B zeta;03B6 zhbopomofo;3113 zhearmenian;056A zhebrevecyrillic;04C2 zhecyrillic;0436 zhedescendercyrillic;0497 zhedieresiscyrillic;04DD zihiragana;3058 zikatakana;30B8 zinorhebrew;05AE zlinebelow;1E95 zmonospace;FF5A zohiragana;305E zokatakana;30BE zparen;24B5 zretroflexhook;0290 zstroke;01B6 zuhiragana;305A zukatakana;30BA a100;275E a101;2761 a102;2762 a103;2763 a104;2764 a105;2710 a106;2765 a107;2766 a108;2767 a109;2660 a10;2721 a110;2665 a111;2666 a112;2663 a117;2709 a118;2708 a119;2707 a11;261B a120;2460 a121;2461 a122;2462 a123;2463 a124;2464 a125;2465 a126;2466 a127;2467 a128;2468 a129;2469 a12;261E a130;2776 a131;2777 a132;2778 a133;2779 a134;277A a135;277B a136;277C a137;277D a138;277E a139;277F a13;270C a140;2780 a141;2781 a142;2782 a143;2783 a144;2784 a145;2785 a146;2786 a147;2787 a148;2788 a149;2789 a14;270D a150;278A a151;278B a152;278C a153;278D a154;278E a155;278F a156;2790 a157;2791 a158;2792 a159;2793 a15;270E a160;2794 a161;2192 a162;27A3 a163;2194 a164;2195 a165;2799 a166;279B a167;279C a168;279D a169;279E a16;270F a170;279F a171;27A0 a172;27A1 a173;27A2 a174;27A4 a175;27A5 a176;27A6 a177;27A7 a178;27A8 a179;27A9 a17;2711 a180;27AB a181;27AD a182;27AF a183;27B2 a184;27B3 a185;27B5 a186;27B8 a187;27BA a188;27BB a189;27BC a18;2712 a190;27BD a191;27BE a192;279A a193;27AA a194;27B6 a195;27B9 a196;2798 a197;27B4 a198;27B7 a199;27AC a19;2713 a1;2701 a200;27AE a201;27B1 a202;2703 a203;2750 a204;2752 a205;276E a206;2770 a20;2714 a21;2715 a22;2716 a23;2717 a24;2718 a25;2719 a26;271A a27;271B a28;271C a29;2722 a2;2702 a30;2723 a31;2724 a32;2725 a33;2726 a34;2727 a35;2605 a36;2729 a37;272A a38;272B a39;272C a3;2704 a40;272D a41;272E a42;272F a43;2730 a44;2731 a45;2732 a46;2733 a47;2734 a48;2735 a49;2736 a4;260E a50;2737 a51;2738 a52;2739 a53;273A a54;273B a55;273C a56;273D a57;273E a58;273F a59;2740 a5;2706 a60;2741 a61;2742 a62;2743 a63;2744 a64;2745 a65;2746 a66;2747 a67;2748 a68;2749 a69;274A a6;271D a70;274B a71;25CF a72;274D a73;25A0 a74;274F a75;2751 a76;25B2 a77;25BC a78;25C6 a79;2756 a7;271E a81;25D7 a82;2758 a83;2759 a84;275A a85;276F a86;2771 a87;2772 a88;2773 a89;2768 a8;271F a90;2769 a91;276C a92;276D a93;276A a94;276B a95;2774 a96;2775 a97;275B a98;275C a99;275D a9;2720 """ # string table management # class StringTable: def __init__( self, name_list, master_table_name ): self.names = name_list self.master_table = master_table_name self.indices = {} index = 0 for name in name_list: self.indices[name] = index index += len( name ) + 1 self.total = index def dump( self, file ): write = file.write write( " static const char " + self.master_table + "[" + repr( self.total ) + "] =\n" ) write( " {\n" ) line = "" for name in self.names: line += " '" line += string.join( ( re.findall( ".", name ) ), "','" ) line += "', 0,\n" write( line + " };\n\n\n" ) def dump_sublist( self, file, table_name, macro_name, sublist ): write = file.write write( "#define " + macro_name + " " + repr( len( sublist ) ) + "\n\n" ) write( " /* Values are offsets into the `" + self.master_table + "' table */\n\n" ) write( " static const short " + table_name + "[" + macro_name + "] =\n" ) write( " {\n" ) line = " " comma = "" col = 0 for name in sublist: line += comma line += "%4d" % self.indices[name] col += 1 comma = "," if col == 14: col = 0 comma = ",\n " write( line + "\n };\n\n\n" ) # We now store the Adobe Glyph List in compressed form. The list is put # into a data structure called `trie' (because it has a tree-like # appearance). Consider, for example, that you want to store the # following name mapping: # # A => 1 # Aacute => 6 # Abalon => 2 # Abstract => 4 # # It is possible to store the entries as follows. # # A => 1 # | # +-acute => 6 # | # +-b # | # +-alon => 2 # | # +-stract => 4 # # We see that each node in the trie has: # # - one or more `letters' # - an optional value # - zero or more child nodes # # The first step is to call # # root = StringNode( "", 0 ) # for word in map.values(): # root.add( word, map[word] ) # # which creates a large trie where each node has only one children. # # Executing # # root = root.optimize() # # optimizes the trie by merging the letters of successive nodes whenever # possible. # # Each node of the trie is stored as follows. # # - First the node's letter, according to the following scheme. We # use the fact that in the AGL no name contains character codes > 127. # # name bitsize description # ---------------------------------------------------------------- # notlast 1 Set to 1 if this is not the last letter # in the word. # ascii 7 The letter's ASCII value. # # - The letter is followed by a children count and the value of the # current key (if any). Again we can do some optimization because all # AGL entries are from the BMP; this means that 16 bits are sufficient # to store its Unicode values. Additionally, no node has more than # 127 children. # # name bitsize description # ----------------------------------------- # hasvalue 1 Set to 1 if a 16-bit Unicode value follows. # num_children 7 Number of children. Can be 0 only if # `hasvalue' is set to 1. # value 16 Optional Unicode value. # # - A node is finished by a list of 16bit absolute offsets to the # children, which must be sorted in increasing order of their first # letter. # # For simplicity, all 16bit quantities are stored in big-endian order. # # The root node has first letter = 0, and no value. # class StringNode: def __init__( self, letter, value ): self.letter = letter self.value = value self.children = {} def __cmp__( self, other ): return ord( self.letter[0] ) - ord( other.letter[0] ) def add( self, word, value ): if len( word ) == 0: self.value = value return letter = word[0] word = word[1:] if self.children.has_key( letter ): child = self.children[letter] else: child = StringNode( letter, 0 ) self.children[letter] = child child.add( word, value ) def optimize( self ): # optimize all children first children = self.children.values() self.children = {} for child in children: self.children[child.letter[0]] = child.optimize() # don't optimize if there's a value, # if we don't have any child or if we # have more than one child if ( self.value != 0 ) or ( not children ) or len( children ) > 1: return self child = children[0] self.letter += child.letter self.value = child.value self.children = child.children return self def dump_debug( self, write, margin ): # this is used during debugging line = margin + "+-" if len( self.letter ) == 0: line += "<NOLETTER>" else: line += self.letter if self.value: line += " => " + repr( self.value ) write( line + "\n" ) if self.children: margin += "| " for child in self.children.values(): child.dump_debug( write, margin ) def locate( self, index ): self.index = index if len( self.letter ) > 0: index += len( self.letter ) + 1 else: index += 2 if self.value != 0: index += 2 children = self.children.values() children.sort() index += 2 * len( children ) for child in children: index = child.locate( index ) return index def store( self, storage ): # write the letters l = len( self.letter ) if l == 0: storage += struct.pack( "B", 0 ) else: for n in range( l ): val = ord( self.letter[n] ) if n < l - 1: val += 128 storage += struct.pack( "B", val ) # write the count children = self.children.values() children.sort() count = len( children ) if self.value != 0: storage += struct.pack( "!BH", count + 128, self.value ) else: storage += struct.pack( "B", count ) for child in children: storage += struct.pack( "!H", child.index ) for child in children: storage = child.store( storage ) return storage def adobe_glyph_values(): """return the list of glyph names and their unicode values""" lines = string.split( adobe_glyph_list, '\n' ) glyphs = [] values = [] for line in lines: if line: fields = string.split( line, ';' ) # print fields[1] + ' - ' + fields[0] subfields = string.split( fields[1], ' ' ) if len( subfields ) == 1: glyphs.append( fields[0] ) values.append( fields[1] ) return glyphs, values def filter_glyph_names( alist, filter ): """filter `alist' by taking _out_ all glyph names that are in `filter'""" count = 0 extras = [] for name in alist: try: filtered_index = filter.index( name ) except: extras.append( name ) return extras def dump_encoding( file, encoding_name, encoding_list ): """dump a given encoding""" write = file.write write( " /* the following are indices into the SID name table */\n" ) write( " static const unsigned short " + encoding_name + "[" + repr( len( encoding_list ) ) + "] =\n" ) write( " {\n" ) line = " " comma = "" col = 0 for value in encoding_list: line += comma line += "%3d" % value comma = "," col += 1 if col == 16: col = 0 comma = ",\n " write( line + "\n };\n\n\n" ) def dump_array( the_array, write, array_name ): """dumps a given encoding""" write( " static const unsigned char " + array_name + "[" + repr( len( the_array ) ) + "L] =\n" ) write( " {\n" ) line = "" comma = " " col = 0 for value in the_array: line += comma line += "%3d" % ord( value ) comma = "," col += 1 if col == 16: col = 0 comma = ",\n " if len( line ) > 1024: write( line ) line = "" write( line + "\n };\n\n\n" ) def main(): """main program body""" if len( sys.argv ) != 2: print __doc__ % sys.argv[0] sys.exit( 1 ) file = open( sys.argv[1], "w\n" ) write = file.write count_sid = len( sid_standard_names ) # `mac_extras' contains the list of glyph names in the Macintosh standard # encoding which are not in the SID Standard Names. # mac_extras = filter_glyph_names( mac_standard_names, sid_standard_names ) # `base_list' contains the names of our final glyph names table. # It consists of the `mac_extras' glyph names, followed by the SID # standard names. # mac_extras_count = len( mac_extras ) base_list = mac_extras + sid_standard_names write( "/***************************************************************************/\n" ) write( "/* */\n" ) write( "/* %-71s*/\n" % os.path.basename( sys.argv[1] ) ) write( "/* */\n" ) write( "/* PostScript glyph names. */\n" ) write( "/* */\n" ) write( "/* Copyright 2005, 2008, 2011 by */\n" ) write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" ) write( "/* */\n" ) write( "/* This file is part of the FreeType project, and may only be used, */\n" ) write( "/* modified, and distributed under the terms of the FreeType project */\n" ) write( "/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\n" ) write( "/* this file you indicate that you have read the license and */\n" ) write( "/* understand and accept it fully. */\n" ) write( "/* */\n" ) write( "/***************************************************************************/\n" ) write( "\n" ) write( "\n" ) write( " /* This file has been generated automatically -- do not edit! */\n" ) write( "\n" ) write( "\n" ) # dump final glyph list (mac extras + sid standard names) # st = StringTable( base_list, "ft_standard_glyph_names" ) st.dump( file ) st.dump_sublist( file, "ft_mac_names", "FT_NUM_MAC_NAMES", mac_standard_names ) st.dump_sublist( file, "ft_sid_names", "FT_NUM_SID_NAMES", sid_standard_names ) dump_encoding( file, "t1_standard_encoding", t1_standard_encoding ) dump_encoding( file, "t1_expert_encoding", t1_expert_encoding ) # dump the AGL in its compressed form # agl_glyphs, agl_values = adobe_glyph_values() dict = StringNode( "", 0 ) for g in range( len( agl_glyphs ) ): dict.add( agl_glyphs[g], eval( "0x" + agl_values[g] ) ) dict = dict.optimize() dict_len = dict.locate( 0 ) dict_array = dict.store( "" ) write( """\ /* * This table is a compressed version of the Adobe Glyph List (AGL), * optimized for efficient searching. It has been generated by the * `glnames.py' python script located in the `src/tools' directory. * * The lookup function to get the Unicode value for a given string * is defined below the table. */ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST """ ) dump_array( dict_array, write, "ft_adobe_glyph_list" ) # write the lookup routine now # write( """\ /* * This function searches the compressed table efficiently. */ static unsigned long ft_get_adobe_glyph_index( const char* name, const char* limit ) { int c = 0; int count, min, max; const unsigned char* p = ft_adobe_glyph_list; if ( name == 0 || name >= limit ) goto NotFound; c = *name++; count = p[1]; p += 2; min = 0; max = count; while ( min < max ) { int mid = ( min + max ) >> 1; const unsigned char* q = p + mid * 2; int c2; q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] ); c2 = q[0] & 127; if ( c2 == c ) { p = q; goto Found; } if ( c2 < c ) min = mid + 1; else max = mid; } goto NotFound; Found: for (;;) { /* assert (*p & 127) == c */ if ( name >= limit ) { if ( (p[0] & 128) == 0 && (p[1] & 128) != 0 ) return (unsigned long)( ( (int)p[2] << 8 ) | p[3] ); goto NotFound; } c = *name++; if ( p[0] & 128 ) { p++; if ( c != (p[0] & 127) ) goto NotFound; continue; } p++; count = p[0] & 127; if ( p[0] & 128 ) p += 2; p++; for ( ; count > 0; count--, p += 2 ) { int offset = ( (int)p[0] << 8 ) | p[1]; const unsigned char* q = ft_adobe_glyph_list + offset; if ( c == ( q[0] & 127 ) ) { p = q; goto NextIter; } } goto NotFound; NextIter: ; } NotFound: return 0; } #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ """ ) if 0: # generate unit test, or don't # # now write the unit test to check that everything works OK # write( "#ifdef TEST\n\n" ) write( "static const char* const the_names[] = {\n" ) for name in agl_glyphs: write( ' "' + name + '",\n' ) write( " 0\n};\n" ) write( "static const unsigned long the_values[] = {\n" ) for val in agl_values: write( ' 0x' + val + ',\n' ) write( " 0\n};\n" ) write( """ #include <stdlib.h> #include <stdio.h> int main( void ) { int result = 0; const char* const* names = the_names; const unsigned long* values = the_values; for ( ; *names; names++, values++ ) { const char* name = *names; unsigned long reference = *values; unsigned long value; value = ft_get_adobe_glyph_index( name, name + strlen( name ) ); if ( value != reference ) { result = 1; fprintf( stderr, "name '%s' => %04x instead of %04x\\n", name, value, reference ); } } return result; } """ ) write( "#endif /* TEST */\n" ) write("\n/* END */\n") # Now run the main routine # main() # END
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 199, 3, 199, 3, 2868, 804, 499, 14165, 536, 6545, 199, 3, 421, 199, 3, 1898, 31347, 13, 8269, 12, 13004, 12, 11811, 12, 10219, 12, 9079, 12, 7760, 701, 199, 3, 20232, 16147, 281, 12, 6848, 12504, 644, 382, 72, 21226, 12, 436, 644, 281, 1372, 7005, 976, 71, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 2868, 804, 2199, 12, 436, 1443, 1454, 506, 1202, 12, 6042, 12, 199, 3, 436, 1854, 1334, 314, 2895, 402, 314, 2868, 804, 2199, 4190, 12, 199, 3, 5113, 14, 17715, 14, 221, 4885, 32620, 370, 675, 12, 2811, 12, 503, 11207, 642, 570, 1265, 199, 3, 6623, 626, 1265, 1172, 1586, 314, 4190, 436, 20647, 436, 4729, 652, 199, 3, 9999, 14, 421, 199, 19659, 199, 199, 3807, 26, 450, 83, 665, 1199, 13, 493, 30, 819, 961, 2366, 2884, 12821, 314, 14165, 1561, 6716, 3247, 315, 314, 523, 658, 1190, 1247, 7, 859, 14, 819, 22940, 2849, 1423, 365, 314, 536, 402, 314, 1406, 570, 370, 506, 2737, 14, 199, 624, 421, 199, 646, 984, 12, 1059, 12, 2702, 12, 295, 12, 747, 14, 515, 421, 199, 3, 961, 1817, 5548, 314, 24222, 7182, 370, 314, 10444, 9924, 609, 8929, 14, 199, 3, 2779, 365, 1202, 701, 314, 715, 804, 7711, 1579, 1561, 1817, 14, 199, 3, 199, 3, 1666, 199, 3, 199, 3, 257, 1455, 921, 19864, 14, 12820, 14, 957, 15, 1481, 2891, 2395, 15, 11026, 1690, 15, 1049, 439, 22, 1932, 14, 1360, 199, 3, 199, 3, 367, 314, 25410, 769, 14, 199, 3, 199, 3088, 63, 6807, 63, 1247, 275, 971, 199, 59, 523, 327, 378, 523, 3680, 1397, 318, 401, 3680, 2307, 401, 298, 2865, 1657, 316, 1107, 401, 298, 2638, 401, 298, 2804, 17984, 401, 523, 298, 9888, 3345, 401, 298, 1955, 1037, 401, 298, 68, 25317, 401, 298, 7045, 401, 298, 5282, 1192, 460, 401, 819, 327, 1616, 523, 298, 14005, 2361, 401, 298, 9575, 3039, 401, 298, 9575, 1019, 401, 298, 305, 6236, 1339, 401, 298, 6666, 401, 523, 298, 13184, 401, 298, 30215, 401, 298, 5191, 401, 298, 7001, 401, 298, 4262, 401, 819, 327, 3388, 523, 298, 368, 401, 298, 5601, 401, 298, 10480, 401, 298, 13672, 401, 298, 23702, 401, 523, 298, 4174, 401, 298, 27346, 401, 298, 32579, 401, 298, 30126, 401, 298, 12167, 401, 819, 327, 4233, 523, 298, 19290, 12167, 401, 298, 2003, 401, 298, 1452, 401, 298, 13154, 401, 298, 4790, 401, 523, 298, 292, 401, 298, 33, 401, 298, 34, 401, 298, 35, 401, 298, 36, 401, 819, 327, 6335, 523, 298, 37, 401, 298, 38, 401, 298, 39, 401, 298, 40, 401, 298, 41, 401, 523, 298, 42, 401, 298, 43, 401, 298, 44, 401, 298, 45, 401, 298, 46, 401, 819, 327, 5238, 523, 298, 47, 401, 298, 48, 401, 298, 49, 401, 298, 50, 401, 298, 51, 401, 523, 298, 52, 401, 298, 53, 401, 298, 54, 401, 298, 55, 401, 298, 56, 401, 819, 327, 5212, 523, 298, 57, 401, 298, 58, 401, 298, 14594, 3039, 401, 298, 21509, 401, 298, 14594, 1019, 401, 523, 298, 305, 559, 530, 5958, 453, 401, 298, 21831, 401, 298, 19612, 401, 298, 65, 401, 298, 66, 401, 819, 327, 10045, 523, 298, 67, 401, 298, 68, 401, 298, 69, 401, 298, 70, 401, 298, 71, 401, 523, 298, 72, 401, 298, 73, 401, 298, 74, 401, 298, 75, 401, 298, 76, 401, 819, 327, 5939, 523, 298, 77, 401, 298, 78, 401, 298, 79, 401, 298, 80, 401, 298, 81, 401, 523, 298, 82, 401, 298, 83, 401, 298, 84, 401, 298, 85, 401, 298, 86, 401, 819, 327, 9137, 523, 298, 87, 401, 298, 88, 401, 298, 89, 401, 298, 90, 401, 298, 22359, 3039, 401, 523, 298, 1700, 401, 298, 7828, 2247, 1070, 401, 298, 4371, 16488, 401, 298, 33, 30956, 401, 298, 1596, 316, 401, 819, 327, 2948, 523, 298, 35, 27916, 416, 401, 298, 37, 14696, 401, 298, 46, 16488, 401, 298, 47, 30956, 401, 298, 53, 30956, 401, 523, 298, 65, 14696, 401, 298, 643, 345, 432, 401, 298, 65, 24235, 401, 298, 65, 30956, 401, 298, 2159, 76, 271, 401, 819, 327, 16814, 523, 298, 9332, 401, 298, 67, 27916, 416, 401, 298, 69, 14696, 401, 298, 69, 19612, 401, 298, 69, 24235, 401, 523, 298, 6297, 69, 22163, 401, 298, 73, 14696, 401, 298, 528, 345, 432, 401, 298, 530, 5958, 20977, 401, 298, 9897, 69, 22163, 401, 819, 327, 13960, 523, 298, 78, 16488, 401, 298, 79, 14696, 401, 298, 79, 19612, 401, 298, 3095, 1195, 20977, 401, 298, 79, 30956, 401, 523, 298, 79, 16488, 401, 298, 8243, 938, 401, 298, 85, 19612, 401, 298, 85, 24235, 401, 298, 14525, 69, 22163, 401, 819, 327, 21334, 523, 298, 7406, 836, 401, 298, 10956, 401, 298, 2946, 401, 298, 11652, 2983, 401, 298, 2792, 401, 523, 298, 20520, 401, 298, 12400, 401, 298, 836, 10333, 66, 478, 401, 298, 11616, 401, 298, 7307, 401, 819, 327, 22796, 523, 298, 21697, 1657, 401, 298, 14696, 401, 298, 30956, 401, 298, 4610, 537, 401, 298, 12500, 401, 523, 298, 47, 7001, 401, 298, 262, 9693, 401, 298, 6666, 13084, 401, 298, 2978, 261, 537, 401, 298, 71, 622, 264, 537, 401, 819, 327, 14711, 523, 298, 28695, 401, 298, 6553, 401, 298, 6672, 3028, 401, 298, 1838, 1615, 401, 298, 2558, 401, 523, 298, 1038, 401, 298, 24705, 401, 298, 2181, 771, 827, 1132, 401, 298, 2181, 5892, 3119, 1132, 401, 298, 47, 29073, 401, 819, 327, 21235, 523, 298, 3624, 401, 298, 736, 22376, 401, 298, 4790, 2110, 401, 298, 2804, 416, 1064, 944, 401, 298, 7954, 1397, 401, 523, 298, 12841, 915, 401, 298, 2327, 269, 262, 401, 298, 16815, 1452, 401, 298, 13411, 401, 298, 6051, 382, 3701, 357, 3039, 401, 819, 327, 27209, 523, 298, 6051, 382, 3701, 357, 1019, 401, 298, 16514, 2316, 401, 298, 2865, 4785, 780, 1142, 401, 298, 33, 19612, 401, 298, 33, 16488, 401, 523, 298, 47, 16488, 401, 298, 27588, 401, 298, 13361, 401, 298, 500, 1119, 401 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 199, 3, 199, 3, 2868, 804, 499, 14165, 536, 6545, 199, 3, 421, 199, 3, 1898, 31347, 13, 8269, 12, 13004, 12, 11811, 12, 10219, 12, 9079, 12, 7760, 701, 199, 3, 20232, 16147, 281, 12, 6848, 12504, 644, 382, 72, 21226, 12, 436, 644, 281, 1372, 7005, 976, 71, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 314, 2868, 804, 2199, 12, 436, 1443, 1454, 506, 1202, 12, 6042, 12, 199, 3, 436, 1854, 1334, 314, 2895, 402, 314, 2868, 804, 2199, 4190, 12, 199, 3, 5113, 14, 17715, 14, 221, 4885, 32620, 370, 675, 12, 2811, 12, 503, 11207, 642, 570, 1265, 199, 3, 6623, 626, 1265, 1172, 1586, 314, 4190, 436, 20647, 436, 4729, 652, 199, 3, 9999, 14, 421, 199, 19659, 199, 199, 3807, 26, 450, 83, 665, 1199, 13, 493, 30, 819, 961, 2366, 2884, 12821, 314, 14165, 1561, 6716, 3247, 315, 314, 523, 658, 1190, 1247, 7, 859, 14, 819, 22940, 2849, 1423, 365, 314, 536, 402, 314, 1406, 570, 370, 506, 2737, 14, 199, 624, 421, 199, 646, 984, 12, 1059, 12, 2702, 12, 295, 12, 747, 14, 515, 421, 199, 3, 961, 1817, 5548, 314, 24222, 7182, 370, 314, 10444, 9924, 609, 8929, 14, 199, 3, 2779, 365, 1202, 701, 314, 715, 804, 7711, 1579, 1561, 1817, 14, 199, 3, 199, 3, 1666, 199, 3, 199, 3, 257, 1455, 921, 19864, 14, 12820, 14, 957, 15, 1481, 2891, 2395, 15, 11026, 1690, 15, 1049, 439, 22, 1932, 14, 1360, 199, 3, 199, 3, 367, 314, 25410, 769, 14, 199, 3, 199, 3088, 63, 6807, 63, 1247, 275, 971, 199, 59, 523, 327, 378, 523, 3680, 1397, 318, 401, 3680, 2307, 401, 298, 2865, 1657, 316, 1107, 401, 298, 2638, 401, 298, 2804, 17984, 401, 523, 298, 9888, 3345, 401, 298, 1955, 1037, 401, 298, 68, 25317, 401, 298, 7045, 401, 298, 5282, 1192, 460, 401, 819, 327, 1616, 523, 298, 14005, 2361, 401, 298, 9575, 3039, 401, 298, 9575, 1019, 401, 298, 305, 6236, 1339, 401, 298, 6666, 401, 523, 298, 13184, 401, 298, 30215, 401, 298, 5191, 401, 298, 7001, 401, 298, 4262, 401, 819, 327, 3388, 523, 298, 368, 401, 298, 5601, 401, 298, 10480, 401, 298, 13672, 401, 298, 23702, 401, 523, 298, 4174, 401, 298, 27346, 401, 298, 32579, 401, 298, 30126, 401, 298, 12167, 401, 819, 327, 4233, 523, 298, 19290, 12167, 401, 298, 2003, 401, 298, 1452, 401, 298, 13154, 401, 298, 4790, 401, 523, 298, 292, 401, 298, 33, 401, 298, 34, 401, 298, 35, 401, 298, 36, 401, 819, 327, 6335, 523, 298, 37, 401, 298, 38, 401, 298, 39, 401, 298, 40, 401, 298, 41, 401, 523, 298, 42, 401, 298, 43, 401, 298, 44, 401, 298, 45, 401, 298, 46, 401, 819, 327, 5238, 523, 298, 47, 401, 298, 48, 401, 298, 49, 401, 298, 50, 401, 298, 51, 401, 523, 298, 52, 401, 298, 53, 401, 298, 54, 401, 298, 55, 401, 298, 56, 401, 819, 327, 5212, 523, 298, 57, 401, 298, 58, 401, 298, 14594, 3039, 401, 298, 21509, 401, 298, 14594, 1019, 401, 523, 298, 305, 559, 530, 5958, 453, 401, 298, 21831, 401, 298, 19612, 401, 298, 65, 401, 298, 66, 401, 819, 327, 10045, 523, 298, 67, 401, 298, 68, 401, 298, 69, 401, 298, 70, 401, 298, 71, 401, 523, 298, 72, 401, 298, 73, 401, 298, 74, 401, 298, 75, 401, 298, 76, 401, 819, 327, 5939, 523, 298, 77, 401, 298, 78, 401, 298, 79, 401, 298, 80, 401, 298, 81, 401, 523, 298, 82, 401, 298, 83, 401, 298, 84, 401, 298, 85, 401, 298, 86, 401, 819, 327, 9137, 523, 298, 87, 401, 298, 88, 401, 298, 89, 401, 298, 90, 401, 298, 22359, 3039, 401, 523, 298, 1700, 401, 298, 7828, 2247, 1070, 401, 298, 4371, 16488, 401, 298, 33, 30956, 401, 298, 1596, 316, 401, 819, 327, 2948, 523, 298, 35, 27916, 416, 401, 298, 37, 14696, 401, 298, 46, 16488, 401, 298, 47, 30956, 401, 298, 53, 30956, 401, 523, 298, 65, 14696, 401, 298, 643, 345, 432, 401, 298, 65, 24235, 401, 298, 65, 30956, 401, 298, 2159, 76, 271, 401, 819, 327, 16814, 523, 298, 9332, 401, 298, 67, 27916, 416, 401, 298, 69, 14696, 401, 298, 69, 19612, 401, 298, 69, 24235, 401, 523, 298, 6297, 69, 22163, 401, 298, 73, 14696, 401, 298, 528, 345, 432, 401, 298, 530, 5958, 20977, 401, 298, 9897, 69, 22163, 401, 819, 327, 13960, 523, 298, 78, 16488, 401, 298, 79, 14696, 401, 298, 79, 19612, 401, 298, 3095, 1195, 20977, 401, 298, 79, 30956, 401, 523, 298, 79, 16488, 401, 298, 8243, 938, 401, 298, 85, 19612, 401, 298, 85, 24235, 401, 298, 14525, 69, 22163, 401, 819, 327, 21334, 523, 298, 7406, 836, 401, 298, 10956, 401, 298, 2946, 401, 298, 11652, 2983, 401, 298, 2792, 401, 523, 298, 20520, 401, 298, 12400, 401, 298, 836, 10333, 66, 478, 401, 298, 11616, 401, 298, 7307, 401, 819, 327, 22796, 523, 298, 21697, 1657, 401, 298, 14696, 401, 298, 30956, 401, 298, 4610, 537, 401, 298, 12500, 401, 523, 298, 47, 7001, 401, 298, 262, 9693, 401, 298, 6666, 13084, 401, 298, 2978, 261, 537, 401, 298, 71, 622, 264, 537, 401, 819, 327, 14711, 523, 298, 28695, 401, 298, 6553, 401, 298, 6672, 3028, 401, 298, 1838, 1615, 401, 298, 2558, 401, 523, 298, 1038, 401, 298, 24705, 401, 298, 2181, 771, 827, 1132, 401, 298, 2181, 5892, 3119, 1132, 401, 298, 47, 29073, 401, 819, 327, 21235, 523, 298, 3624, 401, 298, 736, 22376, 401, 298, 4790, 2110, 401, 298, 2804, 416, 1064, 944, 401, 298, 7954, 1397, 401, 523, 298, 12841, 915, 401, 298, 2327, 269, 262, 401, 298, 16815, 1452, 401, 298, 13411, 401, 298, 6051, 382, 3701, 357, 3039, 401, 819, 327, 27209, 523, 298, 6051, 382, 3701, 357, 1019, 401, 298, 16514, 2316, 401, 298, 2865, 4785, 780, 1142, 401, 298, 33, 19612, 401, 298, 33, 16488, 401, 523, 298, 47, 16488, 401, 298, 27588, 401, 298, 13361, 401, 298, 500, 1119, 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, 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 ]
globau/servo
tests/wpt/css-tests/tools/pytest/_pytest/pytester.py
175
38600
""" (disabled by default) support for testing pytest and pytest plugins. """ import codecs import gc import os import platform import re import subprocess import sys import time import traceback from fnmatch import fnmatch from py.builtin import print_ from _pytest._code import Source import py import pytest from _pytest.main import Session, EXIT_OK def pytest_addoption(parser): # group = parser.getgroup("pytester", "pytester (self-tests) options") parser.addoption('--lsof', action="store_true", dest="lsof", default=False, help=("run FD checks if lsof is available")) parser.addoption('--runpytest', default="inprocess", dest="runpytest", choices=("inprocess", "subprocess", ), help=("run pytest sub runs in tests using an 'inprocess' " "or 'subprocess' (python -m main) method")) def pytest_configure(config): # This might be called multiple times. Only take the first. global _pytest_fullpath try: _pytest_fullpath except NameError: _pytest_fullpath = os.path.abspath(pytest.__file__.rstrip("oc")) _pytest_fullpath = _pytest_fullpath.replace("$py.class", ".py") if config.getvalue("lsof"): checker = LsofFdLeakChecker() if checker.matching_platform(): config.pluginmanager.register(checker) class LsofFdLeakChecker(object): def get_open_files(self): out = self._exec_lsof() open_files = self._parse_lsof_output(out) return open_files def _exec_lsof(self): pid = os.getpid() return py.process.cmdexec("lsof -Ffn0 -p %d" % pid) def _parse_lsof_output(self, out): def isopen(line): return line.startswith('f') and ("deleted" not in line and 'mem' not in line and "txt" not in line and 'cwd' not in line) open_files = [] for line in out.split("\n"): if isopen(line): fields = line.split('\0') fd = fields[0][1:] filename = fields[1][1:] if filename.startswith('/'): open_files.append((fd, filename)) return open_files def matching_platform(self): try: py.process.cmdexec("lsof -v") except (py.process.cmdexec.Error, UnicodeDecodeError): # cmdexec may raise UnicodeDecodeError on Windows systems # with locale other than english: # https://bitbucket.org/pytest-dev/py/issues/66 return False else: return True @pytest.hookimpl(hookwrapper=True, tryfirst=True) def pytest_runtest_item(self, item): lines1 = self.get_open_files() yield if hasattr(sys, "pypy_version_info"): gc.collect() lines2 = self.get_open_files() new_fds = set([t[0] for t in lines2]) - set([t[0] for t in lines1]) leaked_files = [t for t in lines2 if t[0] in new_fds] if leaked_files: error = [] error.append("***** %s FD leakage detected" % len(leaked_files)) error.extend([str(f) for f in leaked_files]) error.append("*** Before:") error.extend([str(f) for f in lines1]) error.append("*** After:") error.extend([str(f) for f in lines2]) error.append(error[0]) error.append("*** function %s:%s: %s " % item.location) pytest.fail("\n".join(error), pytrace=False) # XXX copied from execnet's conftest.py - needs to be merged winpymap = { 'python2.7': r'C:\Python27\python.exe', 'python2.6': r'C:\Python26\python.exe', 'python3.1': r'C:\Python31\python.exe', 'python3.2': r'C:\Python32\python.exe', 'python3.3': r'C:\Python33\python.exe', 'python3.4': r'C:\Python34\python.exe', 'python3.5': r'C:\Python35\python.exe', } def getexecutable(name, cache={}): try: return cache[name] except KeyError: executable = py.path.local.sysfind(name) if executable: if name == "jython": import subprocess popen = subprocess.Popen([str(executable), "--version"], universal_newlines=True, stderr=subprocess.PIPE) out, err = popen.communicate() if not err or "2.5" not in err: executable = None if "2.5.2" in err: executable = None # http://bugs.jython.org/issue1790 cache[name] = executable return executable @pytest.fixture(params=['python2.6', 'python2.7', 'python3.3', "python3.4", 'pypy', 'pypy3']) def anypython(request): name = request.param executable = getexecutable(name) if executable is None: if sys.platform == "win32": executable = winpymap.get(name, None) if executable: executable = py.path.local(executable) if executable.check(): return executable pytest.skip("no suitable %s found" % (name,)) return executable # used at least by pytest-xdist plugin @pytest.fixture def _pytest(request): """ Return a helper which offers a gethookrecorder(hook) method which returns a HookRecorder instance which helps to make assertions about called hooks. """ return PytestArg(request) class PytestArg: def __init__(self, request): self.request = request def gethookrecorder(self, hook): hookrecorder = HookRecorder(hook._pm) self.request.addfinalizer(hookrecorder.finish_recording) return hookrecorder def get_public_names(l): """Only return names from iterator l without a leading underscore.""" return [x for x in l if x[0] != "_"] class ParsedCall: def __init__(self, name, kwargs): self.__dict__.update(kwargs) self._name = name def __repr__(self): d = self.__dict__.copy() del d['_name'] return "<ParsedCall %r(**%r)>" %(self._name, d) class HookRecorder: """Record all hooks called in a plugin manager. This wraps all the hook calls in the plugin manager, recording each call before propagating the normal calls. """ def __init__(self, pluginmanager): self._pluginmanager = pluginmanager self.calls = [] def before(hook_name, hook_impls, kwargs): self.calls.append(ParsedCall(hook_name, kwargs)) def after(outcome, hook_name, hook_impls, kwargs): pass self._undo_wrapping = pluginmanager.add_hookcall_monitoring(before, after) def finish_recording(self): self._undo_wrapping() def getcalls(self, names): if isinstance(names, str): names = names.split() return [call for call in self.calls if call._name in names] def assert_contains(self, entries): __tracebackhide__ = True i = 0 entries = list(entries) backlocals = sys._getframe(1).f_locals while entries: name, check = entries.pop(0) for ind, call in enumerate(self.calls[i:]): if call._name == name: print_("NAMEMATCH", name, call) if eval(check, backlocals, call.__dict__): print_("CHECKERMATCH", repr(check), "->", call) else: print_("NOCHECKERMATCH", repr(check), "-", call) continue i += ind + 1 break print_("NONAMEMATCH", name, "with", call) else: pytest.fail("could not find %r check %r" % (name, check)) def popcall(self, name): __tracebackhide__ = True for i, call in enumerate(self.calls): if call._name == name: del self.calls[i] return call lines = ["could not find call %r, in:" % (name,)] lines.extend([" %s" % str(x) for x in self.calls]) pytest.fail("\n".join(lines)) def getcall(self, name): l = self.getcalls(name) assert len(l) == 1, (name, l) return l[0] # functionality for test reports def getreports(self, names="pytest_runtest_logreport pytest_collectreport"): return [x.report for x in self.getcalls(names)] def matchreport(self, inamepart="", names="pytest_runtest_logreport pytest_collectreport", when=None): """ return a testreport whose dotted import path matches """ l = [] for rep in self.getreports(names=names): try: if not when and rep.when != "call" and rep.passed: # setup/teardown passing reports - let's ignore those continue except AttributeError: pass if when and getattr(rep, 'when', None) != when: continue if not inamepart or inamepart in rep.nodeid.split("::"): l.append(rep) if not l: raise ValueError("could not find test report matching %r: " "no test reports at all!" % (inamepart,)) if len(l) > 1: raise ValueError( "found 2 or more testreports matching %r: %s" %(inamepart, l)) return l[0] def getfailures(self, names='pytest_runtest_logreport pytest_collectreport'): return [rep for rep in self.getreports(names) if rep.failed] def getfailedcollections(self): return self.getfailures('pytest_collectreport') def listoutcomes(self): passed = [] skipped = [] failed = [] for rep in self.getreports( "pytest_collectreport pytest_runtest_logreport"): if rep.passed: if getattr(rep, "when", None) == "call": passed.append(rep) elif rep.skipped: skipped.append(rep) elif rep.failed: failed.append(rep) return passed, skipped, failed def countoutcomes(self): return [len(x) for x in self.listoutcomes()] def assertoutcome(self, passed=0, skipped=0, failed=0): realpassed, realskipped, realfailed = self.listoutcomes() assert passed == len(realpassed) assert skipped == len(realskipped) assert failed == len(realfailed) def clear(self): self.calls[:] = [] @pytest.fixture def linecomp(request): return LineComp() def pytest_funcarg__LineMatcher(request): return LineMatcher @pytest.fixture def testdir(request, tmpdir_factory): return Testdir(request, tmpdir_factory) rex_outcome = re.compile("(\d+) ([\w-]+)") class RunResult: """The result of running a command. Attributes: :ret: The return value. :outlines: List of lines captured from stdout. :errlines: List of lines captures from stderr. :stdout: :py:class:`LineMatcher` of stdout, use ``stdout.str()`` to reconstruct stdout or the commonly used ``stdout.fnmatch_lines()`` method. :stderrr: :py:class:`LineMatcher` of stderr. :duration: Duration in seconds. """ def __init__(self, ret, outlines, errlines, duration): self.ret = ret self.outlines = outlines self.errlines = errlines self.stdout = LineMatcher(outlines) self.stderr = LineMatcher(errlines) self.duration = duration def parseoutcomes(self): """ Return a dictionary of outcomestring->num from parsing the terminal output that the test process produced.""" for line in reversed(self.outlines): if 'seconds' in line: outcomes = rex_outcome.findall(line) if outcomes: d = {} for num, cat in outcomes: d[cat] = int(num) return d def assert_outcomes(self, passed=0, skipped=0, failed=0): """ assert that the specified outcomes appear with the respective numbers (0 means it didn't occur) in the text output from a test run.""" d = self.parseoutcomes() assert passed == d.get("passed", 0) assert skipped == d.get("skipped", 0) assert failed == d.get("failed", 0) class Testdir: """Temporary test directory with tools to test/run py.test itself. This is based on the ``tmpdir`` fixture but provides a number of methods which aid with testing py.test itself. Unless :py:meth:`chdir` is used all methods will use :py:attr:`tmpdir` as current working directory. Attributes: :tmpdir: The :py:class:`py.path.local` instance of the temporary directory. :plugins: A list of plugins to use with :py:meth:`parseconfig` and :py:meth:`runpytest`. Initially this is an empty list but plugins can be added to the list. The type of items to add to the list depend on the method which uses them so refer to them for details. """ def __init__(self, request, tmpdir_factory): self.request = request # XXX remove duplication with tmpdir plugin basetmp = tmpdir_factory.ensuretemp("testdir") name = request.function.__name__ for i in range(100): try: tmpdir = basetmp.mkdir(name + str(i)) except py.error.EEXIST: continue break self.tmpdir = tmpdir self.plugins = [] self._savesyspath = (list(sys.path), list(sys.meta_path)) self._savemodulekeys = set(sys.modules) self.chdir() # always chdir self.request.addfinalizer(self.finalize) method = self.request.config.getoption("--runpytest") if method == "inprocess": self._runpytest_method = self.runpytest_inprocess elif method == "subprocess": self._runpytest_method = self.runpytest_subprocess def __repr__(self): return "<Testdir %r>" % (self.tmpdir,) def finalize(self): """Clean up global state artifacts. Some methods modify the global interpreter state and this tries to clean this up. It does not remove the temporary directory however so it can be looked at after the test run has finished. """ sys.path[:], sys.meta_path[:] = self._savesyspath if hasattr(self, '_olddir'): self._olddir.chdir() self.delete_loaded_modules() def delete_loaded_modules(self): """Delete modules that have been loaded during a test. This allows the interpreter to catch module changes in case the module is re-imported. """ for name in set(sys.modules).difference(self._savemodulekeys): # it seems zope.interfaces is keeping some state # (used by twisted related tests) if name != "zope.interface": del sys.modules[name] def make_hook_recorder(self, pluginmanager): """Create a new :py:class:`HookRecorder` for a PluginManager.""" assert not hasattr(pluginmanager, "reprec") pluginmanager.reprec = reprec = HookRecorder(pluginmanager) self.request.addfinalizer(reprec.finish_recording) return reprec def chdir(self): """Cd into the temporary directory. This is done automatically upon instantiation. """ old = self.tmpdir.chdir() if not hasattr(self, '_olddir'): self._olddir = old def _makefile(self, ext, args, kwargs): items = list(kwargs.items()) if args: source = py.builtin._totext("\n").join( map(py.builtin._totext, args)) + py.builtin._totext("\n") basename = self.request.function.__name__ items.insert(0, (basename, source)) ret = None for name, value in items: p = self.tmpdir.join(name).new(ext=ext) source = Source(value) def my_totext(s, encoding="utf-8"): if py.builtin._isbytes(s): s = py.builtin._totext(s, encoding=encoding) return s source_unicode = "\n".join([my_totext(line) for line in source.lines]) source = py.builtin._totext(source_unicode) content = source.strip().encode("utf-8") # + "\n" #content = content.rstrip() + "\n" p.write(content, "wb") if ret is None: ret = p return ret def makefile(self, ext, *args, **kwargs): """Create a new file in the testdir. ext: The extension the file should use, including the dot. E.g. ".py". args: All args will be treated as strings and joined using newlines. The result will be written as contents to the file. The name of the file will be based on the test function requesting this fixture. E.g. "testdir.makefile('.txt', 'line1', 'line2')" kwargs: Each keyword is the name of a file, while the value of it will be written as contents of the file. E.g. "testdir.makefile('.ini', pytest='[pytest]\naddopts=-rs\n')" """ return self._makefile(ext, args, kwargs) def makeconftest(self, source): """Write a contest.py file with 'source' as contents.""" return self.makepyfile(conftest=source) def makeini(self, source): """Write a tox.ini file with 'source' as contents.""" return self.makefile('.ini', tox=source) def getinicfg(self, source): """Return the pytest section from the tox.ini config file.""" p = self.makeini(source) return py.iniconfig.IniConfig(p)['pytest'] def makepyfile(self, *args, **kwargs): """Shortcut for .makefile() with a .py extension.""" return self._makefile('.py', args, kwargs) def maketxtfile(self, *args, **kwargs): """Shortcut for .makefile() with a .txt extension.""" return self._makefile('.txt', args, kwargs) def syspathinsert(self, path=None): """Prepend a directory to sys.path, defaults to :py:attr:`tmpdir`. This is undone automatically after the test. """ if path is None: path = self.tmpdir sys.path.insert(0, str(path)) # a call to syspathinsert() usually means that the caller # wants to import some dynamically created files. # with python3 we thus invalidate import caches. self._possibly_invalidate_import_caches() def _possibly_invalidate_import_caches(self): # invalidate caches if we can (py33 and above) try: import importlib except ImportError: pass else: if hasattr(importlib, "invalidate_caches"): importlib.invalidate_caches() def mkdir(self, name): """Create a new (sub)directory.""" return self.tmpdir.mkdir(name) def mkpydir(self, name): """Create a new python package. This creates a (sub)direcotry with an empty ``__init__.py`` file so that is recognised as a python package. """ p = self.mkdir(name) p.ensure("__init__.py") return p Session = Session def getnode(self, config, arg): """Return the collection node of a file. :param config: :py:class:`_pytest.config.Config` instance, see :py:meth:`parseconfig` and :py:meth:`parseconfigure` to create the configuration. :param arg: A :py:class:`py.path.local` instance of the file. """ session = Session(config) assert '::' not in str(arg) p = py.path.local(arg) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([str(p)], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res def getpathnode(self, path): """Return the collection node of a file. This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to create the (configured) py.test Config instance. :param path: A :py:class:`py.path.local` instance of the file. """ config = self.parseconfigure(path) session = Session(config) x = session.fspath.bestrelpath(path) config.hook.pytest_sessionstart(session=session) res = session.perform_collect([x], genitems=False)[0] config.hook.pytest_sessionfinish(session=session, exitstatus=EXIT_OK) return res def genitems(self, colitems): """Generate all test items from a collection node. This recurses into the collection node and returns a list of all the test items contained within. """ session = colitems[0].session result = [] for colitem in colitems: result.extend(session.genitems(colitem)) return result def runitem(self, source): """Run the "test_func" Item. The calling test instance (the class which contains the test method) must provide a ``.getrunner()`` method which should return a runner which can run the test protocol for a single item, like e.g. :py:func:`_pytest.runner.runtestprotocol`. """ # used from runner functional tests item = self.getitem(source) # the test class where we are called from wants to provide the runner testclassinstance = self.request.instance runner = testclassinstance.getrunner() return runner(item) def inline_runsource(self, source, *cmdlineargs): """Run a test module in process using ``pytest.main()``. This run writes "source" into a temporary file and runs ``pytest.main()`` on it, returning a :py:class:`HookRecorder` instance for the result. :param source: The source code of the test module. :param cmdlineargs: Any extra command line arguments to use. :return: :py:class:`HookRecorder` instance of the result. """ p = self.makepyfile(source) l = list(cmdlineargs) + [p] return self.inline_run(*l) def inline_genitems(self, *args): """Run ``pytest.main(['--collectonly'])`` in-process. Retuns a tuple of the collected items and a :py:class:`HookRecorder` instance. This runs the :py:func:`pytest.main` function to run all of py.test inside the test process itself like :py:meth:`inline_run`. However the return value is a tuple of the collection items and a :py:class:`HookRecorder` instance. """ rec = self.inline_run("--collect-only", *args) items = [x.item for x in rec.getcalls("pytest_itemcollected")] return items, rec def inline_run(self, *args, **kwargs): """Run ``pytest.main()`` in-process, returning a HookRecorder. This runs the :py:func:`pytest.main` function to run all of py.test inside the test process itself. This means it can return a :py:class:`HookRecorder` instance which gives more detailed results from then run then can be done by matching stdout/stderr from :py:meth:`runpytest`. :param args: Any command line arguments to pass to :py:func:`pytest.main`. :param plugin: (keyword-only) Extra plugin instances the ``pytest.main()`` instance should use. :return: A :py:class:`HookRecorder` instance. """ rec = [] class Collect: def pytest_configure(x, config): rec.append(self.make_hook_recorder(config.pluginmanager)) plugins = kwargs.get("plugins") or [] plugins.append(Collect()) ret = pytest.main(list(args), plugins=plugins) self.delete_loaded_modules() if len(rec) == 1: reprec = rec.pop() else: class reprec: pass reprec.ret = ret # typically we reraise keyboard interrupts from the child run # because it's our user requesting interruption of the testing if ret == 2 and not kwargs.get("no_reraise_ctrlc"): calls = reprec.getcalls("pytest_keyboard_interrupt") if calls and calls[-1].excinfo.type == KeyboardInterrupt: raise KeyboardInterrupt() return reprec def runpytest_inprocess(self, *args, **kwargs): """ Return result of running pytest in-process, providing a similar interface to what self.runpytest() provides. """ if kwargs.get("syspathinsert"): self.syspathinsert() now = time.time() capture = py.io.StdCapture() try: try: reprec = self.inline_run(*args, **kwargs) except SystemExit as e: class reprec: ret = e.args[0] except Exception: traceback.print_exc() class reprec: ret = 3 finally: out, err = capture.reset() sys.stdout.write(out) sys.stderr.write(err) res = RunResult(reprec.ret, out.split("\n"), err.split("\n"), time.time()-now) res.reprec = reprec return res def runpytest(self, *args, **kwargs): """ Run pytest inline or in a subprocess, depending on the command line option "--runpytest" and return a :py:class:`RunResult`. """ args = self._ensure_basetemp(args) return self._runpytest_method(*args, **kwargs) def _ensure_basetemp(self, args): args = [str(x) for x in args] for x in args: if str(x).startswith('--basetemp'): #print ("basedtemp exists: %s" %(args,)) break else: args.append("--basetemp=%s" % self.tmpdir.dirpath('basetemp')) #print ("added basetemp: %s" %(args,)) return args def parseconfig(self, *args): """Return a new py.test Config instance from given commandline args. This invokes the py.test bootstrapping code in _pytest.config to create a new :py:class:`_pytest.core.PluginManager` and call the pytest_cmdline_parse hook to create new :py:class:`_pytest.config.Config` instance. If :py:attr:`plugins` has been populated they should be plugin modules which will be registered with the PluginManager. """ args = self._ensure_basetemp(args) import _pytest.config config = _pytest.config._prepareconfig(args, self.plugins) # we don't know what the test will do with this half-setup config # object and thus we make sure it gets unconfigured properly in any # case (otherwise capturing could still be active, for example) self.request.addfinalizer(config._ensure_unconfigure) return config def parseconfigure(self, *args): """Return a new py.test configured Config instance. This returns a new :py:class:`_pytest.config.Config` instance like :py:meth:`parseconfig`, but also calls the pytest_configure hook. """ config = self.parseconfig(*args) config._do_configure() self.request.addfinalizer(config._ensure_unconfigure) return config def getitem(self, source, funcname="test_func"): """Return the test item for a test function. This writes the source to a python file and runs py.test's collection on the resulting module, returning the test item for the requested function name. :param source: The module source. :param funcname: The name of the test function for which the Item must be returned. """ items = self.getitems(source) for item in items: if item.name == funcname: return item assert 0, "%r item not found in module:\n%s\nitems: %s" %( funcname, source, items) def getitems(self, source): """Return all test items collected from the module. This writes the source to a python file and runs py.test's collection on the resulting module, returning all test items contained within. """ modcol = self.getmodulecol(source) return self.genitems([modcol]) def getmodulecol(self, source, configargs=(), withinit=False): """Return the module collection node for ``source``. This writes ``source`` to a file using :py:meth:`makepyfile` and then runs the py.test collection on it, returning the collection node for the test module. :param source: The source code of the module to collect. :param configargs: Any extra arguments to pass to :py:meth:`parseconfigure`. :param withinit: Whether to also write a ``__init__.py`` file to the temporarly directory to ensure it is a package. """ kw = {self.request.function.__name__: Source(source).strip()} path = self.makepyfile(**kw) if withinit: self.makepyfile(__init__ = "#") self.config = config = self.parseconfigure(path, *configargs) node = self.getnode(config, path) return node def collect_by_name(self, modcol, name): """Return the collection node for name from the module collection. This will search a module collection node for a collection node matching the given name. :param modcol: A module collection node, see :py:meth:`getmodulecol`. :param name: The name of the node to return. """ for colitem in modcol._memocollect(): if colitem.name == name: return colitem def popen(self, cmdargs, stdout, stderr, **kw): """Invoke subprocess.Popen. This calls subprocess.Popen making sure the current working directory is the PYTHONPATH. You probably want to use :py:meth:`run` instead. """ env = os.environ.copy() env['PYTHONPATH'] = os.pathsep.join(filter(None, [ str(os.getcwd()), env.get('PYTHONPATH', '')])) kw['env'] = env return subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw) def run(self, *cmdargs): """Run a command with arguments. Run a process using subprocess.Popen saving the stdout and stderr. Returns a :py:class:`RunResult`. """ return self._run(*cmdargs) def _run(self, *cmdargs): cmdargs = [str(x) for x in cmdargs] p1 = self.tmpdir.join("stdout") p2 = self.tmpdir.join("stderr") print_("running:", ' '.join(cmdargs)) print_(" in:", str(py.path.local())) f1 = codecs.open(str(p1), "w", encoding="utf8") f2 = codecs.open(str(p2), "w", encoding="utf8") try: now = time.time() popen = self.popen(cmdargs, stdout=f1, stderr=f2, close_fds=(sys.platform != "win32")) ret = popen.wait() finally: f1.close() f2.close() f1 = codecs.open(str(p1), "r", encoding="utf8") f2 = codecs.open(str(p2), "r", encoding="utf8") try: out = f1.read().splitlines() err = f2.read().splitlines() finally: f1.close() f2.close() self._dump_lines(out, sys.stdout) self._dump_lines(err, sys.stderr) return RunResult(ret, out, err, time.time()-now) def _dump_lines(self, lines, fp): try: for line in lines: py.builtin.print_(line, file=fp) except UnicodeEncodeError: print("couldn't print to %s because of encoding" % (fp,)) def _getpytestargs(self): # we cannot use "(sys.executable,script)" # because on windows the script is e.g. a py.test.exe return (sys.executable, _pytest_fullpath,) # noqa def runpython(self, script): """Run a python script using sys.executable as interpreter. Returns a :py:class:`RunResult`. """ return self.run(sys.executable, script) def runpython_c(self, command): """Run python -c "command", return a :py:class:`RunResult`.""" return self.run(sys.executable, "-c", command) def runpytest_subprocess(self, *args, **kwargs): """Run py.test as a subprocess with given arguments. Any plugins added to the :py:attr:`plugins` list will added using the ``-p`` command line option. Addtionally ``--basetemp`` is used put any temporary files and directories in a numbered directory prefixed with "runpytest-" so they do not conflict with the normal numberd pytest location for temporary files and directories. Returns a :py:class:`RunResult`. """ p = py.path.local.make_numbered_dir(prefix="runpytest-", keep=None, rootdir=self.tmpdir) args = ('--basetemp=%s' % p, ) + args #for x in args: # if '--confcutdir' in str(x): # break #else: # pass # args = ('--confcutdir=.',) + args plugins = [x for x in self.plugins if isinstance(x, str)] if plugins: args = ('-p', plugins[0]) + args args = self._getpytestargs() + args return self.run(*args) def spawn_pytest(self, string, expect_timeout=10.0): """Run py.test using pexpect. This makes sure to use the right py.test and sets up the temporary directory locations. The pexpect child is returned. """ basetemp = self.tmpdir.mkdir("pexpect") invoke = " ".join(map(str, self._getpytestargs())) cmd = "%s --basetemp=%s %s" % (invoke, basetemp, string) return self.spawn(cmd, expect_timeout=expect_timeout) def spawn(self, cmd, expect_timeout=10.0): """Run a command using pexpect. The pexpect child is returned. """ pexpect = pytest.importorskip("pexpect", "3.0") if hasattr(sys, 'pypy_version_info') and '64' in platform.machine(): pytest.skip("pypy-64 bit not supported") if sys.platform == "darwin": pytest.xfail("pexpect does not work reliably on darwin?!") if sys.platform.startswith("freebsd"): pytest.xfail("pexpect does not work reliably on freebsd") logfile = self.tmpdir.join("spawn.out").open("wb") child = pexpect.spawn(cmd, logfile=logfile) self.request.addfinalizer(logfile.close) child.timeout = expect_timeout return child def getdecoded(out): try: return out.decode("utf-8") except UnicodeDecodeError: return "INTERNAL not-utf8-decodeable, truncated string:\n%s" % ( py.io.saferepr(out),) class LineComp: def __init__(self): self.stringio = py.io.TextIO() def assert_contains_lines(self, lines2): """ assert that lines2 are contained (linearly) in lines1. return a list of extralines found. """ __tracebackhide__ = True val = self.stringio.getvalue() self.stringio.truncate(0) self.stringio.seek(0) lines1 = val.split("\n") return LineMatcher(lines1).fnmatch_lines(lines2) class LineMatcher: """Flexible matching of text. This is a convenience class to test large texts like the output of commands. The constructor takes a list of lines without their trailing newlines, i.e. ``text.splitlines()``. """ def __init__(self, lines): self.lines = lines def str(self): """Return the entire original text.""" return "\n".join(self.lines) def _getlines(self, lines2): if isinstance(lines2, str): lines2 = Source(lines2) if isinstance(lines2, Source): lines2 = lines2.strip().lines return lines2 def fnmatch_lines_random(self, lines2): """Check lines exist in the output. The argument is a list of lines which have to occur in the output, in any order. Each line can contain glob whildcards. """ lines2 = self._getlines(lines2) for line in lines2: for x in self.lines: if line == x or fnmatch(x, line): print_("matched: ", repr(line)) break else: raise ValueError("line %r not found in output" % line) def get_lines_after(self, fnline): """Return all lines following the given line in the text. The given line can contain glob wildcards. """ for i, line in enumerate(self.lines): if fnline == line or fnmatch(line, fnline): return self.lines[i+1:] raise ValueError("line %r not found in output" % fnline) def fnmatch_lines(self, lines2): """Search the text for matching lines. The argument is a list of lines which have to match and can use glob wildcards. If they do not match an pytest.fail() is called. The matches and non-matches are also printed on stdout. """ def show(arg1, arg2): py.builtin.print_(arg1, arg2, file=sys.stderr) lines2 = self._getlines(lines2) lines1 = self.lines[:] nextline = None extralines = [] __tracebackhide__ = True for line in lines2: nomatchprinted = False while lines1: nextline = lines1.pop(0) if line == nextline: show("exact match:", repr(line)) break elif fnmatch(nextline, line): show("fnmatch:", repr(line)) show(" with:", repr(nextline)) break else: if not nomatchprinted: show("nomatch:", repr(line)) nomatchprinted = True show(" and:", repr(nextline)) extralines.append(nextline) else: pytest.fail("remains unmatched: %r, see stderr" % (line,))
mpl-2.0
[ 624, 334, 7011, 701, 849, 9, 2291, 367, 5343, 4613, 436, 4613, 8963, 14, 408, 199, 646, 6010, 199, 646, 9486, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 504, 15951, 492, 15951, 199, 199, 504, 1134, 14, 5351, 492, 870, 63, 199, 199, 504, 485, 4462, 423, 600, 492, 5800, 199, 646, 1134, 199, 646, 4613, 199, 504, 485, 4462, 14, 973, 492, 8596, 12, 3651, 649, 63, 3593, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 327, 1572, 275, 1798, 14, 362, 923, 480, 647, 8234, 401, 298, 647, 8234, 334, 277, 13, 2219, 9, 1511, 531, 272, 1798, 14, 525, 1422, 4517, 478, 1618, 297, 1779, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 478, 1618, 401, 849, 29, 797, 12, 1779, 1720, 15387, 1065, 481, 36, 5920, 340, 9100, 1618, 365, 2808, 2237, 339, 1798, 14, 525, 1422, 4517, 19889, 297, 849, 628, 262, 1412, 401, 2053, 628, 19889, 401, 1779, 3415, 15387, 262, 1412, 401, 298, 5781, 401, 2318, 1779, 1720, 15387, 1065, 4613, 1007, 7858, 315, 2295, 1808, 376, 283, 262, 1412, 7, 298, 326, 298, 269, 283, 5781, 7, 334, 1548, 446, 77, 2446, 9, 1083, 2237, 421, 199, 318, 4613, 63, 6472, 8, 888, 304, 272, 327, 961, 5594, 506, 2797, 3663, 5431, 14, 5972, 5452, 314, 1642, 14, 272, 2288, 485, 4462, 63, 17943, 272, 862, 26, 267, 485, 4462, 63, 17943, 272, 871, 12746, 26, 267, 485, 4462, 63, 17943, 275, 747, 14, 515, 14, 4832, 8, 4462, 855, 493, 4343, 6735, 480, 679, 2237, 267, 485, 4462, 63, 17943, 275, 485, 4462, 63, 17943, 14, 1814, 21506, 647, 14, 533, 401, 3680, 647, 531, 339, 340, 1101, 14, 7150, 480, 478, 1618, 2349, 267, 7739, 275, 491, 1152, 70, 20689, 2553, 1151, 3048, 342, 267, 340, 7739, 14, 9467, 63, 3246, 837, 288, 1101, 14, 2718, 2609, 14, 2683, 8, 6743, 9, 421, 199, 533, 491, 1152, 70, 20689, 2553, 1151, 3048, 8, 785, 304, 272, 347, 664, 63, 1490, 63, 1725, 8, 277, 304, 267, 734, 275, 291, 423, 1628, 63, 478, 1618, 342, 267, 1551, 63, 1725, 275, 291, 423, 1122, 63, 478, 1618, 63, 1199, 8, 548, 9, 267, 372, 1551, 63, 1725, 339, 347, 485, 1628, 63, 478, 1618, 8, 277, 304, 267, 4422, 275, 747, 14, 17829, 342, 267, 372, 1134, 14, 1412, 14, 4400, 731, 825, 480, 478, 1618, 446, 38, 2324, 16, 446, 80, 450, 68, 2, 450, 4422, 9, 339, 347, 485, 1122, 63, 478, 1618, 63, 1199, 8, 277, 12, 734, 304, 267, 347, 365, 1490, 8, 604, 304, 288, 372, 1004, 14, 2460, 360, 70, 358, 436, 1689, 6062, 2, 440, 315, 1004, 436, 355, 283, 5286, 7, 440, 315, 1004, 436, 298, 2424, 2, 440, 315, 1004, 436, 283, 6525, 7, 440, 315, 1004, 9, 398, 1551, 63, 1725, 275, 942, 398, 367, 1004, 315, 734, 14, 1294, 4582, 78, 2349, 288, 340, 365, 1490, 8, 604, 304, 355, 1504, 275, 1004, 14, 1294, 2258, 16, 358, 355, 6111, 275, 1504, 59, 16, 1527, 17, 2938, 355, 1788, 275, 1504, 59, 17, 1527, 17, 2938, 355, 340, 1788, 14, 2460, 18265, 490, 1551, 63, 1725, 14, 740, 1332, 2592, 12, 1788, 430, 398, 372, 1551, 63, 1725, 339, 347, 4877, 63, 3246, 8, 277, 304, 267, 862, 26, 288, 1134, 14, 1412, 14, 4400, 731, 825, 480, 478, 1618, 446, 86, 531, 267, 871, 334, 647, 14, 1412, 14, 4400, 731, 825, 14, 547, 12, 18965, 304, 288, 327, 6904, 731, 825, 1443, 746, 18965, 641, 5417, 10460, 288, 327, 543, 5867, 1163, 2419, 20171, 1891, 26, 288, 327, 4178, 921, 25668, 14, 1308, 15, 4462, 13, 2374, 15, 647, 15, 10115, 15, 1272, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 768, 4462, 14, 3664, 5472, 8, 3664, 5029, 29, 549, 12, 862, 2246, 29, 549, 9, 272, 347, 4613, 63, 1065, 396, 63, 1053, 8, 277, 12, 1242, 304, 267, 2385, 17, 275, 291, 14, 362, 63, 1490, 63, 1725, 342, 267, 1995, 267, 340, 2688, 8, 1274, 12, 298, 20233, 63, 1023, 63, 815, 2349, 288, 9486, 14, 7112, 342, 267, 2385, 18, 275, 291, 14, 362, 63, 1490, 63, 1725, 342, 398, 892, 63, 14240, 275, 663, 779, 84, 59, 16, 61, 367, 307, 315, 2385, 18, 566, 446, 663, 779, 84, 59, 16, 61, 367, 307, 315, 2385, 17, 566, 267, 1026, 16702, 63, 1725, 275, 359, 84, 367, 307, 315, 2385, 18, 340, 307, 59, 16, 61, 315, 892, 63, 14240, 61, 267, 340, 1026, 16702, 63, 1725, 26, 288, 1125, 275, 942, 288, 1125, 14, 740, 480, 1116, 10, 450, 83, 481, 36, 25831, 474, 10501, 2, 450, 822, 8, 274, 16702, 63, 1725, 430, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 1026, 16702, 63, 1725, 566, 288, 1125, 14, 740, 480, 9153, 21467, 9107, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 2385, 17, 566, 288, 1125, 14, 740, 480, 9153, 12836, 9107, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 2385, 18, 566, 288, 1125, 14, 740, 8, 705, 59, 16, 566, 288, 1125, 14, 740, 480, 9153, 805, 450, 83, 2689, 83, 26, 450, 83, 298, 450, 1242, 14, 1985, 9, 288, 4613, 14, 1633, 4582, 78, 1674, 904, 8, 705, 395, 1134, 3446, 29, 797, 9, 421, 199, 3, 5787, 8876, 687, 2146, 846, 1159, 3743, 396, 14, 647, 446, 4839, 370, 506, 9545, 199, 2676, 647, 1130, 275, 469, 272, 283, 1548, 18, 14, 23, 356, 519, 7, 35, 3427, 4718, 1465, 60, 1548, 14, 5803, 297, 272, 283, 1548, 18, 14, 22, 356, 519, 7, 35, 3427, 4718, 1479, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 17, 356, 519, 7, 35, 3427, 4718, 2192, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 18, 356, 519, 7, 35, 3427, 4718, 708, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 19, 356, 519, 7, 35, 3427, 4718, 1153, 60, 1548, 14, 5803 ]
[ 334, 7011, 701, 849, 9, 2291, 367, 5343, 4613, 436, 4613, 8963, 14, 408, 199, 646, 6010, 199, 646, 9486, 199, 646, 747, 199, 646, 4298, 199, 646, 295, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 646, 5190, 199, 504, 15951, 492, 15951, 199, 199, 504, 1134, 14, 5351, 492, 870, 63, 199, 199, 504, 485, 4462, 423, 600, 492, 5800, 199, 646, 1134, 199, 646, 4613, 199, 504, 485, 4462, 14, 973, 492, 8596, 12, 3651, 649, 63, 3593, 421, 199, 318, 4613, 63, 525, 1422, 8, 2087, 304, 272, 327, 1572, 275, 1798, 14, 362, 923, 480, 647, 8234, 401, 298, 647, 8234, 334, 277, 13, 2219, 9, 1511, 531, 272, 1798, 14, 525, 1422, 4517, 478, 1618, 297, 1779, 1595, 628, 1617, 63, 2052, 401, 2053, 628, 478, 1618, 401, 849, 29, 797, 12, 1779, 1720, 15387, 1065, 481, 36, 5920, 340, 9100, 1618, 365, 2808, 2237, 339, 1798, 14, 525, 1422, 4517, 19889, 297, 849, 628, 262, 1412, 401, 2053, 628, 19889, 401, 1779, 3415, 15387, 262, 1412, 401, 298, 5781, 401, 2318, 1779, 1720, 15387, 1065, 4613, 1007, 7858, 315, 2295, 1808, 376, 283, 262, 1412, 7, 298, 326, 298, 269, 283, 5781, 7, 334, 1548, 446, 77, 2446, 9, 1083, 2237, 421, 199, 318, 4613, 63, 6472, 8, 888, 304, 272, 327, 961, 5594, 506, 2797, 3663, 5431, 14, 5972, 5452, 314, 1642, 14, 272, 2288, 485, 4462, 63, 17943, 272, 862, 26, 267, 485, 4462, 63, 17943, 272, 871, 12746, 26, 267, 485, 4462, 63, 17943, 275, 747, 14, 515, 14, 4832, 8, 4462, 855, 493, 4343, 6735, 480, 679, 2237, 267, 485, 4462, 63, 17943, 275, 485, 4462, 63, 17943, 14, 1814, 21506, 647, 14, 533, 401, 3680, 647, 531, 339, 340, 1101, 14, 7150, 480, 478, 1618, 2349, 267, 7739, 275, 491, 1152, 70, 20689, 2553, 1151, 3048, 342, 267, 340, 7739, 14, 9467, 63, 3246, 837, 288, 1101, 14, 2718, 2609, 14, 2683, 8, 6743, 9, 421, 199, 533, 491, 1152, 70, 20689, 2553, 1151, 3048, 8, 785, 304, 272, 347, 664, 63, 1490, 63, 1725, 8, 277, 304, 267, 734, 275, 291, 423, 1628, 63, 478, 1618, 342, 267, 1551, 63, 1725, 275, 291, 423, 1122, 63, 478, 1618, 63, 1199, 8, 548, 9, 267, 372, 1551, 63, 1725, 339, 347, 485, 1628, 63, 478, 1618, 8, 277, 304, 267, 4422, 275, 747, 14, 17829, 342, 267, 372, 1134, 14, 1412, 14, 4400, 731, 825, 480, 478, 1618, 446, 38, 2324, 16, 446, 80, 450, 68, 2, 450, 4422, 9, 339, 347, 485, 1122, 63, 478, 1618, 63, 1199, 8, 277, 12, 734, 304, 267, 347, 365, 1490, 8, 604, 304, 288, 372, 1004, 14, 2460, 360, 70, 358, 436, 1689, 6062, 2, 440, 315, 1004, 436, 355, 283, 5286, 7, 440, 315, 1004, 436, 298, 2424, 2, 440, 315, 1004, 436, 283, 6525, 7, 440, 315, 1004, 9, 398, 1551, 63, 1725, 275, 942, 398, 367, 1004, 315, 734, 14, 1294, 4582, 78, 2349, 288, 340, 365, 1490, 8, 604, 304, 355, 1504, 275, 1004, 14, 1294, 2258, 16, 358, 355, 6111, 275, 1504, 59, 16, 1527, 17, 2938, 355, 1788, 275, 1504, 59, 17, 1527, 17, 2938, 355, 340, 1788, 14, 2460, 18265, 490, 1551, 63, 1725, 14, 740, 1332, 2592, 12, 1788, 430, 398, 372, 1551, 63, 1725, 339, 347, 4877, 63, 3246, 8, 277, 304, 267, 862, 26, 288, 1134, 14, 1412, 14, 4400, 731, 825, 480, 478, 1618, 446, 86, 531, 267, 871, 334, 647, 14, 1412, 14, 4400, 731, 825, 14, 547, 12, 18965, 304, 288, 327, 6904, 731, 825, 1443, 746, 18965, 641, 5417, 10460, 288, 327, 543, 5867, 1163, 2419, 20171, 1891, 26, 288, 327, 4178, 921, 25668, 14, 1308, 15, 4462, 13, 2374, 15, 647, 15, 10115, 15, 1272, 288, 372, 756, 267, 587, 26, 288, 372, 715, 339, 768, 4462, 14, 3664, 5472, 8, 3664, 5029, 29, 549, 12, 862, 2246, 29, 549, 9, 272, 347, 4613, 63, 1065, 396, 63, 1053, 8, 277, 12, 1242, 304, 267, 2385, 17, 275, 291, 14, 362, 63, 1490, 63, 1725, 342, 267, 1995, 267, 340, 2688, 8, 1274, 12, 298, 20233, 63, 1023, 63, 815, 2349, 288, 9486, 14, 7112, 342, 267, 2385, 18, 275, 291, 14, 362, 63, 1490, 63, 1725, 342, 398, 892, 63, 14240, 275, 663, 779, 84, 59, 16, 61, 367, 307, 315, 2385, 18, 566, 446, 663, 779, 84, 59, 16, 61, 367, 307, 315, 2385, 17, 566, 267, 1026, 16702, 63, 1725, 275, 359, 84, 367, 307, 315, 2385, 18, 340, 307, 59, 16, 61, 315, 892, 63, 14240, 61, 267, 340, 1026, 16702, 63, 1725, 26, 288, 1125, 275, 942, 288, 1125, 14, 740, 480, 1116, 10, 450, 83, 481, 36, 25831, 474, 10501, 2, 450, 822, 8, 274, 16702, 63, 1725, 430, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 1026, 16702, 63, 1725, 566, 288, 1125, 14, 740, 480, 9153, 21467, 9107, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 2385, 17, 566, 288, 1125, 14, 740, 480, 9153, 12836, 9107, 288, 1125, 14, 2880, 779, 495, 8, 70, 9, 367, 289, 315, 2385, 18, 566, 288, 1125, 14, 740, 8, 705, 59, 16, 566, 288, 1125, 14, 740, 480, 9153, 805, 450, 83, 2689, 83, 26, 450, 83, 298, 450, 1242, 14, 1985, 9, 288, 4613, 14, 1633, 4582, 78, 1674, 904, 8, 705, 395, 1134, 3446, 29, 797, 9, 421, 199, 3, 5787, 8876, 687, 2146, 846, 1159, 3743, 396, 14, 647, 446, 4839, 370, 506, 9545, 199, 2676, 647, 1130, 275, 469, 272, 283, 1548, 18, 14, 23, 356, 519, 7, 35, 3427, 4718, 1465, 60, 1548, 14, 5803, 297, 272, 283, 1548, 18, 14, 22, 356, 519, 7, 35, 3427, 4718, 1479, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 17, 356, 519, 7, 35, 3427, 4718, 2192, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 18, 356, 519, 7, 35, 3427, 4718, 708, 60, 1548, 14, 5803, 297, 272, 283, 1548, 19, 14, 19, 356, 519, 7, 35, 3427, 4718, 1153, 60, 1548, 14, 5803, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
xinjiguaike/edx-platform
lms/djangoapps/shoppingcart/admin.py
102
5401
"""Django admin interface for the shopping cart models. """ from ratelimitbackend import admin from shoppingcart.models import ( PaidCourseRegistrationAnnotation, Coupon, DonationConfiguration, Invoice, CourseRegistrationCodeInvoiceItem, InvoiceTransaction ) class SoftDeleteCouponAdmin(admin.ModelAdmin): """ Admin for the Coupon table. soft-delete on the coupons """ fields = ('code', 'description', 'course_id', 'percentage_discount', 'created_by', 'created_at', 'is_active') raw_id_fields = ("created_by",) readonly_fields = ('created_at',) actions = ['really_delete_selected'] def queryset(self, request): """ Returns a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view. """ # Default: qs = self.model._default_manager.get_active_coupons_query_set() # Queryset with all the coupons including the soft-deletes: qs = self.model._default_manager.get_query_set() query_string = self.model._default_manager.get_active_coupons_query_set() # pylint: disable=protected-access return query_string def get_actions(self, request): actions = super(SoftDeleteCouponAdmin, self).get_actions(request) del actions['delete_selected'] return actions def really_delete_selected(self, request, queryset): """override the default behavior of selected delete method""" for obj in queryset: obj.is_active = False obj.save() if queryset.count() == 1: message_bit = "1 coupon entry was" else: message_bit = "%s coupon entries were" % queryset.count() self.message_user(request, "%s successfully deleted." % message_bit) def delete_model(self, request, obj): """override the default behavior of single instance of model delete method""" obj.is_active = False obj.save() really_delete_selected.short_description = "Delete s selected entries" class CourseRegistrationCodeInvoiceItemInline(admin.StackedInline): """Admin for course registration code invoice items. Displayed inline within the invoice admin UI. """ model = CourseRegistrationCodeInvoiceItem extra = 0 can_delete = False readonly_fields = ( 'qty', 'unit_price', 'currency', 'course_id', ) def has_add_permission(self, request): return False class InvoiceTransactionInline(admin.StackedInline): """Admin for invoice transactions. Displayed inline within the invoice admin UI. """ model = InvoiceTransaction extra = 0 readonly_fields = ( 'created', 'modified', 'created_by', 'last_modified_by' ) class InvoiceAdmin(admin.ModelAdmin): """Admin for invoices. This is intended for the internal finance team to be able to view and update invoice information, including payments and refunds. """ date_hierarchy = 'created' can_delete = False readonly_fields = ('created', 'modified') search_fields = ( 'internal_reference', 'customer_reference_number', 'company_name', ) fieldsets = ( ( None, { 'fields': ( 'internal_reference', 'customer_reference_number', 'created', 'modified', ) } ), ( 'Billing Information', { 'fields': ( 'company_name', 'company_contact_name', 'company_contact_email', 'recipient_name', 'recipient_email', 'address_line_1', 'address_line_2', 'address_line_3', 'city', 'state', 'zip', 'country' ) } ) ) readonly_fields = ( 'internal_reference', 'customer_reference_number', 'created', 'modified', 'company_name', 'company_contact_name', 'company_contact_email', 'recipient_name', 'recipient_email', 'address_line_1', 'address_line_2', 'address_line_3', 'city', 'state', 'zip', 'country' ) inlines = [ CourseRegistrationCodeInvoiceItemInline, InvoiceTransactionInline ] def save_formset(self, request, form, formset, change): """Save the user who created and modified invoice transactions. """ instances = formset.save(commit=False) for instance in instances: if isinstance(instance, InvoiceTransaction): if not hasattr(instance, 'created_by'): instance.created_by = request.user instance.last_modified_by = request.user instance.save() def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False admin.site.register(PaidCourseRegistrationAnnotation) admin.site.register(Coupon, SoftDeleteCouponAdmin) admin.site.register(DonationConfiguration) admin.site.register(Invoice, InvoiceAdmin)
agpl-3.0
[ 624, 9323, 4628, 3217, 367, 314, 25630, 4073, 16942, 1709, 14, 408, 199, 504, 6634, 3097, 4620, 492, 4628, 199, 504, 25630, 4073, 8153, 14, 992, 492, 334, 272, 10164, 344, 6979, 11757, 16768, 12, 272, 1849, 13527, 12, 272, 7529, 425, 5688, 12, 272, 19868, 12, 272, 5531, 11757, 3034, 21092, 2081, 12, 272, 19868, 10161, 199, 9, 421, 199, 533, 27238, 5392, 967, 13527, 4880, 8, 2113, 14, 12976, 304, 272, 408, 272, 9516, 367, 314, 1849, 13527, 1817, 14, 272, 11620, 13, 1807, 641, 314, 512, 384, 4654, 272, 408, 272, 1504, 275, 661, 600, 297, 283, 1802, 297, 283, 1972, 63, 344, 297, 283, 14200, 63, 15446, 297, 283, 3966, 63, 991, 297, 283, 3966, 63, 292, 297, 283, 374, 63, 2682, 358, 272, 3066, 63, 344, 63, 955, 275, 1689, 3966, 63, 991, 26360, 272, 6863, 63, 955, 275, 661, 3966, 63, 292, 9538, 272, 5445, 275, 788, 29428, 63, 1807, 63, 5511, 418, 339, 347, 7594, 8, 277, 12, 1056, 304, 267, 408, 1803, 282, 18397, 402, 1006, 1402, 4454, 626, 883, 506, 21062, 701, 314, 267, 4628, 4770, 14, 961, 365, 1202, 701, 27579, 63, 1345, 14, 408, 267, 327, 3758, 26, 6377, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 2682, 63, 331, 384, 4654, 63, 1131, 63, 409, 342, 267, 327, 8133, 409, 543, 1006, 314, 512, 384, 4654, 5893, 314, 11620, 13, 26289, 26, 6377, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 1131, 63, 409, 342, 267, 1827, 63, 875, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 2682, 63, 331, 384, 4654, 63, 1131, 63, 409, 342, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 372, 1827, 63, 875, 339, 347, 664, 63, 3723, 8, 277, 12, 1056, 304, 267, 5445, 275, 1613, 8, 19302, 5392, 967, 13527, 4880, 12, 291, 680, 362, 63, 3723, 8, 1069, 9, 267, 2150, 5445, 459, 1807, 63, 5511, 418, 267, 372, 5445, 339, 347, 7710, 63, 1807, 63, 5511, 8, 277, 12, 1056, 12, 7594, 304, 267, 408, 4415, 314, 849, 5953, 402, 4895, 3145, 1083, 624, 267, 367, 1559, 315, 7594, 26, 288, 1559, 14, 374, 63, 2682, 275, 756, 288, 1559, 14, 2117, 342, 398, 340, 7594, 14, 835, 342, 508, 413, 26, 288, 1245, 63, 2075, 275, 298, 17, 29054, 2397, 1990, 2, 267, 587, 26, 288, 1245, 63, 2075, 275, 2071, 83, 29054, 4811, 4898, 2, 450, 7594, 14, 835, 342, 267, 291, 14, 1188, 63, 751, 8, 1069, 12, 2071, 83, 8792, 5463, 2122, 450, 1245, 63, 2075, 9, 339, 347, 3145, 63, 1238, 8, 277, 12, 1056, 12, 1559, 304, 267, 408, 4415, 314, 849, 5953, 402, 2849, 1256, 402, 1402, 3145, 1083, 624, 267, 1559, 14, 374, 63, 2682, 275, 756, 267, 1559, 14, 2117, 342, 339, 7710, 63, 1807, 63, 5511, 14, 3612, 63, 1802, 275, 298, 5392, 308, 4895, 4811, 2, 421, 199, 533, 5531, 11757, 3034, 21092, 2081, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 272, 408, 4880, 367, 2518, 10991, 1233, 8485, 2974, 14, 339, 12175, 379, 8308, 4453, 314, 8485, 4628, 14041, 14, 272, 408, 272, 1402, 275, 5531, 11757, 3034, 21092, 2081, 272, 2402, 275, 378, 272, 883, 63, 1807, 275, 756, 272, 6863, 63, 955, 275, 334, 267, 283, 5643, 297, 267, 283, 3248, 63, 4777, 297, 267, 283, 4968, 297, 267, 283, 1972, 63, 344, 297, 272, 776, 339, 347, 965, 63, 525, 63, 5693, 8, 277, 12, 1056, 304, 267, 372, 756, 421, 199, 533, 19868, 10161, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 272, 408, 4880, 367, 8485, 15809, 14, 339, 12175, 379, 8308, 4453, 314, 8485, 4628, 14041, 14, 272, 408, 272, 1402, 275, 19868, 10161, 272, 2402, 275, 378, 272, 6863, 63, 955, 275, 334, 267, 283, 3966, 297, 267, 283, 5540, 297, 267, 283, 3966, 63, 991, 297, 267, 283, 2019, 63, 5540, 63, 991, 7, 272, 776, 421, 199, 533, 19868, 4880, 8, 2113, 14, 12976, 304, 272, 408, 4880, 367, 26175, 14, 339, 961, 365, 11619, 367, 314, 5007, 2583, 554, 8099, 272, 370, 506, 7688, 370, 2455, 436, 1678, 8485, 2556, 12, 272, 5893, 8633, 1470, 436, 32219, 83, 14, 339, 408, 272, 1434, 63, 14861, 275, 283, 3966, 7, 272, 883, 63, 1807, 275, 756, 272, 6863, 63, 955, 275, 661, 3966, 297, 283, 5540, 358, 272, 2754, 63, 955, 275, 334, 267, 283, 4672, 63, 4443, 297, 267, 283, 10178, 63, 4443, 63, 1955, 297, 267, 283, 4627, 63, 354, 297, 272, 776, 272, 901, 2193, 275, 334, 267, 334, 288, 488, 12, 469, 355, 283, 955, 356, 334, 490, 283, 4672, 63, 4443, 297, 490, 283, 10178, 63, 4443, 63, 1955, 297, 490, 283, 3966, 297, 490, 283, 5540, 297, 355, 776, 288, 789, 267, 2318, 267, 334, 288, 283, 34, 12687, 17064, 297, 469, 355, 283, 955, 356, 334, 490, 283, 4627, 63, 354, 297, 490, 283, 4627, 63, 7811, 63, 354, 297, 490, 283, 4627, 63, 7811, 63, 2123, 297, 490, 283, 10043, 63, 354, 297, 490, 283, 10043, 63, 2123, 297, 490, 283, 1562, 63, 604, 63, 17, 297, 490, 283, 1562, 63, 604, 63, 18, 297, 490, 283, 1562, 63, 604, 63, 19, 297, 490, 283, 3690, 297, 490, 283, 929, 297, 490, 283, 3065, 297, 490, 283, 6063, 7, 355, 776, 288, 789, 267, 776, 272, 776, 272, 6863, 63, 955, 275, 334, 267, 283, 4672, 63, 4443, 297, 267, 283, 10178, 63, 4443, 63, 1955, 297, 267, 283, 3966, 297, 267, 283, 5540, 297, 267, 283, 4627, 63, 354, 297, 267, 283, 4627, 63, 7811, 63, 354, 297, 267, 283, 4627, 63, 7811, 63, 2123, 297, 267, 283, 10043, 63, 354, 297, 267, 283, 10043, 63, 2123, 297, 267, 283, 1562, 63, 604, 63, 17, 297, 267, 283, 1562, 63, 604, 63, 18, 297, 267, 283, 1562, 63, 604, 63, 19, 297, 267, 283, 3690, 297, 267, 283, 929, 297, 267, 283, 3065, 297, 267, 283, 6063, 7, 272, 776, 272, 29177, 275, 359, 267, 5531, 11757, 3034, 21092, 2081, 10307, 12, 267, 19868, 10161, 10307, 272, 1622, 339, 347 ]
[ 9323, 4628, 3217, 367, 314, 25630, 4073, 16942, 1709, 14, 408, 199, 504, 6634, 3097, 4620, 492, 4628, 199, 504, 25630, 4073, 8153, 14, 992, 492, 334, 272, 10164, 344, 6979, 11757, 16768, 12, 272, 1849, 13527, 12, 272, 7529, 425, 5688, 12, 272, 19868, 12, 272, 5531, 11757, 3034, 21092, 2081, 12, 272, 19868, 10161, 199, 9, 421, 199, 533, 27238, 5392, 967, 13527, 4880, 8, 2113, 14, 12976, 304, 272, 408, 272, 9516, 367, 314, 1849, 13527, 1817, 14, 272, 11620, 13, 1807, 641, 314, 512, 384, 4654, 272, 408, 272, 1504, 275, 661, 600, 297, 283, 1802, 297, 283, 1972, 63, 344, 297, 283, 14200, 63, 15446, 297, 283, 3966, 63, 991, 297, 283, 3966, 63, 292, 297, 283, 374, 63, 2682, 358, 272, 3066, 63, 344, 63, 955, 275, 1689, 3966, 63, 991, 26360, 272, 6863, 63, 955, 275, 661, 3966, 63, 292, 9538, 272, 5445, 275, 788, 29428, 63, 1807, 63, 5511, 418, 339, 347, 7594, 8, 277, 12, 1056, 304, 267, 408, 1803, 282, 18397, 402, 1006, 1402, 4454, 626, 883, 506, 21062, 701, 314, 267, 4628, 4770, 14, 961, 365, 1202, 701, 27579, 63, 1345, 14, 408, 267, 327, 3758, 26, 6377, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 2682, 63, 331, 384, 4654, 63, 1131, 63, 409, 342, 267, 327, 8133, 409, 543, 1006, 314, 512, 384, 4654, 5893, 314, 11620, 13, 26289, 26, 6377, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 1131, 63, 409, 342, 267, 1827, 63, 875, 275, 291, 14, 1238, 423, 885, 63, 2609, 14, 362, 63, 2682, 63, 331, 384, 4654, 63, 1131, 63, 409, 342, 221, 327, 4287, 26, 3507, 29, 6798, 13, 2732, 267, 372, 1827, 63, 875, 339, 347, 664, 63, 3723, 8, 277, 12, 1056, 304, 267, 5445, 275, 1613, 8, 19302, 5392, 967, 13527, 4880, 12, 291, 680, 362, 63, 3723, 8, 1069, 9, 267, 2150, 5445, 459, 1807, 63, 5511, 418, 267, 372, 5445, 339, 347, 7710, 63, 1807, 63, 5511, 8, 277, 12, 1056, 12, 7594, 304, 267, 408, 4415, 314, 849, 5953, 402, 4895, 3145, 1083, 624, 267, 367, 1559, 315, 7594, 26, 288, 1559, 14, 374, 63, 2682, 275, 756, 288, 1559, 14, 2117, 342, 398, 340, 7594, 14, 835, 342, 508, 413, 26, 288, 1245, 63, 2075, 275, 298, 17, 29054, 2397, 1990, 2, 267, 587, 26, 288, 1245, 63, 2075, 275, 2071, 83, 29054, 4811, 4898, 2, 450, 7594, 14, 835, 342, 267, 291, 14, 1188, 63, 751, 8, 1069, 12, 2071, 83, 8792, 5463, 2122, 450, 1245, 63, 2075, 9, 339, 347, 3145, 63, 1238, 8, 277, 12, 1056, 12, 1559, 304, 267, 408, 4415, 314, 849, 5953, 402, 2849, 1256, 402, 1402, 3145, 1083, 624, 267, 1559, 14, 374, 63, 2682, 275, 756, 267, 1559, 14, 2117, 342, 339, 7710, 63, 1807, 63, 5511, 14, 3612, 63, 1802, 275, 298, 5392, 308, 4895, 4811, 2, 421, 199, 533, 5531, 11757, 3034, 21092, 2081, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 272, 408, 4880, 367, 2518, 10991, 1233, 8485, 2974, 14, 339, 12175, 379, 8308, 4453, 314, 8485, 4628, 14041, 14, 272, 408, 272, 1402, 275, 5531, 11757, 3034, 21092, 2081, 272, 2402, 275, 378, 272, 883, 63, 1807, 275, 756, 272, 6863, 63, 955, 275, 334, 267, 283, 5643, 297, 267, 283, 3248, 63, 4777, 297, 267, 283, 4968, 297, 267, 283, 1972, 63, 344, 297, 272, 776, 339, 347, 965, 63, 525, 63, 5693, 8, 277, 12, 1056, 304, 267, 372, 756, 421, 199, 533, 19868, 10161, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 272, 408, 4880, 367, 8485, 15809, 14, 339, 12175, 379, 8308, 4453, 314, 8485, 4628, 14041, 14, 272, 408, 272, 1402, 275, 19868, 10161, 272, 2402, 275, 378, 272, 6863, 63, 955, 275, 334, 267, 283, 3966, 297, 267, 283, 5540, 297, 267, 283, 3966, 63, 991, 297, 267, 283, 2019, 63, 5540, 63, 991, 7, 272, 776, 421, 199, 533, 19868, 4880, 8, 2113, 14, 12976, 304, 272, 408, 4880, 367, 26175, 14, 339, 961, 365, 11619, 367, 314, 5007, 2583, 554, 8099, 272, 370, 506, 7688, 370, 2455, 436, 1678, 8485, 2556, 12, 272, 5893, 8633, 1470, 436, 32219, 83, 14, 339, 408, 272, 1434, 63, 14861, 275, 283, 3966, 7, 272, 883, 63, 1807, 275, 756, 272, 6863, 63, 955, 275, 661, 3966, 297, 283, 5540, 358, 272, 2754, 63, 955, 275, 334, 267, 283, 4672, 63, 4443, 297, 267, 283, 10178, 63, 4443, 63, 1955, 297, 267, 283, 4627, 63, 354, 297, 272, 776, 272, 901, 2193, 275, 334, 267, 334, 288, 488, 12, 469, 355, 283, 955, 356, 334, 490, 283, 4672, 63, 4443, 297, 490, 283, 10178, 63, 4443, 63, 1955, 297, 490, 283, 3966, 297, 490, 283, 5540, 297, 355, 776, 288, 789, 267, 2318, 267, 334, 288, 283, 34, 12687, 17064, 297, 469, 355, 283, 955, 356, 334, 490, 283, 4627, 63, 354, 297, 490, 283, 4627, 63, 7811, 63, 354, 297, 490, 283, 4627, 63, 7811, 63, 2123, 297, 490, 283, 10043, 63, 354, 297, 490, 283, 10043, 63, 2123, 297, 490, 283, 1562, 63, 604, 63, 17, 297, 490, 283, 1562, 63, 604, 63, 18, 297, 490, 283, 1562, 63, 604, 63, 19, 297, 490, 283, 3690, 297, 490, 283, 929, 297, 490, 283, 3065, 297, 490, 283, 6063, 7, 355, 776, 288, 789, 267, 776, 272, 776, 272, 6863, 63, 955, 275, 334, 267, 283, 4672, 63, 4443, 297, 267, 283, 10178, 63, 4443, 63, 1955, 297, 267, 283, 3966, 297, 267, 283, 5540, 297, 267, 283, 4627, 63, 354, 297, 267, 283, 4627, 63, 7811, 63, 354, 297, 267, 283, 4627, 63, 7811, 63, 2123, 297, 267, 283, 10043, 63, 354, 297, 267, 283, 10043, 63, 2123, 297, 267, 283, 1562, 63, 604, 63, 17, 297, 267, 283, 1562, 63, 604, 63, 18, 297, 267, 283, 1562, 63, 604, 63, 19, 297, 267, 283, 3690, 297, 267, 283, 929, 297, 267, 283, 3065, 297, 267, 283, 6063, 7, 272, 776, 272, 29177, 275, 359, 267, 5531, 11757, 3034, 21092, 2081, 10307, 12, 267, 19868, 10161, 10307, 272, 1622, 339, 347, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
abhishekgahlot/youtube-dl
youtube_dl/extractor/krasview.py
85
1958
# encoding: utf-8 from __future__ import unicode_literals import json from .common import InfoExtractor from ..utils import ( int_or_none, js_to_json, ) class KrasViewIE(InfoExtractor): IE_DESC = 'Красвью' _VALID_URL = r'https?://krasview\.ru/(?:video|embed)/(?P<id>\d+)' _TEST = { 'url': 'http://krasview.ru/video/512228', 'md5': '3b91003cf85fc5db277870c8ebd98eae', 'info_dict': { 'id': '512228', 'ext': 'mp4', 'title': 'Снег, лёд, заносы', 'description': 'Снято в городе Нягань, в Ханты-Мансийском автономном округе.', 'duration': 27, 'thumbnail': 're:^https?://.*\.jpg', }, 'params': { 'skip_download': 'Not accessible from Travis CI server', }, } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) flashvars = json.loads(js_to_json(self._search_regex( r'video_Init\(({.+?})', webpage, 'flashvars'))) video_url = flashvars['url'] title = self._og_search_title(webpage) description = self._og_search_description(webpage, default=None) thumbnail = flashvars.get('image') or self._og_search_thumbnail(webpage) duration = int_or_none(flashvars.get('duration')) width = int_or_none(self._og_search_property( 'video:width', webpage, 'video width', default=None)) height = int_or_none(self._og_search_property( 'video:height', webpage, 'video height', default=None)) return { 'id': video_id, 'url': video_url, 'title': title, 'description': description, 'thumbnail': thumbnail, 'duration': duration, 'width': width, 'height': height, }
unlicense
[ 3, 2644, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 8586, 63, 475, 63, 1001, 12, 199, 9, 421, 199, 533, 1804, 6360, 2768, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 141, 249, 7753, 5657, 8474, 19630, 16961, 31235, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 75, 6360, 1345, 4537, 6558, 32576, 3722, 92, 6427, 2447, 2229, 48, 28, 344, 3072, 68, 29600, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 75, 6360, 1345, 14, 6558, 15, 3722, 15, 7736, 12048, 297, 267, 283, 1064, 21, 356, 283, 19, 66, 25, 1960, 19, 2177, 2426, 3003, 21, 697, 9963, 15790, 67, 24, 2871, 68, 2905, 69, 3624, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7736, 12048, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 95, 7592, 15578, 112, 12, 7038, 120, 142, 240, 20497, 12, 7038, 116, 21674, 5806, 8474, 17445, 297, 288, 283, 1802, 356, 283, 141, 95, 7592, 14978, 7413, 5806, 22213, 7038, 112, 26438, 28711, 6286, 7038, 252, 14978, 141, 112, 21674, 16961, 12, 22213, 7038, 99, 21674, 7413, 17445, 13, 141, 251, 21674, 8474, 16863, 118, 8474, 11487, 32334, 221, 13111, 111, 7413, 5806, 7592, 32334, 7592, 32334, 221, 8381, 119, 7753, 12195, 141, 112, 6286, 3130, 288, 283, 5553, 356, 8087, 12, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 1763, 17909, 687, 12643, 5068, 445, 41, 1654, 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, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 14775, 2936, 275, 2022, 14, 3640, 8, 3596, 63, 475, 63, 1001, 8, 277, 423, 1733, 63, 3821, 8, 288, 519, 7, 3722, 63, 9346, 60, 1332, 91, 11198, 25583, 9248, 12, 283, 11331, 2936, 7058, 398, 3991, 63, 633, 275, 14775, 2936, 459, 633, 418, 267, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 29, 403, 9, 267, 10062, 275, 14775, 2936, 14, 362, 360, 1569, 358, 503, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 7373, 275, 1109, 63, 269, 63, 3592, 8, 11331, 2936, 14, 362, 360, 5553, 1333, 267, 3462, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 2063, 297, 9248, 12, 283, 3722, 3462, 297, 849, 29, 403, 430, 267, 4569, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 3333, 297, 9248, 12, 283, 3722, 4569, 297, 849, 29, 403, 430, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 2063, 356, 3462, 12, 288, 283, 3333, 356, 4569, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 646, 2022, 199, 199, 504, 1275, 2330, 492, 21298, 199, 504, 2508, 1208, 492, 334, 272, 1109, 63, 269, 63, 3592, 12, 272, 8586, 63, 475, 63, 1001, 12, 199, 9, 421, 199, 533, 1804, 6360, 2768, 4332, 8, 18283, 304, 272, 15292, 63, 15119, 275, 283, 141, 249, 7753, 5657, 8474, 19630, 16961, 31235, 7, 272, 485, 5600, 63, 2632, 275, 519, 7, 2859, 14144, 75, 6360, 1345, 4537, 6558, 32576, 3722, 92, 6427, 2447, 2229, 48, 28, 344, 3072, 68, 29600, 339, 485, 2864, 275, 469, 267, 283, 633, 356, 283, 1014, 921, 75, 6360, 1345, 14, 6558, 15, 3722, 15, 7736, 12048, 297, 267, 283, 1064, 21, 356, 283, 19, 66, 25, 1960, 19, 2177, 2426, 3003, 21, 697, 9963, 15790, 67, 24, 2871, 68, 2905, 69, 3624, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7736, 12048, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 141, 95, 7592, 15578, 112, 12, 7038, 120, 142, 240, 20497, 12, 7038, 116, 21674, 5806, 8474, 17445, 297, 288, 283, 1802, 356, 283, 141, 95, 7592, 14978, 7413, 5806, 22213, 7038, 112, 26438, 28711, 6286, 7038, 252, 14978, 141, 112, 21674, 16961, 12, 22213, 7038, 99, 21674, 7413, 17445, 13, 141, 251, 21674, 8474, 16863, 118, 8474, 11487, 32334, 221, 13111, 111, 7413, 5806, 7592, 32334, 7592, 32334, 221, 8381, 119, 7753, 12195, 141, 112, 6286, 3130, 288, 283, 5553, 356, 8087, 12, 288, 283, 8311, 356, 283, 264, 23497, 2859, 32569, 8476, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 283, 1763, 17909, 687, 12643, 5068, 445, 41, 1654, 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, 9248, 275, 291, 423, 4249, 63, 12022, 8, 633, 12, 3991, 63, 344, 9, 398, 14775, 2936, 275, 2022, 14, 3640, 8, 3596, 63, 475, 63, 1001, 8, 277, 423, 1733, 63, 3821, 8, 288, 519, 7, 3722, 63, 9346, 60, 1332, 91, 11198, 25583, 9248, 12, 283, 11331, 2936, 7058, 398, 3991, 63, 633, 275, 14775, 2936, 459, 633, 418, 267, 2538, 275, 291, 423, 974, 63, 1733, 63, 1213, 8, 12022, 9, 267, 1369, 275, 291, 423, 974, 63, 1733, 63, 1802, 8, 12022, 12, 849, 29, 403, 9, 267, 10062, 275, 14775, 2936, 14, 362, 360, 1569, 358, 503, 291, 423, 974, 63, 1733, 63, 8311, 8, 12022, 9, 267, 7373, 275, 1109, 63, 269, 63, 3592, 8, 11331, 2936, 14, 362, 360, 5553, 1333, 267, 3462, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 2063, 297, 9248, 12, 283, 3722, 3462, 297, 849, 29, 403, 430, 267, 4569, 275, 1109, 63, 269, 63, 3592, 8, 277, 423, 974, 63, 1733, 63, 1829, 8, 288, 283, 3722, 26, 3333, 297, 9248, 12, 283, 3722, 4569, 297, 849, 29, 403, 430, 398, 372, 469, 288, 283, 344, 356, 3991, 63, 344, 12, 288, 283, 633, 356, 3991, 63, 633, 12, 288, 283, 1213, 356, 2538, 12, 288, 283, 1802, 356, 1369, 12, 288, 283, 8311, 356, 10062, 12, 288, 283, 5553, 356, 7373, 12, 288, 283, 2063, 356, 3462, 12, 288, 283, 3333, 356, 4569, 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, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
rat4/bitcoin
qa/rpc-tests/test_framework/blockstore.py
98
4096
# BlockStore: a helper class that keeps a map of blocks and implements # helper functions for responding to getheaders and getdata, # and for constructing a getheaders message # from mininode import * import dbm class BlockStore(object): def __init__(self, datadir): self.blockDB = dbm.open(datadir + "/blocks", 'c') self.currentBlock = 0L def close(self): self.blockDB.close() def get(self, blockhash): serialized_block = None try: serialized_block = self.blockDB[repr(blockhash)] except KeyError: return None f = cStringIO.StringIO(serialized_block) ret = CBlock() ret.deserialize(f) ret.calc_sha256() return ret # Note: this pulls full blocks out of the database just to retrieve # the headers -- perhaps we could keep a separate data structure # to avoid this overhead. def headers_for(self, locator, hash_stop, current_tip=None): if current_tip is None: current_tip = self.currentBlock current_block = self.get(current_tip) if current_block is None: return None response = msg_headers() headersList = [ CBlockHeader(current_block) ] maxheaders = 2000 while (headersList[0].sha256 not in locator.vHave): prevBlockHash = headersList[0].hashPrevBlock prevBlock = self.get(prevBlockHash) if prevBlock is not None: headersList.insert(0, CBlockHeader(prevBlock)) else: break headersList = headersList[:maxheaders] # truncate if we have too many hashList = [x.sha256 for x in headersList] index = len(headersList) if (hash_stop in hashList): index = hashList.index(hash_stop)+1 response.headers = headersList[:index] return response def add_block(self, block): block.calc_sha256() try: self.blockDB[repr(block.sha256)] = bytes(block.serialize()) except TypeError as e: print "Unexpected error: ", sys.exc_info()[0], e.args self.currentBlock = block.sha256 def get_blocks(self, inv): responses = [] for i in inv: if (i.type == 2): # MSG_BLOCK block = self.get(i.hash) if block is not None: responses.append(msg_block(block)) return responses def get_locator(self, current_tip=None): if current_tip is None: current_tip = self.currentBlock r = [] counter = 0 step = 1 lastBlock = self.get(current_tip) while lastBlock is not None: r.append(lastBlock.hashPrevBlock) for i in range(step): lastBlock = self.get(lastBlock.hashPrevBlock) if lastBlock is None: break counter += 1 if counter > 10: step *= 2 locator = CBlockLocator() locator.vHave = r return locator class TxStore(object): def __init__(self, datadir): self.txDB = dbm.open(datadir + "/transactions", 'c') def close(self): self.txDB.close() def get(self, txhash): serialized_tx = None try: serialized_tx = self.txDB[repr(txhash)] except KeyError: return None f = cStringIO.StringIO(serialized_tx) ret = CTransaction() ret.deserialize(f) ret.calc_sha256() return ret def add_transaction(self, tx): tx.calc_sha256() try: self.txDB[repr(tx.sha256)] = bytes(tx.serialize()) except TypeError as e: print "Unexpected error: ", sys.exc_info()[0], e.args def get_transactions(self, inv): responses = [] for i in inv: if (i.type == 1): # MSG_TX tx = self.get(i.hash) if tx is not None: responses.append(msg_tx(tx)) return responses
mit
[ 3, 8651, 5502, 26, 282, 5922, 1021, 626, 18578, 282, 2341, 402, 5664, 436, 9031, 199, 3, 3777, 5922, 3423, 367, 9163, 1098, 370, 2312, 16946, 83, 436, 664, 576, 12, 199, 3, 3777, 436, 367, 22048, 282, 2312, 16946, 83, 1245, 199, 3, 199, 199, 504, 1748, 15993, 492, 627, 199, 646, 31093, 199, 199, 533, 8651, 5502, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 694, 304, 267, 291, 14, 1457, 2846, 275, 31093, 14, 1490, 8, 18259, 435, 3286, 4166, 401, 283, 67, 358, 267, 291, 14, 1818, 3142, 275, 378, 44, 2286, 347, 4002, 8, 277, 304, 267, 291, 14, 1457, 2846, 14, 1600, 342, 339, 347, 664, 8, 277, 12, 1853, 2227, 304, 267, 6380, 63, 1457, 275, 488, 267, 862, 26, 288, 6380, 63, 1457, 275, 291, 14, 1457, 2846, 59, 2722, 8, 25848, 1874, 267, 871, 4067, 26, 288, 372, 488, 267, 289, 275, 15073, 14, 6424, 8, 8397, 63, 1457, 9, 267, 2203, 275, 445, 3142, 342, 267, 2203, 14, 11143, 8, 70, 9, 267, 2203, 14, 8104, 63, 4835, 3912, 342, 267, 372, 2203, 339, 327, 3390, 26, 642, 299, 13072, 2615, 5664, 734, 402, 314, 3050, 2951, 370, 8044, 272, 327, 314, 2323, 1553, 25358, 781, 4293, 4215, 282, 7396, 666, 5523, 272, 327, 370, 5126, 642, 24075, 14, 272, 347, 2323, 63, 509, 8, 277, 12, 14067, 12, 2631, 63, 2379, 12, 1453, 63, 8996, 29, 403, 304, 267, 340, 1453, 63, 8996, 365, 488, 26, 288, 1453, 63, 8996, 275, 291, 14, 1818, 3142, 267, 1453, 63, 1457, 275, 291, 14, 362, 8, 1818, 63, 8996, 9, 267, 340, 1453, 63, 1457, 365, 488, 26, 288, 372, 488, 398, 1177, 275, 1499, 63, 2139, 342, 267, 2323, 1296, 275, 359, 445, 3142, 2567, 8, 1818, 63, 1457, 9, 1622, 267, 1390, 2139, 275, 12293, 267, 1830, 334, 2139, 1296, 59, 16, 1055, 4835, 3912, 440, 315, 14067, 14, 86, 40, 811, 304, 288, 5071, 3142, 3476, 275, 2323, 1296, 59, 16, 1055, 2227, 18873, 3142, 288, 5071, 3142, 275, 291, 14, 362, 8, 5701, 3142, 3476, 9, 288, 340, 5071, 3142, 365, 440, 488, 26, 355, 2323, 1296, 14, 3176, 8, 16, 12, 445, 3142, 2567, 8, 5701, 3142, 430, 288, 587, 26, 355, 2059, 267, 2323, 1296, 275, 2323, 1296, 1491, 988, 2139, 61, 327, 14547, 340, 781, 1172, 4634, 5002, 267, 2631, 1296, 275, 359, 88, 14, 4835, 3912, 367, 671, 315, 2323, 1296, 61, 267, 1478, 275, 822, 8, 2139, 1296, 9, 267, 340, 334, 2227, 63, 2379, 315, 2631, 1296, 304, 288, 1478, 275, 2631, 1296, 14, 1080, 8, 2227, 63, 2379, 6393, 17, 267, 1177, 14, 2139, 275, 2323, 1296, 1491, 1080, 61, 267, 372, 1177, 339, 347, 1050, 63, 1457, 8, 277, 12, 1853, 304, 267, 1853, 14, 8104, 63, 4835, 3912, 342, 267, 862, 26, 288, 291, 14, 1457, 2846, 59, 2722, 8, 1457, 14, 4835, 3912, 1874, 275, 2783, 8, 1457, 14, 3549, 1012, 267, 871, 3146, 465, 325, 26, 288, 870, 298, 8708, 1125, 26, 3872, 984, 14, 2804, 63, 815, 3430, 16, 467, 325, 14, 589, 267, 291, 14, 1818, 3142, 275, 1853, 14, 4835, 3912, 339, 347, 664, 63, 4166, 8, 277, 12, 4572, 304, 267, 9320, 275, 942, 267, 367, 284, 315, 4572, 26, 288, 340, 334, 73, 14, 466, 508, 499, 304, 327, 23620, 63, 8475, 355, 1853, 275, 291, 14, 362, 8, 73, 14, 2227, 9, 355, 340, 1853, 365, 440, 488, 26, 490, 9320, 14, 740, 8, 1328, 63, 1457, 8, 1457, 430, 267, 372, 9320, 339, 347, 664, 63, 6354, 8, 277, 12, 1453, 63, 8996, 29, 403, 304, 267, 340, 1453, 63, 8996, 365, 488, 26, 288, 1453, 63, 8996, 275, 291, 14, 1818, 3142, 267, 519, 275, 942, 267, 7055, 275, 378, 267, 3650, 275, 413, 267, 2061, 3142, 275, 291, 14, 362, 8, 1818, 63, 8996, 9, 267, 1830, 2061, 3142, 365, 440, 488, 26, 288, 519, 14, 740, 8, 2019, 3142, 14, 2227, 18873, 3142, 9, 288, 367, 284, 315, 1425, 8, 2926, 304, 355, 2061, 3142, 275, 291, 14, 362, 8, 2019, 3142, 14, 2227, 18873, 3142, 9, 355, 340, 2061, 3142, 365, 488, 26, 490, 2059, 288, 7055, 847, 413, 288, 340, 7055, 690, 1616, 26, 355, 3650, 9000, 499, 267, 14067, 275, 445, 3142, 10725, 342, 267, 14067, 14, 86, 40, 811, 275, 519, 267, 372, 14067, 199, 199, 533, 377, 88, 5502, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 694, 304, 267, 291, 14, 2347, 2846, 275, 31093, 14, 1490, 8, 18259, 435, 3286, 13754, 401, 283, 67, 358, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 2347, 2846, 14, 1600, 342, 339, 347, 664, 8, 277, 12, 4773, 2227, 304, 267, 6380, 63, 2347, 275, 488, 267, 862, 26, 288, 6380, 63, 2347, 275, 291, 14, 2347, 2846, 59, 2722, 8, 2347, 2227, 1874, 267, 871, 4067, 26, 288, 372, 488, 267, 289, 275, 15073, 14, 6424, 8, 8397, 63, 2347, 9, 267, 2203, 275, 445, 10161, 342, 267, 2203, 14, 11143, 8, 70, 9, 267, 2203, 14, 8104, 63, 4835, 3912, 342, 267, 372, 2203, 339, 347, 1050, 63, 5945, 8, 277, 12, 4773, 304, 267, 4773, 14, 8104, 63, 4835, 3912, 342, 267, 862, 26, 288, 291, 14, 2347, 2846, 59, 2722, 8, 2347, 14, 4835, 3912, 1874, 275, 2783, 8, 2347, 14, 3549, 1012, 267, 871, 3146, 465, 325, 26, 288, 870, 298, 8708, 1125, 26, 3872, 984, 14, 2804, 63, 815, 3430, 16, 467, 325, 14, 589, 339, 347, 664, 63, 13754, 8, 277, 12, 4572, 304, 267, 9320, 275, 942, 267, 367, 284, 315, 4572, 26, 288, 340, 334, 73, 14, 466, 508, 413, 304, 327, 23620, 63, 10051, 355, 4773, 275, 291, 14, 362, 8, 73, 14, 2227, 9, 355, 340, 4773, 365, 440, 488, 26, 490, 9320, 14, 740, 8, 1328, 63, 2347, 8, 2347, 430, 267, 372, 9320, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8651, 5502, 26, 282, 5922, 1021, 626, 18578, 282, 2341, 402, 5664, 436, 9031, 199, 3, 3777, 5922, 3423, 367, 9163, 1098, 370, 2312, 16946, 83, 436, 664, 576, 12, 199, 3, 3777, 436, 367, 22048, 282, 2312, 16946, 83, 1245, 199, 3, 199, 199, 504, 1748, 15993, 492, 627, 199, 646, 31093, 199, 199, 533, 8651, 5502, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 694, 304, 267, 291, 14, 1457, 2846, 275, 31093, 14, 1490, 8, 18259, 435, 3286, 4166, 401, 283, 67, 358, 267, 291, 14, 1818, 3142, 275, 378, 44, 2286, 347, 4002, 8, 277, 304, 267, 291, 14, 1457, 2846, 14, 1600, 342, 339, 347, 664, 8, 277, 12, 1853, 2227, 304, 267, 6380, 63, 1457, 275, 488, 267, 862, 26, 288, 6380, 63, 1457, 275, 291, 14, 1457, 2846, 59, 2722, 8, 25848, 1874, 267, 871, 4067, 26, 288, 372, 488, 267, 289, 275, 15073, 14, 6424, 8, 8397, 63, 1457, 9, 267, 2203, 275, 445, 3142, 342, 267, 2203, 14, 11143, 8, 70, 9, 267, 2203, 14, 8104, 63, 4835, 3912, 342, 267, 372, 2203, 339, 327, 3390, 26, 642, 299, 13072, 2615, 5664, 734, 402, 314, 3050, 2951, 370, 8044, 272, 327, 314, 2323, 1553, 25358, 781, 4293, 4215, 282, 7396, 666, 5523, 272, 327, 370, 5126, 642, 24075, 14, 272, 347, 2323, 63, 509, 8, 277, 12, 14067, 12, 2631, 63, 2379, 12, 1453, 63, 8996, 29, 403, 304, 267, 340, 1453, 63, 8996, 365, 488, 26, 288, 1453, 63, 8996, 275, 291, 14, 1818, 3142, 267, 1453, 63, 1457, 275, 291, 14, 362, 8, 1818, 63, 8996, 9, 267, 340, 1453, 63, 1457, 365, 488, 26, 288, 372, 488, 398, 1177, 275, 1499, 63, 2139, 342, 267, 2323, 1296, 275, 359, 445, 3142, 2567, 8, 1818, 63, 1457, 9, 1622, 267, 1390, 2139, 275, 12293, 267, 1830, 334, 2139, 1296, 59, 16, 1055, 4835, 3912, 440, 315, 14067, 14, 86, 40, 811, 304, 288, 5071, 3142, 3476, 275, 2323, 1296, 59, 16, 1055, 2227, 18873, 3142, 288, 5071, 3142, 275, 291, 14, 362, 8, 5701, 3142, 3476, 9, 288, 340, 5071, 3142, 365, 440, 488, 26, 355, 2323, 1296, 14, 3176, 8, 16, 12, 445, 3142, 2567, 8, 5701, 3142, 430, 288, 587, 26, 355, 2059, 267, 2323, 1296, 275, 2323, 1296, 1491, 988, 2139, 61, 327, 14547, 340, 781, 1172, 4634, 5002, 267, 2631, 1296, 275, 359, 88, 14, 4835, 3912, 367, 671, 315, 2323, 1296, 61, 267, 1478, 275, 822, 8, 2139, 1296, 9, 267, 340, 334, 2227, 63, 2379, 315, 2631, 1296, 304, 288, 1478, 275, 2631, 1296, 14, 1080, 8, 2227, 63, 2379, 6393, 17, 267, 1177, 14, 2139, 275, 2323, 1296, 1491, 1080, 61, 267, 372, 1177, 339, 347, 1050, 63, 1457, 8, 277, 12, 1853, 304, 267, 1853, 14, 8104, 63, 4835, 3912, 342, 267, 862, 26, 288, 291, 14, 1457, 2846, 59, 2722, 8, 1457, 14, 4835, 3912, 1874, 275, 2783, 8, 1457, 14, 3549, 1012, 267, 871, 3146, 465, 325, 26, 288, 870, 298, 8708, 1125, 26, 3872, 984, 14, 2804, 63, 815, 3430, 16, 467, 325, 14, 589, 267, 291, 14, 1818, 3142, 275, 1853, 14, 4835, 3912, 339, 347, 664, 63, 4166, 8, 277, 12, 4572, 304, 267, 9320, 275, 942, 267, 367, 284, 315, 4572, 26, 288, 340, 334, 73, 14, 466, 508, 499, 304, 327, 23620, 63, 8475, 355, 1853, 275, 291, 14, 362, 8, 73, 14, 2227, 9, 355, 340, 1853, 365, 440, 488, 26, 490, 9320, 14, 740, 8, 1328, 63, 1457, 8, 1457, 430, 267, 372, 9320, 339, 347, 664, 63, 6354, 8, 277, 12, 1453, 63, 8996, 29, 403, 304, 267, 340, 1453, 63, 8996, 365, 488, 26, 288, 1453, 63, 8996, 275, 291, 14, 1818, 3142, 267, 519, 275, 942, 267, 7055, 275, 378, 267, 3650, 275, 413, 267, 2061, 3142, 275, 291, 14, 362, 8, 1818, 63, 8996, 9, 267, 1830, 2061, 3142, 365, 440, 488, 26, 288, 519, 14, 740, 8, 2019, 3142, 14, 2227, 18873, 3142, 9, 288, 367, 284, 315, 1425, 8, 2926, 304, 355, 2061, 3142, 275, 291, 14, 362, 8, 2019, 3142, 14, 2227, 18873, 3142, 9, 355, 340, 2061, 3142, 365, 488, 26, 490, 2059, 288, 7055, 847, 413, 288, 340, 7055, 690, 1616, 26, 355, 3650, 9000, 499, 267, 14067, 275, 445, 3142, 10725, 342, 267, 14067, 14, 86, 40, 811, 275, 519, 267, 372, 14067, 199, 199, 533, 377, 88, 5502, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 694, 304, 267, 291, 14, 2347, 2846, 275, 31093, 14, 1490, 8, 18259, 435, 3286, 13754, 401, 283, 67, 358, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 2347, 2846, 14, 1600, 342, 339, 347, 664, 8, 277, 12, 4773, 2227, 304, 267, 6380, 63, 2347, 275, 488, 267, 862, 26, 288, 6380, 63, 2347, 275, 291, 14, 2347, 2846, 59, 2722, 8, 2347, 2227, 1874, 267, 871, 4067, 26, 288, 372, 488, 267, 289, 275, 15073, 14, 6424, 8, 8397, 63, 2347, 9, 267, 2203, 275, 445, 10161, 342, 267, 2203, 14, 11143, 8, 70, 9, 267, 2203, 14, 8104, 63, 4835, 3912, 342, 267, 372, 2203, 339, 347, 1050, 63, 5945, 8, 277, 12, 4773, 304, 267, 4773, 14, 8104, 63, 4835, 3912, 342, 267, 862, 26, 288, 291, 14, 2347, 2846, 59, 2722, 8, 2347, 14, 4835, 3912, 1874, 275, 2783, 8, 2347, 14, 3549, 1012, 267, 871, 3146, 465, 325, 26, 288, 870, 298, 8708, 1125, 26, 3872, 984, 14, 2804, 63, 815, 3430, 16, 467, 325, 14, 589, 339, 347, 664, 63, 13754, 8, 277, 12, 4572, 304, 267, 9320, 275, 942, 267, 367, 284, 315, 4572, 26, 288, 340, 334, 73, 14, 466, 508, 413, 304, 327, 23620, 63, 10051, 355, 4773, 275, 291, 14, 362, 8, 73, 14, 2227, 9, 355, 340, 4773, 365, 440, 488, 26, 490, 9320, 14, 740, 8, 1328, 63, 2347, 8, 2347, 430, 267, 372, 9320, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
F-Secure/watchdog
src/watchdog/utils/__init__.py
4
4729
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2011 Yesudeep Mangalapilly <yesudeep@gmail.com> # Copyright 2012 Google, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ :module: watchdog.utils :synopsis: Utility classes and functions. :author: yesudeep@google.com (Yesudeep Mangalapilly) Functions --------- .. autofunction:: has_attribute .. autofunction:: load_class .. autofunction:: load_module .. autofunction:: read_text_file Classes ------- .. autoclass:: DaemonThread :members: :show-inheritance: :inherited-members: """ import sys import threading import ctypes.util def ctypes_find_library(name, default): """Finds a dynamic library.""" module_path = None try: module_path = ctypes.util.find_library(name) except (OSError, IOError): module_path = default return module_path def has_attribute(ob, attribute): """ :func:`hasattr` swallows exceptions. :func:`has_attribute` tests a Python object for the presence of an attribute. :param ob: object to inspect :param attribute: ``str`` for the name of the attribute. """ return getattr(ob, attribute, None) is not None class DaemonThread(threading.Thread): """ Daemon thread convenience class, sets a few properties and makes writing daemon threads a little easier. """ def __init__(self): threading.Thread.__init__(self) if has_attribute(self, 'daemon'): self.daemon = True else: self.setDaemon(True) self._stopped_event = threading.Event() if not has_attribute(self._stopped_event, 'is_set'): self._stopped_event.is_set = self._stopped_event.isSet @property def stopped_event(self): return self._stopped_event def should_stop(self): """Determines whether the daemon thread should stop.""" return self._stopped_event.is_set() def should_keep_running(self): """Determines whether the daemon thread should continue running.""" return not self._stopped_event.is_set() def on_thread_exit(self): """Override this method instead of :meth:`stop()`. :meth:`stop()` calls this method. Note that this method is called immediately after the daemon thread is signaled to halt. """ pass def stop(self): """Signals the daemon thread to stop.""" self._stopped_event.set() self.on_thread_exit() if not has_attribute(DaemonThread, 'is_alive'): DaemonThread.is_alive = DaemonThread.isAlive def load_module(module_name): """Imports a module given its name and returns a handle to it.""" try: __import__(module_name) except ImportError: raise ImportError('No module named %s' % module_name) return sys.modules[module_name] def load_class(dotted_path): """Loads and returns a class definition provided a dotted path specification the last part of the dotted path is the class name and there is at least one module name preceding the class name. Notes: You will need to ensure that the module you are trying to load exists in the Python path. Examples: - module.name.ClassName # Provided module.name is in the Python path. - module.ClassName # Provided module is in the Python path. What won't work: - ClassName - modle.name.ClassName # Typo in module name. - module.name.ClasNam # Typo in classname. """ dotted_path_split = dotted_path.split('.') if len(dotted_path_split) > 1: klass_name = dotted_path_split[-1] module_name = '.'.join(dotted_path_split[:-1]) module = load_module(module_name) if has_attribute(module, klass_name): klass = getattr(module, klass_name) return klass # Finally create and return an instance of the class #return klass(*args, **kwargs) else: raise AttributeError('Module %s does not have class attribute %s' % ( module_name, klass_name)) else: raise ValueError( 'Dotted module path %s must contain a module name and a classname' % dotted_path) def read_text_file(file_path, mode='rb'): """ Returns the contents of a file after opening it in read-only mode. :param file_path: Path to the file to be read from. :param mode: Mode string. """ return open(file_path, mode).read()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 7760, 29715, 3786, 1545, 603, 621, 279, 439, 382, 590, 665, 5066, 3786, 1545, 32, 6799, 14, 957, 30, 199, 3, 1898, 6029, 4475, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 421, 199, 624, 199, 26, 578, 26, 9626, 13889, 14, 1208, 199, 26, 9466, 27573, 26, 20511, 3992, 436, 3423, 14, 199, 26, 2502, 26, 9456, 3786, 1545, 32, 3098, 14, 957, 334, 12555, 3786, 1545, 603, 621, 279, 439, 382, 590, 9, 199, 199, 13967, 199, 9960, 199, 199, 703, 2599, 1593, 447, 965, 63, 3215, 199, 199, 703, 2599, 1593, 447, 2248, 63, 533, 199, 199, 703, 2599, 1593, 447, 2248, 63, 578, 199, 199, 703, 2599, 1593, 447, 1586, 63, 505, 63, 493, 199, 199, 15711, 199, 12797, 199, 703, 2599, 533, 447, 577, 8770, 4436, 2043, 520, 6334, 26, 2043, 520, 2384, 13, 13136, 26, 2043, 520, 17571, 13, 6334, 26, 199, 199, 624, 199, 199, 646, 984, 199, 646, 5796, 199, 646, 5577, 14, 1974, 421, 199, 318, 5577, 63, 1623, 63, 4342, 8, 354, 12, 849, 304, 523, 408, 30344, 282, 8336, 3555, 1041, 523, 859, 63, 515, 275, 488, 523, 862, 26, 272, 859, 63, 515, 275, 5577, 14, 1974, 14, 1623, 63, 4342, 8, 354, 9, 523, 871, 334, 16719, 12, 5925, 304, 272, 859, 63, 515, 275, 849, 523, 372, 859, 63, 515, 421, 199, 318, 965, 63, 3215, 8, 2873, 12, 2225, 304, 523, 408, 523, 520, 1532, 1705, 11161, 64, 5584, 24077, 4967, 14, 520, 1532, 1705, 1989, 63, 3215, 64, 2295, 282, 2018, 909, 367, 314, 523, 20024, 402, 376, 2225, 14, 819, 520, 635, 2607, 26, 489, 909, 370, 6485, 523, 520, 635, 2225, 26, 489, 1124, 495, 1040, 367, 314, 536, 402, 314, 2225, 14, 523, 408, 523, 372, 2519, 8, 2873, 12, 2225, 12, 488, 9, 365, 440, 488, 421, 199, 533, 577, 8770, 4436, 8, 12562, 14, 4436, 304, 523, 408, 523, 577, 8770, 2462, 16777, 1021, 12, 5951, 282, 9284, 4382, 436, 7704, 523, 3575, 11128, 7183, 282, 12050, 14905, 14, 523, 408, 819, 347, 636, 826, 721, 277, 304, 272, 5796, 14, 4436, 855, 826, 721, 277, 9, 272, 340, 965, 63, 3215, 8, 277, 12, 283, 10824, 735, 489, 291, 14, 10824, 275, 715, 272, 587, 26, 489, 291, 14, 409, 20555, 8, 549, 9, 272, 291, 423, 14661, 63, 1430, 275, 5796, 14, 2390, 342, 339, 340, 440, 965, 63, 3215, 8, 277, 423, 14661, 63, 1430, 12, 283, 374, 63, 409, 735, 489, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 275, 291, 423, 14661, 63, 1430, 14, 374, 1084, 819, 768, 1829, 523, 347, 15248, 63, 1430, 8, 277, 304, 272, 372, 291, 423, 14661, 63, 1430, 819, 347, 1077, 63, 2379, 8, 277, 304, 272, 408, 872, 18454, 3775, 314, 11128, 2462, 1077, 3631, 1041, 272, 372, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 342, 819, 347, 1077, 63, 3250, 63, 5720, 8, 277, 304, 272, 408, 872, 18454, 3775, 314, 11128, 2462, 1077, 1980, 3879, 1041, 272, 372, 440, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 342, 819, 347, 641, 63, 2671, 63, 2224, 8, 277, 304, 272, 408, 11954, 642, 1083, 3140, 402, 520, 5247, 1705, 2379, 25593, 272, 520, 5247, 1705, 2379, 11995, 4882, 642, 1083, 14, 339, 3390, 626, 642, 1083, 365, 2797, 9939, 2410, 314, 11128, 2462, 272, 365, 2070, 65, 1146, 370, 394, 4478, 14, 272, 408, 272, 986, 819, 347, 3631, 8, 277, 304, 272, 408, 28536, 314, 11128, 2462, 370, 3631, 1041, 272, 291, 423, 14661, 63, 1430, 14, 409, 342, 272, 291, 14, 265, 63, 2671, 63, 2224, 342, 421, 199, 692, 440, 965, 63, 3215, 8, 20555, 4436, 12, 283, 374, 63, 9631, 735, 523, 577, 8770, 4436, 14, 374, 63, 9631, 275, 577, 8770, 4436, 14, 374, 23692, 421, 199, 318, 2248, 63, 578, 8, 578, 63, 354, 304, 523, 408, 32447, 282, 859, 1627, 2399, 536, 436, 2529, 282, 2429, 370, 652, 1041, 523, 862, 26, 272, 636, 646, 721, 578, 63, 354, 9, 523, 871, 3545, 26, 272, 746, 3545, 360, 1944, 859, 4310, 450, 83, 7, 450, 859, 63, 354, 9, 523, 372, 984, 14, 3112, 59, 578, 63, 354, 61, 421, 199, 318, 2248, 63, 533, 8, 19404, 63, 515, 304, 523, 408, 30777, 436, 2529, 282, 1021, 5492, 2741, 282, 18947, 931, 523, 8929, 314, 2061, 1777, 402, 314, 18947, 931, 365, 314, 1021, 536, 523, 436, 2337, 365, 737, 5210, 1373, 859, 536, 22627, 314, 1021, 536, 14, 819, 8144, 26, 523, 2047, 911, 1929, 370, 4868, 626, 314, 859, 1265, 787, 9936, 370, 2248, 523, 3495, 315, 314, 2018, 931, 14, 819, 6058, 26, 523, 446, 859, 14, 354, 14, 23200, 259, 327, 2165, 11923, 859, 14, 354, 365, 315, 314, 2018, 931, 14, 523, 446, 859, 14, 23200, 260, 327, 2165, 11923, 859, 365, 315, 314, 2018, 931, 14, 819, 14791, 7859, 1133, 1736, 26, 523, 446, 8089, 985, 523, 446, 3413, 274, 14, 354, 14, 23200, 258, 327, 377, 89, 555, 315, 859, 536, 14, 523, 446, 859, 14, 354, 14, 1968, 305, 46, 455, 420, 327, 377, 89, 555, 315, 15876, 14, 523, 408, 523, 18947, 63, 515, 63, 1294, 275, 18947, 63, 515, 14, 1294 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 7760, 29715, 3786, 1545, 603, 621, 279, 439, 382, 590, 665, 5066, 3786, 1545, 32, 6799, 14, 957, 30, 199, 3, 1898, 6029, 4475, 12, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 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, 421, 199, 624, 199, 26, 578, 26, 9626, 13889, 14, 1208, 199, 26, 9466, 27573, 26, 20511, 3992, 436, 3423, 14, 199, 26, 2502, 26, 9456, 3786, 1545, 32, 3098, 14, 957, 334, 12555, 3786, 1545, 603, 621, 279, 439, 382, 590, 9, 199, 199, 13967, 199, 9960, 199, 199, 703, 2599, 1593, 447, 965, 63, 3215, 199, 199, 703, 2599, 1593, 447, 2248, 63, 533, 199, 199, 703, 2599, 1593, 447, 2248, 63, 578, 199, 199, 703, 2599, 1593, 447, 1586, 63, 505, 63, 493, 199, 199, 15711, 199, 12797, 199, 703, 2599, 533, 447, 577, 8770, 4436, 2043, 520, 6334, 26, 2043, 520, 2384, 13, 13136, 26, 2043, 520, 17571, 13, 6334, 26, 199, 199, 624, 199, 199, 646, 984, 199, 646, 5796, 199, 646, 5577, 14, 1974, 421, 199, 318, 5577, 63, 1623, 63, 4342, 8, 354, 12, 849, 304, 523, 408, 30344, 282, 8336, 3555, 1041, 523, 859, 63, 515, 275, 488, 523, 862, 26, 272, 859, 63, 515, 275, 5577, 14, 1974, 14, 1623, 63, 4342, 8, 354, 9, 523, 871, 334, 16719, 12, 5925, 304, 272, 859, 63, 515, 275, 849, 523, 372, 859, 63, 515, 421, 199, 318, 965, 63, 3215, 8, 2873, 12, 2225, 304, 523, 408, 523, 520, 1532, 1705, 11161, 64, 5584, 24077, 4967, 14, 520, 1532, 1705, 1989, 63, 3215, 64, 2295, 282, 2018, 909, 367, 314, 523, 20024, 402, 376, 2225, 14, 819, 520, 635, 2607, 26, 489, 909, 370, 6485, 523, 520, 635, 2225, 26, 489, 1124, 495, 1040, 367, 314, 536, 402, 314, 2225, 14, 523, 408, 523, 372, 2519, 8, 2873, 12, 2225, 12, 488, 9, 365, 440, 488, 421, 199, 533, 577, 8770, 4436, 8, 12562, 14, 4436, 304, 523, 408, 523, 577, 8770, 2462, 16777, 1021, 12, 5951, 282, 9284, 4382, 436, 7704, 523, 3575, 11128, 7183, 282, 12050, 14905, 14, 523, 408, 819, 347, 636, 826, 721, 277, 304, 272, 5796, 14, 4436, 855, 826, 721, 277, 9, 272, 340, 965, 63, 3215, 8, 277, 12, 283, 10824, 735, 489, 291, 14, 10824, 275, 715, 272, 587, 26, 489, 291, 14, 409, 20555, 8, 549, 9, 272, 291, 423, 14661, 63, 1430, 275, 5796, 14, 2390, 342, 339, 340, 440, 965, 63, 3215, 8, 277, 423, 14661, 63, 1430, 12, 283, 374, 63, 409, 735, 489, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 275, 291, 423, 14661, 63, 1430, 14, 374, 1084, 819, 768, 1829, 523, 347, 15248, 63, 1430, 8, 277, 304, 272, 372, 291, 423, 14661, 63, 1430, 819, 347, 1077, 63, 2379, 8, 277, 304, 272, 408, 872, 18454, 3775, 314, 11128, 2462, 1077, 3631, 1041, 272, 372, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 342, 819, 347, 1077, 63, 3250, 63, 5720, 8, 277, 304, 272, 408, 872, 18454, 3775, 314, 11128, 2462, 1077, 1980, 3879, 1041, 272, 372, 440, 291, 423, 14661, 63, 1430, 14, 374, 63, 409, 342, 819, 347, 641, 63, 2671, 63, 2224, 8, 277, 304, 272, 408, 11954, 642, 1083, 3140, 402, 520, 5247, 1705, 2379, 25593, 272, 520, 5247, 1705, 2379, 11995, 4882, 642, 1083, 14, 339, 3390, 626, 642, 1083, 365, 2797, 9939, 2410, 314, 11128, 2462, 272, 365, 2070, 65, 1146, 370, 394, 4478, 14, 272, 408, 272, 986, 819, 347, 3631, 8, 277, 304, 272, 408, 28536, 314, 11128, 2462, 370, 3631, 1041, 272, 291, 423, 14661, 63, 1430, 14, 409, 342, 272, 291, 14, 265, 63, 2671, 63, 2224, 342, 421, 199, 692, 440, 965, 63, 3215, 8, 20555, 4436, 12, 283, 374, 63, 9631, 735, 523, 577, 8770, 4436, 14, 374, 63, 9631, 275, 577, 8770, 4436, 14, 374, 23692, 421, 199, 318, 2248, 63, 578, 8, 578, 63, 354, 304, 523, 408, 32447, 282, 859, 1627, 2399, 536, 436, 2529, 282, 2429, 370, 652, 1041, 523, 862, 26, 272, 636, 646, 721, 578, 63, 354, 9, 523, 871, 3545, 26, 272, 746, 3545, 360, 1944, 859, 4310, 450, 83, 7, 450, 859, 63, 354, 9, 523, 372, 984, 14, 3112, 59, 578, 63, 354, 61, 421, 199, 318, 2248, 63, 533, 8, 19404, 63, 515, 304, 523, 408, 30777, 436, 2529, 282, 1021, 5492, 2741, 282, 18947, 931, 523, 8929, 314, 2061, 1777, 402, 314, 18947, 931, 365, 314, 1021, 536, 523, 436, 2337, 365, 737, 5210, 1373, 859, 536, 22627, 314, 1021, 536, 14, 819, 8144, 26, 523, 2047, 911, 1929, 370, 4868, 626, 314, 859, 1265, 787, 9936, 370, 2248, 523, 3495, 315, 314, 2018, 931, 14, 819, 6058, 26, 523, 446, 859, 14, 354, 14, 23200, 259, 327, 2165, 11923, 859, 14, 354, 365, 315, 314, 2018, 931, 14, 523, 446, 859, 14, 23200, 260, 327, 2165, 11923, 859, 365, 315, 314, 2018, 931, 14, 819, 14791, 7859, 1133, 1736, 26, 523, 446, 8089, 985, 523, 446, 3413, 274, 14, 354, 14, 23200, 258, 327, 377, 89, 555, 315, 859, 536, 14, 523, 446, 859, 14, 354, 14, 1968, 305, 46, 455, 420, 327, 377, 89, 555, 315, 15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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
buildbot/buildbot
worker/buildbot_worker/test/unit/test_commands_utils.py
6
5327
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright Buildbot Team Members from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import shutil import sys import twisted.python.procutils from twisted.python import runtime from twisted.trial import unittest from buildbot_worker.commands import utils class GetCommand(unittest.TestCase): def setUp(self): # monkey-patch 'which' to return something appropriate self.which_results = {} def which(arg): return self.which_results.get(arg, []) self.patch(twisted.python.procutils, 'which', which) # note that utils.py currently imports which by name, so we # patch it there, too self.patch(utils, 'which', which) def set_which_results(self, results): self.which_results = results def test_getCommand_empty(self): self.set_which_results({ 'xeyes': [], }) with self.assertRaises(RuntimeError): utils.getCommand('xeyes') def test_getCommand_single(self): self.set_which_results({ 'xeyes': ['/usr/bin/xeyes'], }) self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes') def test_getCommand_multi(self): self.set_which_results({ 'xeyes': ['/usr/bin/xeyes', '/usr/X11/bin/xeyes'], }) self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes') def test_getCommand_single_exe(self): self.set_which_results({ 'xeyes': ['/usr/bin/xeyes'], # it should not select this option, since only one matched # to begin with 'xeyes.exe': [r'c:\program files\xeyes.exe'], }) self.assertEqual(utils.getCommand('xeyes'), '/usr/bin/xeyes') def test_getCommand_multi_exe(self): self.set_which_results({ 'xeyes': [r'c:\program files\xeyes.com', r'c:\program files\xeyes.exe'], 'xeyes.exe': [r'c:\program files\xeyes.exe'], }) # this one will work out differently depending on platform.. if runtime.platformType == 'win32': self.assertEqual( utils.getCommand('xeyes'), r'c:\program files\xeyes.exe') else: self.assertEqual( utils.getCommand('xeyes'), r'c:\program files\xeyes.com') class RmdirRecursive(unittest.TestCase): # this is more complicated than you'd think because Twisted doesn't # rmdir its test directory very well, either.. def setUp(self): self.target = 'testdir' try: if os.path.exists(self.target): shutil.rmtree(self.target) except Exception: # this test will probably fail anyway e = sys.exc_info()[0] raise unittest.SkipTest("could not clean before test: {0}".format(e)) # fill it with some files os.mkdir(os.path.join(self.target)) with open(os.path.join(self.target, "a"), "w"): pass os.mkdir(os.path.join(self.target, "d")) with open(os.path.join(self.target, "d", "a"), "w"): pass os.mkdir(os.path.join(self.target, "d", "d")) with open(os.path.join(self.target, "d", "d", "a"), "w"): pass def tearDown(self): try: if os.path.exists(self.target): shutil.rmtree(self.target) except Exception: print( "\n(target directory was not removed by test, and cleanup failed too)\n") raise def test_rmdirRecursive_easy(self): utils.rmdirRecursive(self.target) self.assertFalse(os.path.exists(self.target)) def test_rmdirRecursive_symlink(self): # this was intended as a regression test for #792, but doesn't seem # to trigger it. It can't hurt to check it, all the same. if runtime.platformType == 'win32': raise unittest.SkipTest("no symlinks on this platform") os.mkdir("noperms") with open("noperms/x", "w"): pass os.chmod("noperms/x", 0) try: os.symlink("../noperms", os.path.join(self.target, "link")) utils.rmdirRecursive(self.target) # that shouldn't delete the target of the symlink self.assertTrue(os.path.exists("noperms")) finally: # even Twisted can't clean this up very well, so try hard to # clean it up ourselves.. os.chmod("noperms/x", 0o777) os.unlink("noperms/x") os.rmdir("noperms") self.assertFalse(os.path.exists(self.target))
gpl-2.0
[ 3, 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 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, 747, 199, 646, 5145, 199, 646, 984, 199, 199, 646, 7390, 14, 1548, 14, 4687, 1208, 199, 504, 7390, 14, 1548, 492, 8836, 199, 504, 7390, 14, 14443, 492, 2882, 199, 199, 504, 21306, 63, 6599, 14, 4405, 492, 3778, 421, 199, 533, 2372, 3110, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 14198, 13, 2068, 283, 6777, 7, 370, 372, 6020, 5827, 267, 291, 14, 6777, 63, 2604, 275, 1052, 398, 347, 1314, 8, 1273, 304, 288, 372, 291, 14, 6777, 63, 2604, 14, 362, 8, 1273, 12, 3073, 267, 291, 14, 2068, 8, 12145, 14, 1548, 14, 4687, 1208, 12, 283, 6777, 297, 1314, 9, 267, 327, 5317, 626, 3778, 14, 647, 5544, 8925, 1314, 701, 536, 12, 880, 781, 267, 327, 3371, 652, 2337, 12, 4634, 267, 291, 14, 2068, 8, 1208, 12, 283, 6777, 297, 1314, 9, 339, 347, 663, 63, 6777, 63, 2604, 8, 277, 12, 2058, 304, 267, 291, 14, 6777, 63, 2604, 275, 2058, 339, 347, 511, 63, 362, 3110, 63, 1667, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 990, 267, 3828, 267, 543, 291, 14, 1855, 8, 13281, 304, 288, 3778, 14, 362, 3110, 360, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 4780, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 3029, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 297, 1994, 2647, 15, 56, 845, 15, 1393, 15, 1845, 5066, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 4780, 63, 5803, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 995, 288, 327, 652, 1077, 440, 3504, 642, 945, 12, 3967, 1454, 1373, 7838, 288, 327, 370, 5386, 543, 288, 283, 1845, 5066, 14, 5803, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 3029, 63, 5803, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 957, 297, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 288, 283, 1845, 5066, 14, 5803, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 267, 3828, 267, 327, 642, 1373, 911, 1736, 734, 23142, 10298, 641, 4298, 703, 267, 340, 8836, 14, 3246, 804, 508, 283, 2676, 708, 356, 288, 291, 14, 629, 8, 355, 3778, 14, 362, 3110, 360, 1845, 5066, 659, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 358, 267, 587, 26, 288, 291, 14, 629, 8, 355, 3778, 14, 362, 3110, 360, 1845, 5066, 659, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 957, 358, 421, 199, 533, 820, 77, 694, 25122, 8, 2796, 14, 1746, 304, 339, 327, 642, 365, 1655, 23515, 2419, 1265, 5121, 13516, 2952, 17078, 3181, 1133, 272, 327, 14267, 694, 2399, 511, 2082, 7437, 5521, 12, 1902, 703, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1375, 275, 283, 16634, 7, 267, 862, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 1375, 304, 355, 5145, 14, 9242, 8, 277, 14, 1375, 9, 267, 871, 2186, 26, 288, 327, 642, 511, 911, 8646, 2449, 15988, 288, 325, 275, 984, 14, 2804, 63, 815, 3430, 16, 61, 288, 746, 2882, 14, 25755, 480, 15153, 440, 3633, 2544, 511, 26, 469, 16, 5469, 908, 8, 69, 430, 398, 327, 5554, 652, 543, 2005, 1584, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 430, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 65, 1288, 298, 87, 2349, 288, 986, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 2237, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 65, 1288, 298, 87, 2349, 288, 986, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 68, 2237, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 68, 401, 298, 65, 1288 ]
[ 961, 570, 365, 1777, 402, 6516, 3018, 14, 221, 6516, 3018, 365, 2867, 2032, 26, 1265, 883, 199, 3, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 12, 1015, 499, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 199, 3, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 199, 3, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 199, 3, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 3180, 543, 199, 3, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 199, 3, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 3, 199, 3, 1898, 6516, 3018, 11682, 14409, 83, 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, 747, 199, 646, 5145, 199, 646, 984, 199, 199, 646, 7390, 14, 1548, 14, 4687, 1208, 199, 504, 7390, 14, 1548, 492, 8836, 199, 504, 7390, 14, 14443, 492, 2882, 199, 199, 504, 21306, 63, 6599, 14, 4405, 492, 3778, 421, 199, 533, 2372, 3110, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 327, 14198, 13, 2068, 283, 6777, 7, 370, 372, 6020, 5827, 267, 291, 14, 6777, 63, 2604, 275, 1052, 398, 347, 1314, 8, 1273, 304, 288, 372, 291, 14, 6777, 63, 2604, 14, 362, 8, 1273, 12, 3073, 267, 291, 14, 2068, 8, 12145, 14, 1548, 14, 4687, 1208, 12, 283, 6777, 297, 1314, 9, 267, 327, 5317, 626, 3778, 14, 647, 5544, 8925, 1314, 701, 536, 12, 880, 781, 267, 327, 3371, 652, 2337, 12, 4634, 267, 291, 14, 2068, 8, 1208, 12, 283, 6777, 297, 1314, 9, 339, 347, 663, 63, 6777, 63, 2604, 8, 277, 12, 2058, 304, 267, 291, 14, 6777, 63, 2604, 275, 2058, 339, 347, 511, 63, 362, 3110, 63, 1667, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 990, 267, 3828, 267, 543, 291, 14, 1855, 8, 13281, 304, 288, 3778, 14, 362, 3110, 360, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 4780, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 3029, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 297, 1994, 2647, 15, 56, 845, 15, 1393, 15, 1845, 5066, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 4780, 63, 5803, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 18744, 2647, 15, 1393, 15, 1845, 5066, 995, 288, 327, 652, 1077, 440, 3504, 642, 945, 12, 3967, 1454, 1373, 7838, 288, 327, 370, 5386, 543, 288, 283, 1845, 5066, 14, 5803, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 267, 3828, 267, 291, 14, 629, 8, 1208, 14, 362, 3110, 360, 1845, 5066, 659, 1994, 2647, 15, 1393, 15, 1845, 5066, 358, 339, 347, 511, 63, 362, 3110, 63, 3029, 63, 5803, 8, 277, 304, 267, 291, 14, 409, 63, 6777, 63, 2604, 2561, 288, 283, 1845, 5066, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 957, 297, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 288, 283, 1845, 5066, 14, 5803, 356, 359, 82, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 995, 267, 3828, 267, 327, 642, 1373, 911, 1736, 734, 23142, 10298, 641, 4298, 703, 267, 340, 8836, 14, 3246, 804, 508, 283, 2676, 708, 356, 288, 291, 14, 629, 8, 355, 3778, 14, 362, 3110, 360, 1845, 5066, 659, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 5803, 358, 267, 587, 26, 288, 291, 14, 629, 8, 355, 3778, 14, 362, 3110, 360, 1845, 5066, 659, 519, 7, 67, 3427, 6815, 1584, 60, 1845, 5066, 14, 957, 358, 421, 199, 533, 820, 77, 694, 25122, 8, 2796, 14, 1746, 304, 339, 327, 642, 365, 1655, 23515, 2419, 1265, 5121, 13516, 2952, 17078, 3181, 1133, 272, 327, 14267, 694, 2399, 511, 2082, 7437, 5521, 12, 1902, 703, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 1375, 275, 283, 16634, 7, 267, 862, 26, 288, 340, 747, 14, 515, 14, 2444, 8, 277, 14, 1375, 304, 355, 5145, 14, 9242, 8, 277, 14, 1375, 9, 267, 871, 2186, 26, 288, 327, 642, 511, 911, 8646, 2449, 15988, 288, 325, 275, 984, 14, 2804, 63, 815, 3430, 16, 61, 288, 746, 2882, 14, 25755, 480, 15153, 440, 3633, 2544, 511, 26, 469, 16, 5469, 908, 8, 69, 430, 398, 327, 5554, 652, 543, 2005, 1584, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 430, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 65, 1288, 298, 87, 2349, 288, 986, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 2237, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 65, 1288, 298, 87, 2349, 288, 986, 267, 747, 14, 8215, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 68, 2237, 267, 543, 1551, 8, 736, 14, 515, 14, 904, 8, 277, 14, 1375, 12, 298, 68, 401, 298, 68, 401, 298, 65, 1288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
glove747/liberty-neutron
neutron/tests/unit/test_auth.py
4
5064
# Copyright 2012 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo_middleware import request_id import webob from neutron import auth from neutron.tests import base class NeutronKeystoneContextTestCase(base.BaseTestCase): def setUp(self): super(NeutronKeystoneContextTestCase, self).setUp() @webob.dec.wsgify def fake_app(req): self.context = req.environ['neutron.context'] return webob.Response() self.context = None self.middleware = auth.NeutronKeystoneContext(fake_app) self.request = webob.Request.blank('/') self.request.headers['X_AUTH_TOKEN'] = 'testauthtoken' def test_no_user_id(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '401 Unauthorized') def test_with_user_id(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.user_id, 'testuserid') self.assertEqual(self.context.user, 'testuserid') def test_with_tenant_id(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'test_user_id' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.tenant_id, 'testtenantid') self.assertEqual(self.context.tenant, 'testtenantid') def test_roles_no_admin(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' self.request.headers['X_ROLES'] = 'role1, role2 , role3,role4,role5' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.roles, ['role1', 'role2', 'role3', 'role4', 'role5']) self.assertEqual(self.context.is_admin, False) def test_roles_with_admin(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' self.request.headers['X_ROLES'] = ('role1, role2 , role3,role4,role5,' 'AdMiN') response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.roles, ['role1', 'role2', 'role3', 'role4', 'role5', 'AdMiN']) self.assertTrue(self.context.is_admin) def test_with_user_tenant_name(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' self.request.headers['X_PROJECT_NAME'] = 'testtenantname' self.request.headers['X_USER_NAME'] = 'testusername' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.user_id, 'testuserid') self.assertEqual(self.context.user_name, 'testusername') self.assertEqual(self.context.tenant_id, 'testtenantid') self.assertEqual(self.context.tenant_name, 'testtenantname') def test_request_id_extracted_from_env(self): req_id = 'dummy-request-id' self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' self.request.environ[request_id.ENV_REQUEST_ID] = req_id self.request.get_response(self.middleware) self.assertEqual(req_id, self.context.request_id) def test_with_auth_token(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' response = self.request.get_response(self.middleware) self.assertEqual(response.status, '200 OK') self.assertEqual(self.context.auth_token, 'testauthtoken') def test_without_auth_token(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' self.request.headers['X_USER_ID'] = 'testuserid' del self.request.headers['X_AUTH_TOKEN'] self.request.get_response(self.middleware) self.assertIsNone(self.context.auth_token)
apache-2.0
[ 3, 1898, 6029, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 5754, 492, 1056, 63, 344, 199, 646, 14568, 199, 199, 504, 8224, 492, 1790, 199, 504, 8224, 14, 2219, 492, 1300, 421, 199, 533, 30422, 1197, 8361, 2998, 1746, 8, 1095, 14, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 20915, 1197, 8361, 2998, 1746, 12, 291, 680, 5996, 342, 398, 768, 24057, 14, 7778, 14, 87, 1226, 2021, 267, 347, 4026, 63, 571, 8, 2103, 304, 288, 291, 14, 1100, 275, 2648, 14, 2314, 459, 10271, 14, 1100, 418, 288, 372, 14568, 14, 2364, 342, 398, 291, 14, 1100, 275, 488, 267, 291, 14, 5754, 275, 1790, 14, 20915, 1197, 8361, 2998, 8, 3183, 63, 571, 9, 267, 291, 14, 1069, 275, 14568, 14, 2017, 14, 2500, 7825, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 5580, 63, 8803, 418, 275, 283, 396, 1178, 1418, 7, 339, 347, 511, 63, 889, 63, 751, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 8854, 1910, 11497, 358, 339, 347, 511, 63, 1045, 63, 751, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 751, 63, 344, 12, 283, 396, 19737, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 751, 12, 283, 396, 19737, 358, 339, 347, 511, 63, 1045, 63, 4647, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 63, 751, 63, 344, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 4647, 63, 344, 12, 283, 396, 724, 4466, 68, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 4647, 12, 283, 396, 724, 4466, 68, 358, 339, 347, 511, 63, 8050, 63, 889, 63, 2113, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 6245, 654, 418, 275, 283, 3756, 17, 12, 4719, 18, 2360, 4719, 19, 12, 3756, 20, 12, 3756, 21, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 8050, 12, 788, 3756, 17, 297, 283, 3756, 18, 297, 283, 3756, 19, 297, 6343, 283, 3756, 20, 297, 283, 3756, 21, 1105, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 374, 63, 2113, 12, 756, 9, 339, 347, 511, 63, 8050, 63, 1045, 63, 2113, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 6245, 654, 418, 275, 661, 3756, 17, 12, 4719, 18, 2360, 4719, 19, 12, 3756, 20, 12, 3756, 21, 2584, 5644, 283, 2767, 14738, 46, 358, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 8050, 12, 788, 3756, 17, 297, 283, 3756, 18, 297, 283, 3756, 19, 297, 6343, 283, 3756, 20, 297, 283, 3756, 21, 297, 283, 2767, 14738, 46, 1105, 267, 291, 14, 1815, 8, 277, 14, 1100, 14, 374, 63, 2113, 9, 339, 347, 511, 63, 1045, 63, 751, 63, 4647, 63, 354, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 2339, 418, 275, 283, 396, 4647, 354, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 2339, 418, 275, 283, 396, 2473, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277 ]
[ 1898, 6029, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 11258, 63, 5754, 492, 1056, 63, 344, 199, 646, 14568, 199, 199, 504, 8224, 492, 1790, 199, 504, 8224, 14, 2219, 492, 1300, 421, 199, 533, 30422, 1197, 8361, 2998, 1746, 8, 1095, 14, 20760, 304, 272, 347, 3613, 8, 277, 304, 267, 1613, 8, 20915, 1197, 8361, 2998, 1746, 12, 291, 680, 5996, 342, 398, 768, 24057, 14, 7778, 14, 87, 1226, 2021, 267, 347, 4026, 63, 571, 8, 2103, 304, 288, 291, 14, 1100, 275, 2648, 14, 2314, 459, 10271, 14, 1100, 418, 288, 372, 14568, 14, 2364, 342, 398, 291, 14, 1100, 275, 488, 267, 291, 14, 5754, 275, 1790, 14, 20915, 1197, 8361, 2998, 8, 3183, 63, 571, 9, 267, 291, 14, 1069, 275, 14568, 14, 2017, 14, 2500, 7825, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 5580, 63, 8803, 418, 275, 283, 396, 1178, 1418, 7, 339, 347, 511, 63, 889, 63, 751, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 8854, 1910, 11497, 358, 339, 347, 511, 63, 1045, 63, 751, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 751, 63, 344, 12, 283, 396, 19737, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 751, 12, 283, 396, 19737, 358, 339, 347, 511, 63, 1045, 63, 4647, 63, 344, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 63, 751, 63, 344, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 4647, 63, 344, 12, 283, 396, 724, 4466, 68, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 4647, 12, 283, 396, 724, 4466, 68, 358, 339, 347, 511, 63, 8050, 63, 889, 63, 2113, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 6245, 654, 418, 275, 283, 3756, 17, 12, 4719, 18, 2360, 4719, 19, 12, 3756, 20, 12, 3756, 21, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 8050, 12, 788, 3756, 17, 297, 283, 3756, 18, 297, 283, 3756, 19, 297, 6343, 283, 3756, 20, 297, 283, 3756, 21, 1105, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 374, 63, 2113, 12, 756, 9, 339, 347, 511, 63, 8050, 63, 1045, 63, 2113, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 6245, 654, 418, 275, 661, 3756, 17, 12, 4719, 18, 2360, 4719, 19, 12, 3756, 20, 12, 3756, 21, 2584, 5644, 283, 2767, 14738, 46, 358, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 14, 1100, 14, 8050, 12, 788, 3756, 17, 297, 283, 3756, 18, 297, 283, 3756, 19, 297, 6343, 283, 3756, 20, 297, 283, 3756, 21, 297, 283, 2767, 14738, 46, 1105, 267, 291, 14, 1815, 8, 277, 14, 1100, 14, 374, 63, 2113, 9, 339, 347, 511, 63, 1045, 63, 751, 63, 4647, 63, 354, 8, 277, 304, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 998, 418, 275, 283, 396, 724, 4466, 68, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 998, 418, 275, 283, 396, 19737, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 10797, 63, 2339, 418, 275, 283, 396, 4647, 354, 7, 267, 291, 14, 1069, 14, 2139, 459, 56, 63, 3791, 63, 2339, 418, 275, 283, 396, 2473, 7, 267, 1177, 275, 291, 14, 1069, 14, 362, 63, 1310, 8, 277, 14, 5754, 9, 267, 291, 14, 629, 8, 1310, 14, 1205, 12, 283, 1840, 9949, 358, 267, 291, 14, 629, 8, 277, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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/env python # # Implementation of elliptic curves, for cryptographic applications. # # This module doesn't provide any way to choose a random elliptic # curve, nor to verify that an elliptic curve was chosen randomly, # because one can simply use NIST's standard curves. # # Notes from X9.62-1998 (draft): # Nomenclature: # - Q is a public key. # The "Elliptic Curve Domain Parameters" include: # - q is the "field size", which in our case equals p. # - p is a big prime. # - G is a point of prime order (5.1.1.1). # - n is the order of G (5.1.1.1). # Public-key validation (5.2.2): # - Verify that Q is not the point at infinity. # - Verify that X_Q and Y_Q are in [0,p-1]. # - Verify that Q is on the curve. # - Verify that nQ is the point at infinity. # Signature generation (5.3): # - Pick random k from [1,n-1]. # Signature checking (5.4.2): # - Verify that r and s are in [1,n-1]. # # Version of 2008.11.25. # # Revision history: # 2005.12.31 - Initial version. # 2008.11.25 - Change CurveFp.is_on to contains_point. # # Written in 2005 by Peter Pearson and placed in the public domain. from __future__ import division from .six import print_ from . import numbertheory class CurveFp( object ): """Elliptic Curve over the field of integers modulo a prime.""" def __init__( self, p, a, b ): """The curve of points satisfying y^2 = x^3 + a*x + b (mod p).""" self.__p = p self.__a = a self.__b = b def p( self ): return self.__p def a( self ): return self.__a def b( self ): return self.__b def contains_point( self, x, y ): """Is the point (x,y) on this curve?""" return ( y * y - ( x * x * x + self.__a * x + self.__b ) ) % self.__p == 0 class Point( object ): """A point on an elliptic curve. Altering x and y is forbidding, but they can be read by the x() and y() methods.""" def __init__( self, curve, x, y, order = None ): """curve, x, y, order; order (optional) is the order of this point.""" self.__curve = curve self.__x = x self.__y = y self.__order = order # self.curve is allowed to be None only for INFINITY: if self.__curve: assert self.__curve.contains_point( x, y ) if order: assert self * order == INFINITY def __eq__( self, other ): """Return True if the points are identical, False otherwise.""" if self.__curve == other.__curve \ and self.__x == other.__x \ and self.__y == other.__y: return True else: return False def __add__( self, other ): """Add one point to another point.""" # X9.62 B.3: if other == INFINITY: return self if self == INFINITY: return other assert self.__curve == other.__curve if self.__x == other.__x: if ( self.__y + other.__y ) % self.__curve.p() == 0: return INFINITY else: return self.double() p = self.__curve.p() l = ( ( other.__y - self.__y ) * \ numbertheory.inverse_mod( other.__x - self.__x, p ) ) % p x3 = ( l * l - self.__x - other.__x ) % p y3 = ( l * ( self.__x - x3 ) - self.__y ) % p return Point( self.__curve, x3, y3 ) def __mul__( self, other ): """Multiply a point by an integer.""" def leftmost_bit( x ): assert x > 0 result = 1 while result <= x: result = 2 * result return result // 2 e = other if self.__order: e = e % self.__order if e == 0: return INFINITY if self == INFINITY: return INFINITY assert e > 0 # From X9.62 D.3.2: e3 = 3 * e negative_self = Point( self.__curve, self.__x, -self.__y, self.__order ) i = leftmost_bit( e3 ) // 2 result = self # print_("Multiplying %s by %d (e3 = %d):" % ( self, other, e3 )) while i > 1: result = result.double() if ( e3 & i ) != 0 and ( e & i ) == 0: result = result + self if ( e3 & i ) == 0 and ( e & i ) != 0: result = result + negative_self # print_(". . . i = %d, result = %s" % ( i, result )) i = i // 2 return result def __rmul__( self, other ): """Multiply a point by an integer.""" return self * other def __str__( self ): if self == INFINITY: return "infinity" return "(%d,%d)" % ( self.__x, self.__y ) def double( self ): """Return a new point that is twice the old.""" if self == INFINITY: return INFINITY # X9.62 B.3: p = self.__curve.p() a = self.__curve.a() l = ( ( 3 * self.__x * self.__x + a ) * \ numbertheory.inverse_mod( 2 * self.__y, p ) ) % p x3 = ( l * l - 2 * self.__x ) % p y3 = ( l * ( self.__x - x3 ) - self.__y ) % p return Point( self.__curve, x3, y3 ) def x( self ): return self.__x def y( self ): return self.__y def curve( self ): return self.__curve def order( self ): return self.__order # This one point is the Point At Infinity for all purposes: INFINITY = Point( None, None, None ) def __main__(): class FailedTest(Exception): pass def test_add( c, x1, y1, x2, y2, x3, y3 ): """We expect that on curve c, (x1,y1) + (x2, y2 ) = (x3, y3).""" p1 = Point( c, x1, y1 ) p2 = Point( c, x2, y2 ) p3 = p1 + p2 print_("%s + %s = %s" % ( p1, p2, p3 ), end=' ') if p3.x() != x3 or p3.y() != y3: raise FailedTest("Failure: should give (%d,%d)." % ( x3, y3 )) else: print_(" Good.") def test_double( c, x1, y1, x3, y3 ): """We expect that on curve c, 2*(x1,y1) = (x3, y3).""" p1 = Point( c, x1, y1 ) p3 = p1.double() print_("%s doubled = %s" % ( p1, p3 ), end=' ') if p3.x() != x3 or p3.y() != y3: raise FailedTest("Failure: should give (%d,%d)." % ( x3, y3 )) else: print_(" Good.") def test_double_infinity( c ): """We expect that on curve c, 2*INFINITY = INFINITY.""" p1 = INFINITY p3 = p1.double() print_("%s doubled = %s" % ( p1, p3 ), end=' ') if p3.x() != INFINITY.x() or p3.y() != INFINITY.y(): raise FailedTest("Failure: should give (%d,%d)." % ( INFINITY.x(), INFINITY.y() )) else: print_(" Good.") def test_multiply( c, x1, y1, m, x3, y3 ): """We expect that on curve c, m*(x1,y1) = (x3,y3).""" p1 = Point( c, x1, y1 ) p3 = p1 * m print_("%s * %d = %s" % ( p1, m, p3 ), end=' ') if p3.x() != x3 or p3.y() != y3: raise FailedTest("Failure: should give (%d,%d)." % ( x3, y3 )) else: print_(" Good.") # A few tests from X9.62 B.3: c = CurveFp( 23, 1, 1 ) test_add( c, 3, 10, 9, 7, 17, 20 ) test_double( c, 3, 10, 7, 12 ) test_add( c, 3, 10, 3, 10, 7, 12 ) # (Should just invoke double.) test_multiply( c, 3, 10, 2, 7, 12 ) test_double_infinity(c) # From X9.62 I.1 (p. 96): g = Point( c, 13, 7, 7 ) check = INFINITY for i in range( 7 + 1 ): p = ( i % 7 ) * g print_("%s * %d = %s, expected %s . . ." % ( g, i, p, check ), end=' ') if p == check: print_(" Good.") else: raise FailedTest("Bad.") check = check + g # NIST Curve P-192: p = 6277101735386680763835789423207666416083908700390324961279 r = 6277101735386680763835789423176059013767194773182842284081 #s = 0x3045ae6fc8422f64ed579528d38120eae12196d5L c = 0x3099d2bbbfcb2538542dcd5fb078b6ef5f3d6fe2c745de65 b = 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1 Gx = 0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012 Gy = 0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811 c192 = CurveFp( p, -3, b ) p192 = Point( c192, Gx, Gy, r ) # Checking against some sample computations presented # in X9.62: d = 651056770906015076056810763456358567190100156695615665659 Q = d * p192 if Q.x() != 0x62B12D60690CDCF330BABAB6E69763B471F994DD702D16A5: raise FailedTest("p192 * d came out wrong.") else: print_("p192 * d came out right.") k = 6140507067065001063065065565667405560006161556565665656654 R = k * p192 if R.x() != 0x885052380FF147B734C330C43D39B2C4A89F29B0F749FEAD \ or R.y() != 0x9CF9FA1CBEFEFB917747A3BB29C072B9289C2547884FD835: raise FailedTest("k * p192 came out wrong.") else: print_("k * p192 came out right.") u1 = 2563697409189434185194736134579731015366492496392189760599 u2 = 6266643813348617967186477710235785849136406323338782220568 temp = u1 * p192 + u2 * Q if temp.x() != 0x885052380FF147B734C330C43D39B2C4A89F29B0F749FEAD \ or temp.y() != 0x9CF9FA1CBEFEFB917747A3BB29C072B9289C2547884FD835: raise FailedTest("u1 * p192 + u2 * Q came out wrong.") else: print_("u1 * p192 + u2 * Q came out right.") if __name__ == "__main__": __main__()
mit
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 24425, 402, 16028, 764, 1094, 2310, 12, 367, 13230, 9770, 13103, 14, 199, 3, 199, 3, 961, 859, 3181, 1133, 5647, 1263, 4340, 370, 11496, 282, 2196, 16028, 764, 199, 3, 15318, 12, 6590, 370, 4911, 626, 376, 16028, 764, 15318, 1990, 12414, 19311, 12, 199, 3, 2952, 1373, 883, 9329, 675, 653, 6225, 1159, 4465, 1094, 2310, 14, 199, 3, 199, 3, 8144, 687, 1323, 25, 14, 2789, 13, 23756, 334, 7185, 304, 199, 3, 257, 653, 1377, 78, 429, 1463, 26, 199, 3, 258, 446, 1413, 365, 282, 4575, 790, 14, 199, 3, 258, 710, 298, 23525, 764, 7319, 432, 14061, 3897, 2, 2387, 26, 199, 3, 258, 446, 1894, 365, 314, 298, 698, 1568, 401, 1314, 315, 4154, 1930, 18527, 299, 14, 199, 3, 258, 446, 299, 365, 282, 7282, 21619, 14, 199, 3, 258, 446, 598, 365, 282, 2376, 402, 21619, 1865, 334, 21, 14, 17, 14, 17, 14, 17, 680, 199, 3, 258, 446, 302, 365, 314, 1865, 402, 598, 334, 21, 14, 17, 14, 17, 14, 17, 680, 199, 3, 257, 1684, 13, 498, 6411, 334, 21, 14, 18, 14, 18, 304, 199, 3, 258, 446, 7635, 626, 1413, 365, 440, 314, 2376, 737, 23573, 14, 199, 3, 258, 446, 7635, 626, 1323, 63, 49, 436, 1488, 63, 49, 787, 315, 359, 16, 12, 80, 13, 17, 1055, 199, 3, 258, 446, 7635, 626, 1413, 365, 641, 314, 15318, 14, 199, 3, 258, 446, 7635, 626, 302, 49, 365, 314, 2376, 737, 23573, 14, 199, 3, 257, 18603, 10152, 334, 21, 14, 19, 304, 199, 3, 258, 446, 16568, 2196, 1022, 687, 359, 17, 12, 78, 13, 17, 1055, 199, 3, 257, 18603, 7907, 334, 21, 14, 20, 14, 18, 304, 199, 3, 258, 446, 7635, 626, 519, 436, 308, 787, 315, 359, 17, 12, 78, 13, 17, 1055, 199, 3, 199, 3, 3394, 402, 9079, 14, 845, 14, 821, 14, 199, 3, 199, 3, 27095, 7994, 26, 199, 3, 259, 11811, 14, 713, 14, 2192, 446, 6026, 1015, 14, 199, 3, 259, 9079, 14, 845, 14, 821, 446, 7743, 7319, 432, 38, 80, 14, 374, 63, 265, 370, 3509, 63, 1403, 14, 199, 3, 199, 3, 27694, 315, 11811, 701, 22912, 510, 2210, 834, 436, 15090, 315, 314, 4575, 2881, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 1275, 4174, 492, 870, 63, 199, 504, 1275, 492, 1329, 1589, 1089, 199, 199, 533, 7319, 432, 38, 80, 8, 909, 3461, 523, 408, 23525, 764, 7319, 432, 1806, 314, 901, 402, 9446, 27656, 282, 21619, 1041, 523, 347, 636, 826, 721, 291, 12, 299, 12, 282, 12, 330, 3461, 272, 408, 1918, 15318, 402, 4501, 23082, 316, 612, 62, 18, 275, 671, 62, 19, 435, 282, 10, 88, 435, 330, 334, 1494, 299, 10477, 272, 291, 855, 80, 275, 299, 272, 291, 855, 65, 275, 282, 272, 291, 855, 66, 275, 330, 819, 347, 299, 8, 291, 3461, 272, 372, 291, 855, 80, 819, 347, 282, 8, 291, 3461, 272, 372, 291, 855, 65, 819, 347, 330, 8, 291, 3461, 272, 372, 291, 855, 66, 819, 347, 3509, 63, 1403, 8, 291, 12, 671, 12, 612, 3461, 272, 408, 1831, 314, 2376, 334, 88, 12, 89, 9, 641, 642, 15318, 30196, 272, 372, 334, 612, 627, 612, 446, 334, 671, 627, 671, 627, 671, 435, 291, 855, 65, 627, 671, 435, 291, 855, 66, 776, 776, 450, 291, 855, 80, 508, 378, 4388, 199, 533, 7584, 8, 909, 3461, 523, 408, 33, 2376, 641, 376, 16028, 764, 15318, 14, 4580, 351, 316, 671, 436, 612, 365, 367, 17949, 1098, 12, 1362, 1325, 2985, 883, 506, 1586, 701, 314, 671, 342, 436, 612, 342, 3102, 1041, 523, 347, 636, 826, 721, 291, 12, 15318, 12, 671, 12, 612, 12, 1865, 275, 488, 3461, 272, 408, 11895, 12, 671, 12, 612, 12, 1865, 27, 1865, 334, 4144, 9, 365, 314, 1865, 402, 642, 2376, 1041, 272, 291, 855, 11895, 275, 15318, 272, 291, 855, 88, 275, 671, 272, 291, 855, 89, 275, 612, 272, 291, 855, 1648, 275, 1865, 272, 327, 291, 14, 11895, 365, 4370, 370, 506, 488, 1454, 367, 1621, 17383, 1922, 26, 272, 340, 291, 855, 11895, 26, 702, 291, 855, 11895, 14, 6134, 63, 1403, 8, 671, 12, 612, 776, 272, 340, 1865, 26, 702, 291, 627, 1865, 508, 1621, 17383, 1922, 819, 347, 636, 4077, 721, 291, 12, 1163, 3461, 272, 408, 1767, 715, 340, 314, 4501, 787, 13130, 12, 756, 4257, 1041, 272, 340, 291, 855, 11895, 508, 1163, 855, 11895, 971, 2126, 436, 291, 855, 88, 508, 1163, 855, 88, 971, 2126, 436, 291, 855, 89, 508, 1163, 855, 89, 26, 489, 372, 715, 272, 587, 26, 489, 372, 756, 819, 347, 636, 525, 721, 291, 12, 1163, 3461, 272, 408, 1123, 1373, 2376, 370, 4573, 2376, 1041, 339, 327, 1323, 25, 14, 2789, 699, 14, 19, 26, 339, 340, 1163, 508, 1621, 17383, 1922, 26, 372, 291, 272, 340, 291, 508, 1621, 17383, 1922, 26, 372, 1163, 272, 702, 291, 855, 11895, 508, 1163, 855, 11895, 272, 340, 291, 855, 88, 508, 1163, 855, 88, 26, 489, 340, 334, 291, 855, 89, 435, 1163, 855, 89, 776, 450, 291, 855, 11895, 14, 80, 342, 508, 378, 26, 267, 372, 1621, 17383, 1922, 489, 587, 26, 267, 372, 291, 14, 3157, 342, 339, 299, 275, 291, 855, 11895, 14, 80, 342, 339, 634, 275, 334, 334, 1163, 855, 89, 446, 291, 855, 89, 776, 627, 971, 881, 1329, 1589, 1089, 14, 11668, 63, 1494, 8, 1163, 855, 88, 446, 291, 855, 88, 12, 299, 776, 776, 450, 299, 339, 671, 19, 275, 334, 634, 627, 634, 446, 291, 855, 88, 446, 1163, 855, 88, 776, 450, 299, 272, 612, 19, 275, 334, 634, 627, 334, 291, 855, 88, 446, 671, 19, 776, 446, 291, 855, 89, 776, 450, 299, 339, 372, 7584, 8, 291, 855, 11895, 12, 671, 19, 12, 612, 19, 776, 819, 347, 636, 3703, 721, 291, 12, 1163, 3461, 272, 408, 25314, 590, 282, 2376, 701, 376, 3000, 1041, 339, 347, 29971, 63, 2075 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 24425, 402, 16028, 764, 1094, 2310, 12, 367, 13230, 9770, 13103, 14, 199, 3, 199, 3, 961, 859, 3181, 1133, 5647, 1263, 4340, 370, 11496, 282, 2196, 16028, 764, 199, 3, 15318, 12, 6590, 370, 4911, 626, 376, 16028, 764, 15318, 1990, 12414, 19311, 12, 199, 3, 2952, 1373, 883, 9329, 675, 653, 6225, 1159, 4465, 1094, 2310, 14, 199, 3, 199, 3, 8144, 687, 1323, 25, 14, 2789, 13, 23756, 334, 7185, 304, 199, 3, 257, 653, 1377, 78, 429, 1463, 26, 199, 3, 258, 446, 1413, 365, 282, 4575, 790, 14, 199, 3, 258, 710, 298, 23525, 764, 7319, 432, 14061, 3897, 2, 2387, 26, 199, 3, 258, 446, 1894, 365, 314, 298, 698, 1568, 401, 1314, 315, 4154, 1930, 18527, 299, 14, 199, 3, 258, 446, 299, 365, 282, 7282, 21619, 14, 199, 3, 258, 446, 598, 365, 282, 2376, 402, 21619, 1865, 334, 21, 14, 17, 14, 17, 14, 17, 680, 199, 3, 258, 446, 302, 365, 314, 1865, 402, 598, 334, 21, 14, 17, 14, 17, 14, 17, 680, 199, 3, 257, 1684, 13, 498, 6411, 334, 21, 14, 18, 14, 18, 304, 199, 3, 258, 446, 7635, 626, 1413, 365, 440, 314, 2376, 737, 23573, 14, 199, 3, 258, 446, 7635, 626, 1323, 63, 49, 436, 1488, 63, 49, 787, 315, 359, 16, 12, 80, 13, 17, 1055, 199, 3, 258, 446, 7635, 626, 1413, 365, 641, 314, 15318, 14, 199, 3, 258, 446, 7635, 626, 302, 49, 365, 314, 2376, 737, 23573, 14, 199, 3, 257, 18603, 10152, 334, 21, 14, 19, 304, 199, 3, 258, 446, 16568, 2196, 1022, 687, 359, 17, 12, 78, 13, 17, 1055, 199, 3, 257, 18603, 7907, 334, 21, 14, 20, 14, 18, 304, 199, 3, 258, 446, 7635, 626, 519, 436, 308, 787, 315, 359, 17, 12, 78, 13, 17, 1055, 199, 3, 199, 3, 3394, 402, 9079, 14, 845, 14, 821, 14, 199, 3, 199, 3, 27095, 7994, 26, 199, 3, 259, 11811, 14, 713, 14, 2192, 446, 6026, 1015, 14, 199, 3, 259, 9079, 14, 845, 14, 821, 446, 7743, 7319, 432, 38, 80, 14, 374, 63, 265, 370, 3509, 63, 1403, 14, 199, 3, 199, 3, 27694, 315, 11811, 701, 22912, 510, 2210, 834, 436, 15090, 315, 314, 4575, 2881, 14, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 1275, 4174, 492, 870, 63, 199, 504, 1275, 492, 1329, 1589, 1089, 199, 199, 533, 7319, 432, 38, 80, 8, 909, 3461, 523, 408, 23525, 764, 7319, 432, 1806, 314, 901, 402, 9446, 27656, 282, 21619, 1041, 523, 347, 636, 826, 721, 291, 12, 299, 12, 282, 12, 330, 3461, 272, 408, 1918, 15318, 402, 4501, 23082, 316, 612, 62, 18, 275, 671, 62, 19, 435, 282, 10, 88, 435, 330, 334, 1494, 299, 10477, 272, 291, 855, 80, 275, 299, 272, 291, 855, 65, 275, 282, 272, 291, 855, 66, 275, 330, 819, 347, 299, 8, 291, 3461, 272, 372, 291, 855, 80, 819, 347, 282, 8, 291, 3461, 272, 372, 291, 855, 65, 819, 347, 330, 8, 291, 3461, 272, 372, 291, 855, 66, 819, 347, 3509, 63, 1403, 8, 291, 12, 671, 12, 612, 3461, 272, 408, 1831, 314, 2376, 334, 88, 12, 89, 9, 641, 642, 15318, 30196, 272, 372, 334, 612, 627, 612, 446, 334, 671, 627, 671, 627, 671, 435, 291, 855, 65, 627, 671, 435, 291, 855, 66, 776, 776, 450, 291, 855, 80, 508, 378, 4388, 199, 533, 7584, 8, 909, 3461, 523, 408, 33, 2376, 641, 376, 16028, 764, 15318, 14, 4580, 351, 316, 671, 436, 612, 365, 367, 17949, 1098, 12, 1362, 1325, 2985, 883, 506, 1586, 701, 314, 671, 342, 436, 612, 342, 3102, 1041, 523, 347, 636, 826, 721, 291, 12, 15318, 12, 671, 12, 612, 12, 1865, 275, 488, 3461, 272, 408, 11895, 12, 671, 12, 612, 12, 1865, 27, 1865, 334, 4144, 9, 365, 314, 1865, 402, 642, 2376, 1041, 272, 291, 855, 11895, 275, 15318, 272, 291, 855, 88, 275, 671, 272, 291, 855, 89, 275, 612, 272, 291, 855, 1648, 275, 1865, 272, 327, 291, 14, 11895, 365, 4370, 370, 506, 488, 1454, 367, 1621, 17383, 1922, 26, 272, 340, 291, 855, 11895, 26, 702, 291, 855, 11895, 14, 6134, 63, 1403, 8, 671, 12, 612, 776, 272, 340, 1865, 26, 702, 291, 627, 1865, 508, 1621, 17383, 1922, 819, 347, 636, 4077, 721, 291, 12, 1163, 3461, 272, 408, 1767, 715, 340, 314, 4501, 787, 13130, 12, 756, 4257, 1041, 272, 340, 291, 855, 11895, 508, 1163, 855, 11895, 971, 2126, 436, 291, 855, 88, 508, 1163, 855, 88, 971, 2126, 436, 291, 855, 89, 508, 1163, 855, 89, 26, 489, 372, 715, 272, 587, 26, 489, 372, 756, 819, 347, 636, 525, 721, 291, 12, 1163, 3461, 272, 408, 1123, 1373, 2376, 370, 4573, 2376, 1041, 339, 327, 1323, 25, 14, 2789, 699, 14, 19, 26, 339, 340, 1163, 508, 1621, 17383, 1922, 26, 372, 291, 272, 340, 291, 508, 1621, 17383, 1922, 26, 372, 1163, 272, 702, 291, 855, 11895, 508, 1163, 855, 11895, 272, 340, 291, 855, 88, 508, 1163, 855, 88, 26, 489, 340, 334, 291, 855, 89, 435, 1163, 855, 89, 776, 450, 291, 855, 11895, 14, 80, 342, 508, 378, 26, 267, 372, 1621, 17383, 1922, 489, 587, 26, 267, 372, 291, 14, 3157, 342, 339, 299, 275, 291, 855, 11895, 14, 80, 342, 339, 634, 275, 334, 334, 1163, 855, 89, 446, 291, 855, 89, 776, 627, 971, 881, 1329, 1589, 1089, 14, 11668, 63, 1494, 8, 1163, 855, 88, 446, 291, 855, 88, 12, 299, 776, 776, 450, 299, 339, 671, 19, 275, 334, 634, 627, 634, 446, 291, 855, 88, 446, 1163, 855, 88, 776, 450, 299, 272, 612, 19, 275, 334, 634, 627, 334, 291, 855, 88, 446, 671, 19, 776, 446, 291, 855, 89, 776, 450, 299, 339, 372, 7584, 8, 291, 855, 11895, 12, 671, 19, 12, 612, 19, 776, 819, 347, 636, 3703, 721, 291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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
typpo/shadowsocks
shadowsocks/crypto/table.py
1044
8108
# !/usr/bin/env python # # Copyright 2015 clowwindy # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from __future__ import absolute_import, division, print_function, \ with_statement import string import struct import hashlib __all__ = ['ciphers'] cached_tables = {} if hasattr(string, 'maketrans'): maketrans = string.maketrans translate = string.translate else: maketrans = bytes.maketrans translate = bytes.translate def get_table(key): m = hashlib.md5() m.update(key) s = m.digest() a, b = struct.unpack('<QQ', s) table = maketrans(b'', b'') table = [table[i: i + 1] for i in range(len(table))] for i in range(1, 1024): table.sort(key=lambda x: int(a % (ord(x) + i))) return table def init_table(key): if key not in cached_tables: encrypt_table = b''.join(get_table(key)) decrypt_table = maketrans(encrypt_table, maketrans(b'', b'')) cached_tables[key] = [encrypt_table, decrypt_table] return cached_tables[key] class TableCipher(object): def __init__(self, cipher_name, key, iv, op): self._encrypt_table, self._decrypt_table = init_table(key) self._op = op def update(self, data): if self._op: return translate(data, self._encrypt_table) else: return translate(data, self._decrypt_table) ciphers = { 'table': (0, 0, TableCipher) } def test_table_result(): from shadowsocks.common import ord target1 = [ [60, 53, 84, 138, 217, 94, 88, 23, 39, 242, 219, 35, 12, 157, 165, 181, 255, 143, 83, 247, 162, 16, 31, 209, 190, 171, 115, 65, 38, 41, 21, 245, 236, 46, 121, 62, 166, 233, 44, 154, 153, 145, 230, 49, 128, 216, 173, 29, 241, 119, 64, 229, 194, 103, 131, 110, 26, 197, 218, 59, 204, 56, 27, 34, 141, 221, 149, 239, 192, 195, 24, 155, 170, 183, 11, 254, 213, 37, 137, 226, 75, 203, 55, 19, 72, 248, 22, 129, 33, 175, 178, 10, 198, 71, 77, 36, 113, 167, 48, 2, 117, 140, 142, 66, 199, 232, 243, 32, 123, 54, 51, 82, 57, 177, 87, 251, 150, 196, 133, 5, 253, 130, 8, 184, 14, 152, 231, 3, 186, 159, 76, 89, 228, 205, 156, 96, 163, 146, 18, 91, 132, 85, 80, 109, 172, 176, 105, 13, 50, 235, 127, 0, 189, 95, 98, 136, 250, 200, 108, 179, 211, 214, 106, 168, 78, 79, 74, 210, 30, 73, 201, 151, 208, 114, 101, 174, 92, 52, 120, 240, 15, 169, 220, 182, 81, 224, 43, 185, 40, 99, 180, 17, 212, 158, 42, 90, 9, 191, 45, 6, 25, 4, 222, 67, 126, 1, 116, 124, 206, 69, 61, 7, 68, 97, 202, 63, 244, 20, 28, 58, 93, 134, 104, 144, 227, 147, 102, 118, 135, 148, 47, 238, 86, 112, 122, 70, 107, 215, 100, 139, 223, 225, 164, 237, 111, 125, 207, 160, 187, 246, 234, 161, 188, 193, 249, 252], [151, 205, 99, 127, 201, 119, 199, 211, 122, 196, 91, 74, 12, 147, 124, 180, 21, 191, 138, 83, 217, 30, 86, 7, 70, 200, 56, 62, 218, 47, 168, 22, 107, 88, 63, 11, 95, 77, 28, 8, 188, 29, 194, 186, 38, 198, 33, 230, 98, 43, 148, 110, 177, 1, 109, 82, 61, 112, 219, 59, 0, 210, 35, 215, 50, 27, 103, 203, 212, 209, 235, 93, 84, 169, 166, 80, 130, 94, 164, 165, 142, 184, 111, 18, 2, 141, 232, 114, 6, 131, 195, 139, 176, 220, 5, 153, 135, 213, 154, 189, 238, 174, 226, 53, 222, 146, 162, 236, 158, 143, 55, 244, 233, 96, 173, 26, 206, 100, 227, 49, 178, 34, 234, 108, 207, 245, 204, 150, 44, 87, 121, 54, 140, 118, 221, 228, 155, 78, 3, 239, 101, 64, 102, 17, 223, 41, 137, 225, 229, 66, 116, 171, 125, 40, 39, 71, 134, 13, 193, 129, 247, 251, 20, 136, 242, 14, 36, 97, 163, 181, 72, 25, 144, 46, 175, 89, 145, 113, 90, 159, 190, 15, 183, 73, 123, 187, 128, 248, 252, 152, 24, 197, 68, 253, 52, 69, 117, 57, 92, 104, 157, 170, 214, 81, 60, 133, 208, 246, 172, 23, 167, 160, 192, 76, 161, 237, 45, 4, 58, 10, 182, 65, 202, 240, 185, 241, 79, 224, 132, 51, 42, 126, 105, 37, 250, 149, 32, 243, 231, 67, 179, 48, 9, 106, 216, 31, 249, 19, 85, 254, 156, 115, 255, 120, 75, 16]] target2 = [ [124, 30, 170, 247, 27, 127, 224, 59, 13, 22, 196, 76, 72, 154, 32, 209, 4, 2, 131, 62, 101, 51, 230, 9, 166, 11, 99, 80, 208, 112, 36, 248, 81, 102, 130, 88, 218, 38, 168, 15, 241, 228, 167, 117, 158, 41, 10, 180, 194, 50, 204, 243, 246, 251, 29, 198, 219, 210, 195, 21, 54, 91, 203, 221, 70, 57, 183, 17, 147, 49, 133, 65, 77, 55, 202, 122, 162, 169, 188, 200, 190, 125, 63, 244, 96, 31, 107, 106, 74, 143, 116, 148, 78, 46, 1, 137, 150, 110, 181, 56, 95, 139, 58, 3, 231, 66, 165, 142, 242, 43, 192, 157, 89, 175, 109, 220, 128, 0, 178, 42, 255, 20, 214, 185, 83, 160, 253, 7, 23, 92, 111, 153, 26, 226, 33, 176, 144, 18, 216, 212, 28, 151, 71, 206, 222, 182, 8, 174, 205, 201, 152, 240, 155, 108, 223, 104, 239, 98, 164, 211, 184, 34, 193, 14, 114, 187, 40, 254, 12, 67, 93, 217, 6, 94, 16, 19, 82, 86, 245, 24, 197, 134, 132, 138, 229, 121, 5, 235, 238, 85, 47, 103, 113, 179, 69, 250, 45, 135, 156, 25, 61, 75, 44, 146, 189, 84, 207, 172, 119, 53, 123, 186, 120, 171, 68, 227, 145, 136, 100, 90, 48, 79, 159, 149, 39, 213, 236, 126, 52, 60, 225, 199, 105, 73, 233, 252, 118, 215, 35, 115, 64, 37, 97, 129, 161, 177, 87, 237, 141, 173, 191, 163, 140, 234, 232, 249], [117, 94, 17, 103, 16, 186, 172, 127, 146, 23, 46, 25, 168, 8, 163, 39, 174, 67, 137, 175, 121, 59, 9, 128, 179, 199, 132, 4, 140, 54, 1, 85, 14, 134, 161, 238, 30, 241, 37, 224, 166, 45, 119, 109, 202, 196, 93, 190, 220, 69, 49, 21, 228, 209, 60, 73, 99, 65, 102, 7, 229, 200, 19, 82, 240, 71, 105, 169, 214, 194, 64, 142, 12, 233, 88, 201, 11, 72, 92, 221, 27, 32, 176, 124, 205, 189, 177, 246, 35, 112, 219, 61, 129, 170, 173, 100, 84, 242, 157, 26, 218, 20, 33, 191, 155, 232, 87, 86, 153, 114, 97, 130, 29, 192, 164, 239, 90, 43, 236, 208, 212, 185, 75, 210, 0, 81, 227, 5, 116, 243, 34, 18, 182, 70, 181, 197, 217, 95, 183, 101, 252, 248, 107, 89, 136, 216, 203, 68, 91, 223, 96, 141, 150, 131, 13, 152, 198, 111, 44, 222, 125, 244, 76, 251, 158, 106, 24, 42, 38, 77, 2, 213, 207, 249, 147, 113, 135, 245, 118, 193, 47, 98, 145, 66, 160, 123, 211, 165, 78, 204, 80, 250, 110, 162, 48, 58, 10, 180, 55, 231, 79, 149, 74, 62, 50, 148, 143, 206, 28, 15, 57, 159, 139, 225, 122, 237, 138, 171, 36, 56, 115, 63, 144, 154, 6, 230, 133, 215, 41, 184, 22, 104, 254, 234, 253, 187, 226, 247, 188, 156, 151, 40, 108, 51, 83, 178, 52, 3, 31, 255, 195, 53, 235, 126, 167, 120]] encrypt_table = b''.join(get_table(b'foobar!')) decrypt_table = maketrans(encrypt_table, maketrans(b'', b'')) for i in range(0, 256): assert (target1[0][i] == ord(encrypt_table[i])) assert (target1[1][i] == ord(decrypt_table[i])) encrypt_table = b''.join(get_table(b'barfoo!')) decrypt_table = maketrans(encrypt_table, maketrans(b'', b'')) for i in range(0, 256): assert (target2[0][i] == ord(encrypt_table[i])) assert (target2[1][i] == ord(decrypt_table[i])) def test_encryption(): from shadowsocks.crypto import util cipher = TableCipher('table', b'test', b'', 1) decipher = TableCipher('table', b'test', b'', 0) util.run_cipher(cipher, decipher) if __name__ == '__main__': test_table_result() test_encryption()
apache-2.0
[ 3, 8546, 15, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 1059, 199, 646, 2702, 199, 646, 8337, 421, 199, 363, 452, 363, 275, 788, 27426, 418, 199, 199, 5245, 63, 5987, 275, 1052, 199, 199, 692, 2688, 8, 875, 12, 283, 22191, 31552, 735, 272, 5475, 31552, 275, 1059, 14, 22191, 31552, 272, 9028, 275, 1059, 14, 5275, 199, 2836, 26, 272, 5475, 31552, 275, 2783, 14, 22191, 31552, 272, 9028, 275, 2783, 14, 5275, 421, 199, 318, 664, 63, 1224, 8, 498, 304, 272, 333, 275, 8337, 14, 1064, 21, 342, 272, 333, 14, 873, 8, 498, 9, 272, 308, 275, 333, 14, 5671, 342, 272, 282, 12, 330, 275, 2702, 14, 5301, 4827, 12917, 297, 308, 9, 272, 1817, 275, 5475, 31552, 8, 66, 6448, 330, 17483, 272, 1817, 275, 359, 1224, 59, 73, 26, 284, 435, 413, 61, 367, 284, 315, 1425, 8, 552, 8, 1224, 10524, 272, 367, 284, 315, 1425, 8, 17, 12, 6619, 304, 267, 1817, 14, 3191, 8, 498, 29, 2734, 671, 26, 1109, 8, 65, 450, 334, 2181, 8, 88, 9, 435, 284, 1724, 272, 372, 1817, 421, 199, 318, 4205, 63, 1224, 8, 498, 304, 272, 340, 790, 440, 315, 6328, 63, 5987, 26, 267, 14645, 63, 1224, 275, 330, 17067, 904, 8, 362, 63, 1224, 8, 498, 430, 267, 20090, 63, 1224, 275, 5475, 31552, 8, 11929, 63, 1224, 12, 5475, 31552, 8, 66, 6448, 330, 7, 1333, 267, 6328, 63, 5987, 59, 498, 61, 275, 359, 11929, 63, 1224, 12, 20090, 63, 1224, 61, 272, 372, 6328, 63, 5987, 59, 498, 61, 421, 199, 533, 6957, 21967, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10830, 63, 354, 12, 790, 12, 18831, 12, 1687, 304, 267, 291, 423, 11929, 63, 1224, 12, 291, 423, 15682, 63, 1224, 275, 4205, 63, 1224, 8, 498, 9, 267, 291, 423, 411, 275, 1687, 339, 347, 1678, 8, 277, 12, 666, 304, 267, 340, 291, 423, 411, 26, 288, 372, 9028, 8, 576, 12, 291, 423, 11929, 63, 1224, 9, 267, 587, 26, 288, 372, 9028, 8, 576, 12, 291, 423, 15682, 63, 1224, 9, 421, 199, 27426, 275, 469, 272, 283, 1224, 356, 334, 16, 12, 378, 12, 6957, 21967, 9, 199, 93, 421, 199, 318, 511, 63, 1224, 63, 1099, 837, 272, 687, 15084, 21234, 14, 2330, 492, 6206, 272, 1347, 17, 275, 359, 267, 359, 2259, 12, 13564, 12, 8264, 12, 26309, 12, 499, 1196, 12, 18729, 12, 10523, 12, 6546, 12, 10551, 12, 499, 2260, 12, 499, 1167, 12, 8685, 12, 3144, 12, 32400, 12, 31852, 12, 413, 2835, 12, 268, 5450, 12, 29235, 12, 20582, 12, 499, 2417, 12, 32729, 12, 3193, 12, 7105, 12, 499, 1643, 12, 29682, 12, 413, 3172, 12, 22560, 12, 11738, 12, 10448, 12, 13385, 12, 7829, 12, 268, 32102, 12, 499, 1344, 12, 12426, 12, 26228, 12, 16202, 12, 29923, 12, 499, 1153, 12, 10868, 12, 31693, 12, 25828, 12, 28818, 12, 28700, 12, 12260, 12, 7960, 12, 30630, 12, 268, 413, 2898, 12, 7349, 12, 499, 2953, 12, 26497, 12, 5049, 12, 499, 1398, 12, 413, 2635, 12, 22363, 12, 30542, 12, 16814, 12, 7875, 12, 413, 2576, 12, 32319, 12, 8155, 12, 14785, 12, 268, 12001, 12, 8087, 12, 8177, 12, 413, 2953, 12, 499, 2025, 12, 28528, 12, 499, 1355, 12, 13567, 12, 413, 2720, 12, 5504, 12, 29710, 12, 27209, 12, 413, 2658, 12, 4119, 12, 22540, 12, 268, 499, 969, 12, 6877, 12, 27750, 12, 32584, 12, 13098, 12, 29202, 12, 12766, 12, 5851, 12, 15323, 12, 499, 2006, 12, 6928, 12, 25454, 12, 9404, 12, 27306, 12, 413, 2277, 12, 268, 1616, 12, 413, 2905, 12, 17245, 12, 8375, 12, 8780, 12, 24073, 12, 31650, 12, 9615, 12, 499, 12, 26189, 12, 22796, 12, 31308, 12, 14157, 12, 9013, 12, 499, 708, 12, 268, 499, 2824, 12, 4337, 12, 11869, 12, 13470, 12, 8026, 12, 18051, 12, 12699, 12, 413, 1138, 12, 10513, 12, 499, 2869, 12, 14711, 12, 32132, 12, 28416, 12, 959, 12, 26727, 12, 268, 21334, 12, 1695, 12, 27631, 12, 4329, 12, 413, 2528, 12, 499, 2192, 12, 650, 12, 413, 1184, 12, 413, 1427, 12, 14646, 12, 17838, 12, 499, 1651, 12, 24005, 12, 32609, 12, 15580, 12, 268, 24619, 12, 31263, 12, 6155, 12, 21358, 12, 27207, 12, 16412, 12, 5939, 12, 24058, 12, 24911, 12, 27827, 12, 20462, 12, 4944, 12, 5238, 12, 31071, 12, 12792, 12, 268, 378, 12, 31446, 12, 16102, 12, 16096, 12, 27208, 12, 16074, 12, 1926, 12, 24579, 12, 31420, 12, 30301, 12, 21237, 12, 23746, 12, 413, 2333, 12, 14679, 12, 13734, 12, 268, 9720, 12, 26160, 12, 4233, 12, 18525, 12, 1784, 12, 413, 2869, 12, 29203, 12, 23510, 12, 14313, 12, 30698, 12, 20140, 12, 14589, 12, 13960, 12, 21883, 12, 4114, 12, 268, 20680, 12, 25647, 12, 413, 2564, 12, 19071, 12, 18565, 12, 11851, 12, 413, 2426, 12, 6335, 12, 8806, 12, 13576, 12, 5557, 12, 29532, 12, 413, 2010, 12, 5685, 12, 9137, 12, 1749, 12, 268, 413, 3328, 12, 10416, 12, 1227, 12, 5661, 12, 841, 12, 26485, 12, 13296, 12, 21572, 12, 413 ]
[ 8546, 15, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 6900, 286, 674, 11530, 89, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 12, 971, 272, 543, 63, 6242, 199, 199, 646, 1059, 199, 646, 2702, 199, 646, 8337, 421, 199, 363, 452, 363, 275, 788, 27426, 418, 199, 199, 5245, 63, 5987, 275, 1052, 199, 199, 692, 2688, 8, 875, 12, 283, 22191, 31552, 735, 272, 5475, 31552, 275, 1059, 14, 22191, 31552, 272, 9028, 275, 1059, 14, 5275, 199, 2836, 26, 272, 5475, 31552, 275, 2783, 14, 22191, 31552, 272, 9028, 275, 2783, 14, 5275, 421, 199, 318, 664, 63, 1224, 8, 498, 304, 272, 333, 275, 8337, 14, 1064, 21, 342, 272, 333, 14, 873, 8, 498, 9, 272, 308, 275, 333, 14, 5671, 342, 272, 282, 12, 330, 275, 2702, 14, 5301, 4827, 12917, 297, 308, 9, 272, 1817, 275, 5475, 31552, 8, 66, 6448, 330, 17483, 272, 1817, 275, 359, 1224, 59, 73, 26, 284, 435, 413, 61, 367, 284, 315, 1425, 8, 552, 8, 1224, 10524, 272, 367, 284, 315, 1425, 8, 17, 12, 6619, 304, 267, 1817, 14, 3191, 8, 498, 29, 2734, 671, 26, 1109, 8, 65, 450, 334, 2181, 8, 88, 9, 435, 284, 1724, 272, 372, 1817, 421, 199, 318, 4205, 63, 1224, 8, 498, 304, 272, 340, 790, 440, 315, 6328, 63, 5987, 26, 267, 14645, 63, 1224, 275, 330, 17067, 904, 8, 362, 63, 1224, 8, 498, 430, 267, 20090, 63, 1224, 275, 5475, 31552, 8, 11929, 63, 1224, 12, 5475, 31552, 8, 66, 6448, 330, 7, 1333, 267, 6328, 63, 5987, 59, 498, 61, 275, 359, 11929, 63, 1224, 12, 20090, 63, 1224, 61, 272, 372, 6328, 63, 5987, 59, 498, 61, 421, 199, 533, 6957, 21967, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 10830, 63, 354, 12, 790, 12, 18831, 12, 1687, 304, 267, 291, 423, 11929, 63, 1224, 12, 291, 423, 15682, 63, 1224, 275, 4205, 63, 1224, 8, 498, 9, 267, 291, 423, 411, 275, 1687, 339, 347, 1678, 8, 277, 12, 666, 304, 267, 340, 291, 423, 411, 26, 288, 372, 9028, 8, 576, 12, 291, 423, 11929, 63, 1224, 9, 267, 587, 26, 288, 372, 9028, 8, 576, 12, 291, 423, 15682, 63, 1224, 9, 421, 199, 27426, 275, 469, 272, 283, 1224, 356, 334, 16, 12, 378, 12, 6957, 21967, 9, 199, 93, 421, 199, 318, 511, 63, 1224, 63, 1099, 837, 272, 687, 15084, 21234, 14, 2330, 492, 6206, 272, 1347, 17, 275, 359, 267, 359, 2259, 12, 13564, 12, 8264, 12, 26309, 12, 499, 1196, 12, 18729, 12, 10523, 12, 6546, 12, 10551, 12, 499, 2260, 12, 499, 1167, 12, 8685, 12, 3144, 12, 32400, 12, 31852, 12, 413, 2835, 12, 268, 5450, 12, 29235, 12, 20582, 12, 499, 2417, 12, 32729, 12, 3193, 12, 7105, 12, 499, 1643, 12, 29682, 12, 413, 3172, 12, 22560, 12, 11738, 12, 10448, 12, 13385, 12, 7829, 12, 268, 32102, 12, 499, 1344, 12, 12426, 12, 26228, 12, 16202, 12, 29923, 12, 499, 1153, 12, 10868, 12, 31693, 12, 25828, 12, 28818, 12, 28700, 12, 12260, 12, 7960, 12, 30630, 12, 268, 413, 2898, 12, 7349, 12, 499, 2953, 12, 26497, 12, 5049, 12, 499, 1398, 12, 413, 2635, 12, 22363, 12, 30542, 12, 16814, 12, 7875, 12, 413, 2576, 12, 32319, 12, 8155, 12, 14785, 12, 268, 12001, 12, 8087, 12, 8177, 12, 413, 2953, 12, 499, 2025, 12, 28528, 12, 499, 1355, 12, 13567, 12, 413, 2720, 12, 5504, 12, 29710, 12, 27209, 12, 413, 2658, 12, 4119, 12, 22540, 12, 268, 499, 969, 12, 6877, 12, 27750, 12, 32584, 12, 13098, 12, 29202, 12, 12766, 12, 5851, 12, 15323, 12, 499, 2006, 12, 6928, 12, 25454, 12, 9404, 12, 27306, 12, 413, 2277, 12, 268, 1616, 12, 413, 2905, 12, 17245, 12, 8375, 12, 8780, 12, 24073, 12, 31650, 12, 9615, 12, 499, 12, 26189, 12, 22796, 12, 31308, 12, 14157, 12, 9013, 12, 499, 708, 12, 268, 499, 2824, 12, 4337, 12, 11869, 12, 13470, 12, 8026, 12, 18051, 12, 12699, 12, 413, 1138, 12, 10513, 12, 499, 2869, 12, 14711, 12, 32132, 12, 28416, 12, 959, 12, 26727, 12, 268, 21334, 12, 1695, 12, 27631, 12, 4329, 12, 413, 2528, 12, 499, 2192, 12, 650, 12, 413, 1184, 12, 413, 1427, 12, 14646, 12, 17838, 12, 499, 1651, 12, 24005, 12, 32609, 12, 15580, 12, 268, 24619, 12, 31263, 12, 6155, 12, 21358, 12, 27207, 12, 16412, 12, 5939, 12, 24058, 12, 24911, 12, 27827, 12, 20462, 12, 4944, 12, 5238, 12, 31071, 12, 12792, 12, 268, 378, 12, 31446, 12, 16102, 12, 16096, 12, 27208, 12, 16074, 12, 1926, 12, 24579, 12, 31420, 12, 30301, 12, 21237, 12, 23746, 12, 413, 2333, 12, 14679, 12, 13734, 12, 268, 9720, 12, 26160, 12, 4233, 12, 18525, 12, 1784, 12, 413, 2869, 12, 29203, 12, 23510, 12, 14313, 12, 30698, 12, 20140, 12, 14589, 12, 13960, 12, 21883, 12, 4114, 12, 268, 20680, 12, 25647, 12, 413, 2564, 12, 19071, 12, 18565, 12, 11851, 12, 413, 2426, 12, 6335, 12, 8806, 12, 13576, 12, 5557, 12, 29532, 12, 413, 2010, 12, 5685, 12, 9137, 12, 1749, 12, 268, 413, 3328, 12, 10416, 12, 1227, 12, 5661, 12, 841, 12, 26485, 12, 13296, 12, 21572, 12, 413, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
thiriel/maps
venv/lib/python2.7/site-packages/django/contrib/gis/db/backends/spatialite/creation.py
78
5863
import os from django.conf import settings from django.core.cache import get_cache from django.core.cache.backends.db import BaseDatabaseCache from django.core.exceptions import ImproperlyConfigured from django.db.backends.sqlite3.creation import DatabaseCreation class SpatiaLiteCreation(DatabaseCreation): def create_test_db(self, verbosity=1, autoclobber=False): """ Creates a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created. This method is overloaded to load up the SpatiaLite initialization SQL prior to calling the `syncdb` command. """ # Don't import django.core.management if it isn't needed. from django.core.management import call_command test_database_name = self._get_test_db_name() if verbosity >= 1: test_db_repr = '' if verbosity >= 2: test_db_repr = " ('%s')" % test_database_name print "Creating test database for alias '%s'%s..." % (self.connection.alias, test_db_repr) self._create_test_db(verbosity, autoclobber) self.connection.close() self.connection.settings_dict["NAME"] = test_database_name # Confirm the feature set of the test database self.connection.features.confirm() # Need to load the SpatiaLite initialization SQL before running `syncdb`. self.load_spatialite_sql() # Report syncdb messages at one level lower than that requested. # This ensures we don't get flooded with messages during testing # (unless you really ask to be flooded) call_command('syncdb', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias, load_initial_data=False) # We need to then do a flush to ensure that any data installed by # custom SQL has been removed. The only test data should come from # test fixtures, or autogenerated from post_syncdb triggers. # This has the side effect of loading initial data (which was # intentionally skipped in the syncdb). call_command('flush', verbosity=max(verbosity - 1, 0), interactive=False, database=self.connection.alias) from django.core.cache import get_cache from django.core.cache.backends.db import BaseDatabaseCache for cache_alias in settings.CACHES: cache = get_cache(cache_alias) if isinstance(cache, BaseDatabaseCache): call_command('createcachetable', cache._table, database=self.connection.alias) # Get a cursor (even though we don't need one yet). This has # the side effect of initializing the test database. cursor = self.connection.cursor() return test_database_name def sql_indexes_for_field(self, model, f, style): "Return any spatial index creation SQL for the field." from django.contrib.gis.db.models.fields import GeometryField output = super(SpatiaLiteCreation, self).sql_indexes_for_field(model, f, style) if isinstance(f, GeometryField): gqn = self.connection.ops.geo_quote_name qn = self.connection.ops.quote_name db_table = model._meta.db_table output.append(style.SQL_KEYWORD('SELECT ') + style.SQL_TABLE('AddGeometryColumn') + '(' + style.SQL_TABLE(gqn(db_table)) + ', ' + style.SQL_FIELD(gqn(f.column)) + ', ' + style.SQL_FIELD(str(f.srid)) + ', ' + style.SQL_COLTYPE(gqn(f.geom_type)) + ', ' + style.SQL_KEYWORD(str(f.dim)) + ', ' + style.SQL_KEYWORD(str(int(not f.null))) + ');') if f.spatial_index: output.append(style.SQL_KEYWORD('SELECT ') + style.SQL_TABLE('CreateSpatialIndex') + '(' + style.SQL_TABLE(gqn(db_table)) + ', ' + style.SQL_FIELD(gqn(f.column)) + ');') return output def load_spatialite_sql(self): """ This routine loads up the SpatiaLite SQL file. """ if self.connection.ops.spatial_version[:2] >= (3, 0): # Spatialite >= 3.0.x -- No need to load any SQL file, calling # InitSpatialMetaData() transparently creates the spatial metadata # tables cur = self.connection._cursor() cur.execute("SELECT InitSpatialMetaData()") else: # Spatialite < 3.0.x -- Load the initial SQL # Getting the location of the SpatiaLite SQL file, and confirming # it exists. spatialite_sql = self.spatialite_init_file() if not os.path.isfile(spatialite_sql): raise ImproperlyConfigured('Could not find the required SpatiaLite initialization ' 'SQL file (necessary for testing): %s' % spatialite_sql) # Opening up the SpatiaLite SQL initialization file and executing # as a script. sql_fh = open(spatialite_sql, 'r') try: cur = self.connection._cursor() cur.executescript(sql_fh.read()) finally: sql_fh.close() def spatialite_init_file(self): # SPATIALITE_SQL may be placed in settings to tell GeoDjango # to use a specific path to the SpatiaLite initilization SQL. return getattr(settings, 'SPATIALITE_SQL', 'init_spatialite-%s.%s.sql' % self.connection.ops.spatial_version[:2])
bsd-3-clause
[ 646, 747, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 697, 492, 29103, 4437, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 7765, 14, 10659, 19, 14, 8782, 492, 8692, 13921, 199, 199, 533, 25177, 13921, 8, 7243, 13921, 304, 339, 347, 1218, 63, 396, 63, 697, 8, 277, 12, 8661, 29, 17, 12, 6384, 679, 22669, 29, 797, 304, 267, 408, 267, 10560, 282, 511, 3050, 12, 21652, 1337, 314, 922, 367, 18791, 340, 314, 267, 3050, 2575, 3495, 14, 1803, 314, 536, 402, 314, 511, 3050, 2737, 14, 398, 961, 1083, 365, 1806, 4591, 370, 2248, 1536, 314, 25177, 11097, 267, 5385, 6791, 370, 6358, 314, 658, 5186, 697, 64, 1414, 14, 267, 408, 267, 327, 7529, 1133, 492, 1639, 14, 1018, 14, 8110, 340, 652, 5712, 1133, 4346, 14, 267, 687, 1639, 14, 1018, 14, 8110, 492, 1240, 63, 1531, 398, 511, 63, 4659, 63, 354, 275, 291, 423, 362, 63, 396, 63, 697, 63, 354, 342, 398, 340, 8661, 2356, 413, 26, 288, 511, 63, 697, 63, 2722, 275, 2125, 288, 340, 8661, 2356, 499, 26, 355, 511, 63, 697, 63, 2722, 275, 298, 16651, 83, 19124, 450, 511, 63, 4659, 63, 354, 288, 870, 298, 14380, 511, 3050, 367, 5162, 1543, 83, 5956, 83, 11500, 450, 334, 277, 14, 2105, 14, 3620, 12, 511, 63, 697, 63, 2722, 9, 398, 291, 423, 981, 63, 396, 63, 697, 8, 9833, 12, 6384, 679, 22669, 9, 398, 291, 14, 2105, 14, 1600, 342, 267, 291, 14, 2105, 14, 1751, 63, 807, 905, 2339, 937, 275, 511, 63, 4659, 63, 354, 398, 327, 32112, 314, 3878, 663, 402, 314, 511, 3050, 267, 291, 14, 2105, 14, 3179, 14, 9548, 342, 398, 327, 14012, 370, 2248, 314, 25177, 11097, 5385, 2544, 3879, 658, 5186, 697, 2313, 267, 291, 14, 912, 63, 25873, 63, 3009, 342, 398, 327, 11774, 7604, 697, 3788, 737, 1373, 2166, 5117, 2419, 626, 5839, 14, 267, 327, 961, 15620, 781, 2793, 1133, 664, 289, 320, 380, 68, 543, 3788, 5309, 5343, 267, 327, 334, 18447, 1265, 7710, 7198, 370, 506, 289, 320, 380, 68, 9, 267, 1240, 63, 1531, 360, 5186, 697, 297, 288, 8661, 29, 988, 8, 9833, 446, 413, 12, 378, 395, 288, 12777, 29, 797, 12, 288, 3050, 29, 277, 14, 2105, 14, 3620, 12, 288, 2248, 63, 2747, 63, 576, 29, 797, 9, 398, 327, 2136, 1929, 370, 2066, 886, 282, 8976, 370, 4868, 626, 1263, 666, 4903, 701, 267, 327, 3537, 5385, 965, 2757, 4829, 14, 710, 1454, 511, 666, 1077, 11492, 687, 267, 327, 511, 15188, 12, 503, 18392, 687, 2963, 63, 5186, 697, 18899, 14, 267, 327, 961, 965, 314, 5366, 7763, 402, 8697, 2536, 666, 334, 6777, 1990, 267, 327, 32005, 9645, 315, 314, 7604, 697, 680, 267, 1240, 63, 1531, 360, 4939, 297, 288, 8661, 29, 988, 8, 9833, 446, 413, 12, 378, 395, 288, 12777, 29, 797, 12, 288, 3050, 29, 277, 14, 2105, 14, 3620, 9, 398, 687, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 267, 687, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 697, 492, 29103, 4437, 267, 367, 2581, 63, 3620, 315, 2202, 14, 3263, 1244, 654, 26, 288, 2581, 275, 664, 63, 1637, 8, 1637, 63, 3620, 9, 288, 340, 1228, 8, 1637, 12, 29103, 4437, 304, 355, 1240, 63, 1531, 360, 981, 20138, 386, 461, 297, 2581, 423, 1224, 12, 3050, 29, 277, 14, 2105, 14, 3620, 9, 398, 327, 2372, 282, 3920, 334, 12056, 10617, 781, 2793, 1133, 1929, 1373, 5966, 680, 961, 965, 267, 327, 314, 5366, 7763, 402, 29141, 314, 511, 3050, 14, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 398, 372, 511, 63, 4659, 63, 354, 339, 347, 3875, 63, 10116, 63, 509, 63, 698, 8, 277, 12, 1402, 12, 289, 12, 3449, 304, 267, 298, 1767, 1263, 11469, 1478, 7143, 5385, 367, 314, 901, 2122, 267, 687, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 14, 955, 492, 30490, 398, 1072, 275, 1613, 8, 12739, 23675, 13921, 12, 291, 680, 3009, 63, 10116, 63, 509, 63, 698, 8, 1238, 12, 289, 12, 3449, 9, 398, 340, 1228, 8, 70, 12, 30490, 304, 288, 486, 15156, 275, 291, 14, 2105, 14, 1483, 14, 6721, 63, 3513, 63, 354, 288, 18293, 275, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 288, 1592, 63, 1224, 275, 1402, 423, 2024, 14, 697, 63, 1224, 953, 1072, 14, 740, 8, 2487, 14, 4657, 63, 17714, 360, 4859, 5320, 435, 2079, 3449, 14, 4657, 63, 8723, 360, 1123, 6831, 4547, 358, 435, 16746, 435, 2079, 3449, 14, 4657, 63, 8723, 8, 71, 15156, 8, 697, 63, 1224, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 8609, 8, 71, 15156, 8, 70, 14, 2301, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 8609, 8, 495, 8, 70, 14, 10498, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 3978, 2711, 8, 71, 15156, 8, 70, 14, 6481, 63, 466, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 17714, 8, 495, 8, 70, 14, 3572, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 17714, 8, 495, 8, 442, 8, 1397, 289, 14, 2307, 1724, 435, 2079, 283, 2736, 358, 953, 340, 289, 14, 11679, 63, 1080, 26, 355, 1072, 14, 740, 8, 2487, 14, 4657, 63, 17714, 360, 4859, 5320, 435, 2892, 3449, 14, 4657, 63, 8723, 360, 2499, 18075, 2681, 358, 435, 16746, 435, 2892, 3449, 14, 4657, 63, 8723, 8, 71, 15156, 8, 697, 63, 1224, 430, 435, 1656, 283, 435, 2892, 3449, 14, 4657, 63, 8609, 8, 71, 15156, 8, 70, 14, 2301, 430, 435, 283, 2736, 358, 398, 372, 1072, 339, 347, 2248, 63, 25873, 63, 3009, 8, 277, 304, 267, 408, 267, 961, 12981, 14404, 1536, 314, 25177, 5385, 570, 14, 267, 408, 267, 340, 291, 14, 2105, 14, 1483, 14, 11679, 63, 1023, 1491, 18, 61, 2356, 334, 19, 12, 378, 304, 288, 327, 13423, 1175, 2356, 650 ]
[ 747, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 199, 504, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 697, 492, 29103, 4437, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 697, 14, 7765, 14, 10659, 19, 14, 8782, 492, 8692, 13921, 199, 199, 533, 25177, 13921, 8, 7243, 13921, 304, 339, 347, 1218, 63, 396, 63, 697, 8, 277, 12, 8661, 29, 17, 12, 6384, 679, 22669, 29, 797, 304, 267, 408, 267, 10560, 282, 511, 3050, 12, 21652, 1337, 314, 922, 367, 18791, 340, 314, 267, 3050, 2575, 3495, 14, 1803, 314, 536, 402, 314, 511, 3050, 2737, 14, 398, 961, 1083, 365, 1806, 4591, 370, 2248, 1536, 314, 25177, 11097, 267, 5385, 6791, 370, 6358, 314, 658, 5186, 697, 64, 1414, 14, 267, 408, 267, 327, 7529, 1133, 492, 1639, 14, 1018, 14, 8110, 340, 652, 5712, 1133, 4346, 14, 267, 687, 1639, 14, 1018, 14, 8110, 492, 1240, 63, 1531, 398, 511, 63, 4659, 63, 354, 275, 291, 423, 362, 63, 396, 63, 697, 63, 354, 342, 398, 340, 8661, 2356, 413, 26, 288, 511, 63, 697, 63, 2722, 275, 2125, 288, 340, 8661, 2356, 499, 26, 355, 511, 63, 697, 63, 2722, 275, 298, 16651, 83, 19124, 450, 511, 63, 4659, 63, 354, 288, 870, 298, 14380, 511, 3050, 367, 5162, 1543, 83, 5956, 83, 11500, 450, 334, 277, 14, 2105, 14, 3620, 12, 511, 63, 697, 63, 2722, 9, 398, 291, 423, 981, 63, 396, 63, 697, 8, 9833, 12, 6384, 679, 22669, 9, 398, 291, 14, 2105, 14, 1600, 342, 267, 291, 14, 2105, 14, 1751, 63, 807, 905, 2339, 937, 275, 511, 63, 4659, 63, 354, 398, 327, 32112, 314, 3878, 663, 402, 314, 511, 3050, 267, 291, 14, 2105, 14, 3179, 14, 9548, 342, 398, 327, 14012, 370, 2248, 314, 25177, 11097, 5385, 2544, 3879, 658, 5186, 697, 2313, 267, 291, 14, 912, 63, 25873, 63, 3009, 342, 398, 327, 11774, 7604, 697, 3788, 737, 1373, 2166, 5117, 2419, 626, 5839, 14, 267, 327, 961, 15620, 781, 2793, 1133, 664, 289, 320, 380, 68, 543, 3788, 5309, 5343, 267, 327, 334, 18447, 1265, 7710, 7198, 370, 506, 289, 320, 380, 68, 9, 267, 1240, 63, 1531, 360, 5186, 697, 297, 288, 8661, 29, 988, 8, 9833, 446, 413, 12, 378, 395, 288, 12777, 29, 797, 12, 288, 3050, 29, 277, 14, 2105, 14, 3620, 12, 288, 2248, 63, 2747, 63, 576, 29, 797, 9, 398, 327, 2136, 1929, 370, 2066, 886, 282, 8976, 370, 4868, 626, 1263, 666, 4903, 701, 267, 327, 3537, 5385, 965, 2757, 4829, 14, 710, 1454, 511, 666, 1077, 11492, 687, 267, 327, 511, 15188, 12, 503, 18392, 687, 2963, 63, 5186, 697, 18899, 14, 267, 327, 961, 965, 314, 5366, 7763, 402, 8697, 2536, 666, 334, 6777, 1990, 267, 327, 32005, 9645, 315, 314, 7604, 697, 680, 267, 1240, 63, 1531, 360, 4939, 297, 288, 8661, 29, 988, 8, 9833, 446, 413, 12, 378, 395, 288, 12777, 29, 797, 12, 288, 3050, 29, 277, 14, 2105, 14, 3620, 9, 398, 687, 1639, 14, 1018, 14, 1637, 492, 664, 63, 1637, 267, 687, 1639, 14, 1018, 14, 1637, 14, 7765, 14, 697, 492, 29103, 4437, 267, 367, 2581, 63, 3620, 315, 2202, 14, 3263, 1244, 654, 26, 288, 2581, 275, 664, 63, 1637, 8, 1637, 63, 3620, 9, 288, 340, 1228, 8, 1637, 12, 29103, 4437, 304, 355, 1240, 63, 1531, 360, 981, 20138, 386, 461, 297, 2581, 423, 1224, 12, 3050, 29, 277, 14, 2105, 14, 3620, 9, 398, 327, 2372, 282, 3920, 334, 12056, 10617, 781, 2793, 1133, 1929, 1373, 5966, 680, 961, 965, 267, 327, 314, 5366, 7763, 402, 29141, 314, 511, 3050, 14, 267, 3920, 275, 291, 14, 2105, 14, 3937, 342, 398, 372, 511, 63, 4659, 63, 354, 339, 347, 3875, 63, 10116, 63, 509, 63, 698, 8, 277, 12, 1402, 12, 289, 12, 3449, 304, 267, 298, 1767, 1263, 11469, 1478, 7143, 5385, 367, 314, 901, 2122, 267, 687, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 14, 955, 492, 30490, 398, 1072, 275, 1613, 8, 12739, 23675, 13921, 12, 291, 680, 3009, 63, 10116, 63, 509, 63, 698, 8, 1238, 12, 289, 12, 3449, 9, 398, 340, 1228, 8, 70, 12, 30490, 304, 288, 486, 15156, 275, 291, 14, 2105, 14, 1483, 14, 6721, 63, 3513, 63, 354, 288, 18293, 275, 291, 14, 2105, 14, 1483, 14, 3513, 63, 354, 288, 1592, 63, 1224, 275, 1402, 423, 2024, 14, 697, 63, 1224, 953, 1072, 14, 740, 8, 2487, 14, 4657, 63, 17714, 360, 4859, 5320, 435, 2079, 3449, 14, 4657, 63, 8723, 360, 1123, 6831, 4547, 358, 435, 16746, 435, 2079, 3449, 14, 4657, 63, 8723, 8, 71, 15156, 8, 697, 63, 1224, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 8609, 8, 71, 15156, 8, 70, 14, 2301, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 8609, 8, 495, 8, 70, 14, 10498, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 3978, 2711, 8, 71, 15156, 8, 70, 14, 6481, 63, 466, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 17714, 8, 495, 8, 70, 14, 3572, 430, 435, 1656, 283, 435, 2079, 3449, 14, 4657, 63, 17714, 8, 495, 8, 442, 8, 1397, 289, 14, 2307, 1724, 435, 2079, 283, 2736, 358, 953, 340, 289, 14, 11679, 63, 1080, 26, 355, 1072, 14, 740, 8, 2487, 14, 4657, 63, 17714, 360, 4859, 5320, 435, 2892, 3449, 14, 4657, 63, 8723, 360, 2499, 18075, 2681, 358, 435, 16746, 435, 2892, 3449, 14, 4657, 63, 8723, 8, 71, 15156, 8, 697, 63, 1224, 430, 435, 1656, 283, 435, 2892, 3449, 14, 4657, 63, 8609, 8, 71, 15156, 8, 70, 14, 2301, 430, 435, 283, 2736, 358, 398, 372, 1072, 339, 347, 2248, 63, 25873, 63, 3009, 8, 277, 304, 267, 408, 267, 961, 12981, 14404, 1536, 314, 25177, 5385, 570, 14, 267, 408, 267, 340, 291, 14, 2105, 14, 1483, 14, 11679, 63, 1023, 1491, 18, 61, 2356, 334, 19, 12, 378, 304, 288, 327, 13423, 1175, 2356, 650, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
oxtopus/nupic
examples/opf/experiments/spatial_classification/category_0/description.py
17
1601
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2013, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU 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. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- ## This file defines parameters for a prediction experiment. import os from nupic.frameworks.opf.expdescriptionhelpers import importBaseDescription # the sub-experiment configuration config = \ { 'dataSource': 'file://' + os.path.join(os.path.dirname(__file__), '../datasets/category_0.csv'), 'errorMetric': 'avg_err', 'modelParams': { 'sensorParams': { 'verbosity': 0}, 'clParams': { 'clVerbosity': 0, }, } } mod = importBaseDescription('../base/description.py', config) locals().update(mod.__dict__)
gpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 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, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 16421, 283, 576, 2980, 356, 283, 493, 22399, 435, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 221, 1460, 20644, 12281, 15, 3710, 63, 16, 14, 4737, 659, 5101, 523, 283, 705, 11119, 356, 283, 8595, 63, 1508, 297, 12244, 283, 1238, 6007, 356, 469, 5591, 283, 8956, 6007, 356, 469, 283, 9833, 356, 378, 1386, 272, 283, 429, 6007, 356, 469, 15166, 283, 429, 3673, 5947, 356, 378, 12, 272, 1660, 523, 789, 199, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 1095, 15, 1802, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 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, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 16421, 283, 576, 2980, 356, 283, 493, 22399, 435, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 221, 1460, 20644, 12281, 15, 3710, 63, 16, 14, 4737, 659, 5101, 523, 283, 705, 11119, 356, 283, 8595, 63, 1508, 297, 12244, 283, 1238, 6007, 356, 469, 5591, 283, 8956, 6007, 356, 469, 283, 9833, 356, 378, 1386, 272, 283, 429, 6007, 356, 469, 15166, 283, 429, 3673, 5947, 356, 378, 12, 272, 1660, 523, 789, 199, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 1095, 15, 1802, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ufbmi/olass-client
olass/models/crud_mixin.py
2
1418
""" Goal: simplify the code when interacting with entities """ import sqlalchemy as db from olass.models.base import get_session class CRUDMixin(): """ Helper class sqlalchemy entities """ __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) @classmethod def get_by_id(cls, id): if any( (isinstance(id, str) and id.isdigit(), isinstance(id, (int, float))),): session = get_session() # return cls.query.get(int(id)) # return session.query(cls).filter_by(id=int(id)).one() return session.query(cls).get(int(id)) return None @classmethod def create(cls, **kwargs): """ Helper for add() + commit() """ instance = cls(**kwargs) return instance.save() def update(self, commit=True, **kwargs): """ update object instance """ for attr, value in kwargs.items(): setattr(self, attr, value) return self.save() if commit else self def save(self, commit=True): """ save object instance """ session = get_session() session.add(self) if commit: session.commit() return self def delete(self, commit=True): """ delete object instance """ session = get_session() session.delete(self) return commit and session.commit()
mit
[ 624, 199, 31274, 26, 15037, 314, 1233, 1380, 17232, 316, 543, 9045, 199, 624, 199, 646, 8335, 465, 1592, 199, 504, 312, 4297, 14, 992, 14, 1095, 492, 664, 63, 1730, 421, 199, 533, 17101, 3383, 4256, 837, 272, 408, 11642, 1021, 8335, 9045, 408, 272, 636, 1224, 63, 589, 363, 275, 791, 2880, 63, 5952, 356, 715, 93, 339, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 29, 549, 9, 339, 768, 3744, 272, 347, 664, 63, 991, 63, 344, 8, 1886, 12, 1305, 304, 267, 340, 1263, 8, 288, 334, 6074, 8, 344, 12, 620, 9, 436, 1305, 14, 13896, 1062, 1467, 1228, 8, 344, 12, 334, 442, 12, 2069, 11508, 304, 288, 2351, 275, 664, 63, 1730, 342, 288, 327, 372, 843, 14, 1131, 14, 362, 8, 442, 8, 344, 430, 288, 327, 372, 2351, 14, 1131, 8, 1886, 680, 1541, 63, 991, 8, 344, 29, 442, 8, 344, 4992, 368, 342, 288, 372, 2351, 14, 1131, 8, 1886, 680, 362, 8, 442, 8, 344, 430, 267, 372, 488, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 1011, 958, 304, 267, 408, 11642, 367, 1050, 342, 435, 5532, 342, 408, 267, 1256, 275, 843, 3682, 958, 9, 267, 372, 1256, 14, 2117, 342, 339, 347, 1678, 8, 277, 12, 5532, 29, 549, 12, 1011, 958, 304, 267, 408, 1678, 909, 1256, 408, 267, 367, 1921, 12, 574, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 1921, 12, 574, 9, 267, 372, 291, 14, 2117, 342, 340, 5532, 587, 291, 339, 347, 3354, 8, 277, 12, 5532, 29, 549, 304, 267, 408, 3354, 909, 1256, 408, 267, 2351, 275, 664, 63, 1730, 342, 267, 2351, 14, 525, 8, 277, 9, 398, 340, 5532, 26, 288, 2351, 14, 3543, 342, 267, 372, 291, 339, 347, 3145, 8, 277, 12, 5532, 29, 549, 304, 267, 408, 3145, 909, 1256, 408, 267, 2351, 275, 664, 63, 1730, 342, 267, 2351, 14, 1807, 8, 277, 9, 267, 372, 5532, 436, 2351, 14, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 31274, 26, 15037, 314, 1233, 1380, 17232, 316, 543, 9045, 199, 624, 199, 646, 8335, 465, 1592, 199, 504, 312, 4297, 14, 992, 14, 1095, 492, 664, 63, 1730, 421, 199, 533, 17101, 3383, 4256, 837, 272, 408, 11642, 1021, 8335, 9045, 408, 272, 636, 1224, 63, 589, 363, 275, 791, 2880, 63, 5952, 356, 715, 93, 339, 1305, 275, 1592, 14, 4547, 8, 697, 14, 2674, 12, 5062, 63, 498, 29, 549, 9, 339, 768, 3744, 272, 347, 664, 63, 991, 63, 344, 8, 1886, 12, 1305, 304, 267, 340, 1263, 8, 288, 334, 6074, 8, 344, 12, 620, 9, 436, 1305, 14, 13896, 1062, 1467, 1228, 8, 344, 12, 334, 442, 12, 2069, 11508, 304, 288, 2351, 275, 664, 63, 1730, 342, 288, 327, 372, 843, 14, 1131, 14, 362, 8, 442, 8, 344, 430, 288, 327, 372, 2351, 14, 1131, 8, 1886, 680, 1541, 63, 991, 8, 344, 29, 442, 8, 344, 4992, 368, 342, 288, 372, 2351, 14, 1131, 8, 1886, 680, 362, 8, 442, 8, 344, 430, 267, 372, 488, 339, 768, 3744, 272, 347, 1218, 8, 1886, 12, 1011, 958, 304, 267, 408, 11642, 367, 1050, 342, 435, 5532, 342, 408, 267, 1256, 275, 843, 3682, 958, 9, 267, 372, 1256, 14, 2117, 342, 339, 347, 1678, 8, 277, 12, 5532, 29, 549, 12, 1011, 958, 304, 267, 408, 1678, 909, 1256, 408, 267, 367, 1921, 12, 574, 315, 2074, 14, 1744, 837, 288, 5371, 8, 277, 12, 1921, 12, 574, 9, 267, 372, 291, 14, 2117, 342, 340, 5532, 587, 291, 339, 347, 3354, 8, 277, 12, 5532, 29, 549, 304, 267, 408, 3354, 909, 1256, 408, 267, 2351, 275, 664, 63, 1730, 342, 267, 2351, 14, 525, 8, 277, 9, 398, 340, 5532, 26, 288, 2351, 14, 3543, 342, 267, 372, 291, 339, 347, 3145, 8, 277, 12, 5532, 29, 549, 304, 267, 408, 3145, 909, 1256, 408, 267, 2351, 275, 664, 63, 1730, 342, 267, 2351, 14, 1807, 8, 277, 9, 267, 372, 5532, 436, 2351, 14, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Scille/parsec-cloud
parsec/api/protocol/types.py
1
4779
# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2016-2021 Scille SAS import re from unicodedata import normalize from typing import Union, TypeVar, Type, NoReturn from uuid import uuid4 from collections import namedtuple from email.utils import parseaddr from parsec.serde import fields UserIDTypeVar = TypeVar("UserIDTypeVar", bound="UserID") DeviceIDTypeVar = TypeVar("DeviceIDTypeVar", bound="DeviceID") DeviceNameTypeVar = TypeVar("DeviceNameTypeVar", bound="DeviceName") def _bytes_size(txt: str) -> int: return len(txt.encode("utf8")) class OrganizationID(str): __slots__ = () regex = re.compile(r"^[\w\-]{1,32}$") def __new__(cls, raw: str) -> "OrganizationID": raw = normalize("NFC", raw) if not cls.regex.match(raw) or _bytes_size(raw) > 32: raise ValueError("Invalid organization ID") return super(OrganizationID, cls).__new__(cls, raw) def __repr__(self) -> str: return f"<OrganizationID {super().__repr__()}>" class UserID(str): __slots__ = () regex = re.compile(r"^[\w\-]{1,32}$") def __new__(cls, raw: str) -> "UserID": raw = normalize("NFC", raw) if not cls.regex.match(raw) or _bytes_size(raw) > 32: raise ValueError("Invalid user name") return super(UserID, cls).__new__(cls, raw) def __repr__(self) -> str: return f"<UserID {super().__repr__()}>" @classmethod def new(cls: Type[UserIDTypeVar]) -> UserIDTypeVar: return cls(uuid4().hex) def to_device_id(self, device_name: Union[str, "DeviceID"]) -> "DeviceID": return DeviceID(f"{self}@{device_name}") class DeviceName(str): __slots__ = () regex = re.compile(r"^[\w\-]{1,32}$") def __new__(cls, raw: str) -> "DeviceName": raw = normalize("NFC", raw) if not cls.regex.match(raw) or _bytes_size(raw) > 32: raise ValueError("Invalid device name") return super(DeviceName, cls).__new__(cls, raw) def __repr__(self) -> str: return f"<DeviceName {super().__repr__()}>" @classmethod def new(cls: Type[DeviceNameTypeVar]) -> DeviceNameTypeVar: return cls(uuid4().hex) class DeviceID(str): __slots__ = () regex = re.compile(r"^[\w\-]{1,32}@[\w\-]{1,32}$") def __new__(cls, raw: str) -> "DeviceID": raw = normalize("NFC", raw) if not cls.regex.match(raw) or _bytes_size(raw) > 65: raise ValueError("Invalid device ID") return super(DeviceID, cls).__new__(cls, raw) def __repr__(self) -> str: return f"<DeviceID {super().__repr__()}>" @property def user_id(self) -> UserID: return UserID(self.split("@")[0]) @property def device_name(self) -> DeviceName: return DeviceName(self.split("@")[1]) @classmethod def new(cls: Type[DeviceIDTypeVar]) -> DeviceIDTypeVar: return cls(f"{uuid4().hex}@{uuid4().hex}") OrganizationIDField = fields.str_based_field_factory(OrganizationID) UserIDField = fields.str_based_field_factory(UserID) DeviceNameField = fields.str_based_field_factory(DeviceName) DeviceIDField = fields.str_based_field_factory(DeviceID) class HumanHandle(namedtuple("HumanHandle", "email label")): __slots__ = () def __new__(cls, email: str, label: str) -> "HumanHandle": email = normalize("NFC", email) label = normalize("NFC", label) # TODO: how to check the email easily ? if not 0 < _bytes_size(email) < 255: raise ValueError("Invalid email address") if not 0 < _bytes_size(label) < 255: raise ValueError("Invalid label") parsed_label, parsed_email = parseaddr(f"{label} <{email}>") if parsed_email != email or parsed_label != label: raise ValueError("Invalid email/label couple") return super(HumanHandle, cls).__new__(cls, email, label) def __repr__(self) -> str: return f"<HumanHandle {str(self)} >" def __str__(self) -> str: return f"{self.label} <{self.email}>" def __eq__(self, other: object) -> bool: # Ignore label field, as it is only for human redability return isinstance(other, HumanHandle) and self.email == other.email def __gt__(self, other: object) -> NoReturn: raise NotImplementedError def __hash__(self) -> int: return hash(self.email) class HumanHandleField(fields.Tuple): def __init__(self, **kwargs: object): email = fields.String(required=True) label = fields.String(required=True) super().__init__(email, label, **kwargs) def _deserialize(self, *args: object, **kwargs: object) -> HumanHandle: result = super()._deserialize(*args, **kwargs) return HumanHandle(*result)
agpl-3.0
[ 3, 2235, 3321, 8142, 334, 2859, 921, 1122, 67, 14, 4091, 9, 1898, 334, 67, 9, 437, 28863, 19, 7800, 13, 22150, 13916, 17142, 26124, 199, 199, 646, 295, 199, 504, 23128, 492, 7666, 199, 504, 14090, 492, 15961, 12, 2434, 5894, 12, 2434, 12, 3091, 1767, 199, 504, 5377, 492, 5377, 20, 199, 504, 5055, 492, 12863, 199, 504, 3031, 14, 1208, 492, 2198, 2697, 199, 199, 504, 2198, 67, 14, 332, 271, 492, 1504, 421, 199, 28659, 804, 5894, 275, 2434, 5894, 480, 28659, 804, 5894, 401, 3914, 628, 28659, 531, 199, 2510, 998, 804, 5894, 275, 2434, 5894, 480, 2510, 998, 804, 5894, 401, 3914, 628, 2510, 998, 531, 199, 2510, 985, 804, 5894, 275, 2434, 5894, 480, 2510, 985, 804, 5894, 401, 3914, 628, 2510, 985, 531, 421, 199, 318, 485, 2394, 63, 890, 8, 2424, 26, 620, 9, 1035, 1109, 26, 272, 372, 822, 8, 2424, 14, 2143, 480, 1624, 24, 2237, 421, 199, 533, 18863, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 15928, 998, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 13237, 2870, 531, 267, 372, 1613, 8, 15928, 998, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 15928, 998, 469, 4792, 11027, 2722, 4533, 93, 4335, 421, 199, 533, 2876, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 28659, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 922, 536, 531, 267, 372, 1613, 8, 28659, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 28659, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 28659, 804, 5894, 566, 1035, 2876, 998, 804, 5894, 26, 267, 372, 843, 8, 2580, 20, 1252, 4097, 9, 339, 347, 370, 63, 1782, 63, 344, 8, 277, 12, 2243, 63, 354, 26, 15961, 59, 495, 12, 298, 2510, 998, 3135, 1035, 298, 2510, 998, 582, 267, 372, 12272, 998, 8, 70, 14381, 277, 93, 32, 91, 1782, 63, 354, 15412, 421, 199, 533, 12272, 985, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 2510, 985, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 2243, 536, 531, 267, 372, 1613, 8, 2510, 985, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 2510, 985, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 2510, 985, 804, 5894, 566, 1035, 12272, 985, 804, 5894, 26, 267, 372, 843, 8, 2580, 20, 1252, 4097, 9, 421, 199, 533, 12272, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 32, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 2510, 998, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 11738, 26, 288, 746, 1722, 480, 3364, 2243, 2870, 531, 267, 372, 1613, 8, 2510, 998, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 2510, 998, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 1829, 272, 347, 922, 63, 344, 8, 277, 9, 1035, 2876, 998, 26, 267, 372, 2876, 998, 8, 277, 14, 1294, 25915, 9981, 16, 566, 339, 768, 1829, 272, 347, 2243, 63, 354, 8, 277, 9, 1035, 12272, 985, 26, 267, 372, 12272, 985, 8, 277, 14, 1294, 25915, 9981, 17, 566, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 2510, 998, 804, 5894, 566, 1035, 12272, 998, 804, 5894, 26, 267, 372, 843, 8, 70, 14381, 2580, 20, 1252, 4097, 93, 32, 91, 2580, 20, 1252, 4097, 15412, 421, 199, 15928, 998, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 15928, 998, 9, 199, 28659, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 28659, 9, 199, 2510, 985, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 2510, 985, 9, 199, 2510, 998, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 2510, 998, 9, 421, 199, 533, 869, 7652, 5940, 8, 18921, 480, 31355, 5940, 401, 298, 2123, 1768, 14150, 272, 636, 7257, 363, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 3031, 26, 620, 12, 1768, 26, 620, 9, 1035, 298, 31355, 5940, 582, 267, 3031, 275, 7666, 480, 46, 4161, 401, 3031, 9, 267, 1768, 275, 7666, 480, 46, 4161, 401, 1768, 9, 398, 327, 3254, 26, 4212, 370, 1104, 314, 3031, 221, 16174, 5805, 267, 340, 440, 378, 665, 485, 2394, 63, 890, 8, 2123, 9, 665, 5450, 26 ]
[ 2235, 3321, 8142, 334, 2859, 921, 1122, 67, 14, 4091, 9, 1898, 334, 67, 9, 437, 28863, 19, 7800, 13, 22150, 13916, 17142, 26124, 199, 199, 646, 295, 199, 504, 23128, 492, 7666, 199, 504, 14090, 492, 15961, 12, 2434, 5894, 12, 2434, 12, 3091, 1767, 199, 504, 5377, 492, 5377, 20, 199, 504, 5055, 492, 12863, 199, 504, 3031, 14, 1208, 492, 2198, 2697, 199, 199, 504, 2198, 67, 14, 332, 271, 492, 1504, 421, 199, 28659, 804, 5894, 275, 2434, 5894, 480, 28659, 804, 5894, 401, 3914, 628, 28659, 531, 199, 2510, 998, 804, 5894, 275, 2434, 5894, 480, 2510, 998, 804, 5894, 401, 3914, 628, 2510, 998, 531, 199, 2510, 985, 804, 5894, 275, 2434, 5894, 480, 2510, 985, 804, 5894, 401, 3914, 628, 2510, 985, 531, 421, 199, 318, 485, 2394, 63, 890, 8, 2424, 26, 620, 9, 1035, 1109, 26, 272, 372, 822, 8, 2424, 14, 2143, 480, 1624, 24, 2237, 421, 199, 533, 18863, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 15928, 998, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 13237, 2870, 531, 267, 372, 1613, 8, 15928, 998, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 15928, 998, 469, 4792, 11027, 2722, 4533, 93, 4335, 421, 199, 533, 2876, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 28659, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 922, 536, 531, 267, 372, 1613, 8, 28659, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 28659, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 28659, 804, 5894, 566, 1035, 2876, 998, 804, 5894, 26, 267, 372, 843, 8, 2580, 20, 1252, 4097, 9, 339, 347, 370, 63, 1782, 63, 344, 8, 277, 12, 2243, 63, 354, 26, 15961, 59, 495, 12, 298, 2510, 998, 3135, 1035, 298, 2510, 998, 582, 267, 372, 12272, 998, 8, 70, 14381, 277, 93, 32, 91, 1782, 63, 354, 15412, 421, 199, 533, 12272, 985, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 2510, 985, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 4337, 26, 288, 746, 1722, 480, 3364, 2243, 536, 531, 267, 372, 1613, 8, 2510, 985, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 2510, 985, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 2510, 985, 804, 5894, 566, 1035, 12272, 985, 804, 5894, 26, 267, 372, 843, 8, 2580, 20, 1252, 4097, 9, 421, 199, 533, 12272, 998, 8, 495, 304, 272, 636, 7257, 363, 275, 6248, 272, 5163, 275, 295, 14, 2014, 8, 82, 16136, 7023, 87, 16185, 8194, 17, 12, 708, 93, 32, 7023, 87, 16185, 8194, 17, 12, 708, 93, 22550, 339, 347, 636, 1222, 721, 1886, 12, 3066, 26, 620, 9, 1035, 298, 2510, 998, 582, 267, 3066, 275, 7666, 480, 46, 4161, 401, 3066, 9, 267, 340, 440, 843, 14, 3821, 14, 1431, 8, 1773, 9, 503, 485, 2394, 63, 890, 8, 1773, 9, 690, 11738, 26, 288, 746, 1722, 480, 3364, 2243, 2870, 531, 267, 372, 1613, 8, 2510, 998, 12, 843, 2843, 1222, 721, 1886, 12, 3066, 9, 339, 347, 636, 2722, 721, 277, 9, 1035, 620, 26, 267, 372, 289, 17030, 2510, 998, 469, 4792, 11027, 2722, 4533, 93, 4335, 339, 768, 1829, 272, 347, 922, 63, 344, 8, 277, 9, 1035, 2876, 998, 26, 267, 372, 2876, 998, 8, 277, 14, 1294, 25915, 9981, 16, 566, 339, 768, 1829, 272, 347, 2243, 63, 354, 8, 277, 9, 1035, 12272, 985, 26, 267, 372, 12272, 985, 8, 277, 14, 1294, 25915, 9981, 17, 566, 339, 768, 3744, 272, 347, 892, 8, 1886, 26, 2434, 59, 2510, 998, 804, 5894, 566, 1035, 12272, 998, 804, 5894, 26, 267, 372, 843, 8, 70, 14381, 2580, 20, 1252, 4097, 93, 32, 91, 2580, 20, 1252, 4097, 15412, 421, 199, 15928, 998, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 15928, 998, 9, 199, 28659, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 28659, 9, 199, 2510, 985, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 2510, 985, 9, 199, 2510, 998, 792, 275, 1504, 14, 495, 63, 6788, 63, 698, 63, 3702, 8, 2510, 998, 9, 421, 199, 533, 869, 7652, 5940, 8, 18921, 480, 31355, 5940, 401, 298, 2123, 1768, 14150, 272, 636, 7257, 363, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 3031, 26, 620, 12, 1768, 26, 620, 9,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
quodlibet/quodlibet
quodlibet/ext/events/waveformseekbar.py
1
27104
# Copyright 2016 0x1777 # 2016-17 Nick Boultbee # 2017 Didier Villevalois # 2017 Muges # 2017 Eyenseo # 2018 Joschua Gandert # 2018 Blimmo # 2018 Olli Helin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. from math import ceil, floor from typing import List from gi.repository import Gtk, Gdk, Gst import cairo from quodlibet import _, app from quodlibet import print_w from quodlibet import util from quodlibet.plugins import PluginConfig, IntConfProp, \ ConfProp, BoolConfProp from quodlibet.plugins.events import EventPlugin from quodlibet.qltk import Align from quodlibet.qltk import Icons from quodlibet.qltk.seekbutton import TimeLabel from quodlibet.qltk.tracker import TimeTracker from quodlibet.qltk import get_fg_highlight_color from quodlibet.util import connect_destroy, print_d from quodlibet.util.path import uri2gsturi class WaveformSeekBar(Gtk.Box): """A widget containing labels and the seekbar.""" def __init__(self, player, library): super().__init__() self._player = player self._rms_vals = [] self._hovering = False self._elapsed_label = TimeLabel() self._remaining_label = TimeLabel() self._waveform_scale = WaveformScale(player) self.pack_start(Align(self._elapsed_label, border=6), False, True, 0) self.pack_start(self._waveform_scale, True, True, 0) self.pack_start(Align(self._remaining_label, border=6), False, True, 0) for child in self.get_children(): child.show_all() self.set_time_label_visibility(CONFIG.show_time_labels) self._waveform_scale.connect('size-allocate', self._update_redraw_interval) self._waveform_scale.connect('motion-notify-event', self._on_mouse_hover) self._waveform_scale.connect('leave-notify-event', self._on_mouse_leave) self._label_tracker = TimeTracker(player) self._label_tracker.connect('tick', self._on_tick_label, player) self._redraw_tracker = TimeTracker(player) self._redraw_tracker.connect('tick', self._on_tick_waveform, player) connect_destroy(player, 'seek', self._on_player_seek) connect_destroy(player, 'song-started', self._on_song_started) connect_destroy(player, 'song-ended', self._on_song_ended) connect_destroy(player, 'notify::seekable', self._on_seekable_changed) connect_destroy(library, 'changed', self._on_song_changed, player) self.connect('destroy', self._on_destroy) self._update(player) if player.info: self._create_waveform(player.info, CONFIG.max_data_points) def set_time_label_visibility(self, is_visible): self._time_labels_visible = is_visible if is_visible: self._elapsed_label.show() self._remaining_label.show() else: self._elapsed_label.hide() self._remaining_label.hide() def _create_waveform(self, song, points): # Close any existing pipeline to avoid leaks self._clean_pipeline() if not song.is_file: return command_template = """ uridecodebin name=uridec ! audioconvert ! level name=audiolevel interval={} post-messages=true ! fakesink sync=false""" interval = int(song("~#length") * 1E9 / points) if not interval: return print_d("Computing data for each %.3f seconds" % (interval / 1E9)) command = command_template.format(interval) pipeline = Gst.parse_launch(command) pipeline.get_by_name("uridec").set_property("uri", uri2gsturi(song("~uri"))) bus = pipeline.get_bus() self._bus_id = bus.connect("message", self._on_bus_message, points) bus.add_signal_watch() pipeline.set_state(Gst.State.PLAYING) self._pipeline = pipeline self._new_rms_vals = [] def _on_bus_message(self, bus, message, points): force_stop = False if message.type == Gst.MessageType.ERROR: error, debug = message.parse_error() print_d("Error received from element {name}: {error}".format( name=message.src.get_name(), error=error)) print_d("Debugging information: {}".format(debug)) elif message.type == Gst.MessageType.ELEMENT: structure = message.get_structure() if structure.get_name() == "level": rms_db = structure.get_value("rms") if rms_db: # Calculate average of all channels (usually 2) rms_db_avg = sum(rms_db) / len(rms_db) # Normalize dB value to value between 0 and 1 rms = pow(10, (rms_db_avg / 20)) self._new_rms_vals.append(rms) if len(self._new_rms_vals) >= points: # The audio might be much longer than we anticipated # and we would get way too many events due to the too # short interval set. force_stop = True else: print_w("Got unexpected message of type {}" .format(message.type)) if message.type == Gst.MessageType.EOS or force_stop: self._clean_pipeline() # Update the waveform with the new data self._rms_vals = self._new_rms_vals self._waveform_scale.reset(self._rms_vals) self._waveform_scale.set_placeholder(False) self._update_redraw_interval() # Clear temporary reference to the waveform data del self._new_rms_vals def _clean_pipeline(self): if hasattr(self, "_pipeline") and self._pipeline: self._pipeline.set_state(Gst.State.NULL) if self._bus_id: bus = self._pipeline.get_bus() bus.remove_signal_watch() bus.disconnect(self._bus_id) self._bus_id = None if self._pipeline: self._pipeline = None def _update_redraw_interval(self, *args): if self._player.info and self.is_visible(): # Must be recomputed when size is changed interval = self._waveform_scale.compute_redraw_interval() self._redraw_tracker.set_interval(interval) def _on_destroy(self, *args): self._clean_pipeline() self._label_tracker.destroy() self._redraw_tracker.destroy() def _on_tick_label(self, tracker, player): self._update_label(player) def _on_tick_waveform(self, tracker, player): self._update_waveform(player) def _on_seekable_changed(self, player, *args): self._update_label(player) def _on_player_seek(self, player, song, ms): self._update(player) def _on_song_changed(self, library, songs, player): if not player.info: return # Check that the currently playing song has changed if player.info in songs: # Trigger a re-computation of the waveform self._create_waveform(player.info, CONFIG.max_data_points) self._resize_labels(player.info) # Only update the label if some tag value changed self._update_label(player) def _on_song_started(self, player, song): if player.info: # Trigger a re-computation of the waveform self._create_waveform(player.info, CONFIG.max_data_points) self._resize_labels(player.info) self._waveform_scale.set_placeholder(True) self._update(player, True) def _on_song_ended(self, player, song, ended): self._update(player) def _update(self, player, full_redraw=False): self._update_label(player) self._update_waveform(player, full_redraw) def _update_label(self, player): if not self._time_labels_visible: self.set_sensitive(player.info is not None and player.seekable) return if player.info: if self._hovering: # Show the position pointed by the mouse position = self._waveform_scale.get_mouse_position() else: # Show the position of the player (converted in seconds) position = player.get_position() / 1000.0 length = player.info("~#length") remaining = length - position self._elapsed_label.set_time(position) self._remaining_label.set_time(remaining) self._elapsed_label.set_disabled(not player.seekable) self._remaining_label.set_disabled(not player.seekable) self.set_sensitive(player.seekable) else: self._remaining_label.set_disabled(True) self._elapsed_label.set_disabled(True) self.set_sensitive(False) def _update_waveform(self, player, full_redraw=False): if player.info: # Position in ms, length in seconds position = player.get_position() / 1000.0 length = player.info("~#length") if length != 0: self._waveform_scale.set_position(position / length) else: print_d("Length reported as zero for %s" % player.info) self._waveform_scale.set_position(0) if position == 0 or full_redraw: self._waveform_scale.queue_draw() else: (x, y, w, h) = self._waveform_scale.compute_redraw_area() self._waveform_scale.queue_draw_area(x, y, w, h) else: self._waveform_scale.set_placeholder(True) self._waveform_scale.queue_draw() def _on_mouse_hover(self, _, event): def clamp(a, x, b): '''Return x if a <= x <= b, else the a or b nearest to x.''' return min(max(x, a), b) width = self._waveform_scale.get_allocation().width self._waveform_scale.set_mouse_x_position(clamp(0, event.x, width)) if self._hovering: (x, y, w, h) = self._waveform_scale.compute_hover_redraw_area() self._waveform_scale.queue_draw_area(x, y, w, h) else: self._waveform_scale.queue_draw() self._update_label(self._player) self._hovering = True def _on_mouse_leave(self, _, event): self._waveform_scale.set_mouse_x_position(-1) self._waveform_scale.queue_draw() self._hovering = False self._update_label(self._player) def _resize_labels(self, song): """Resize the labels to make sure there is enough space to display the length of the songs. This prevents the waveform from changing size when the position changes from 9:59 to 10:00 for example.""" length = util.format_time_display(song("~#length")) # Get the width needed to display the length of the song (the text # displayed in the labels will always be shorter than that) layout = self._remaining_label.get_layout() layout.set_text(length, -1) width, height = layout.get_pixel_size() # Set it as the minimum width of the labels to prevent them from # changing width self._remaining_label.set_size_request(width, -1) self._elapsed_label.set_size_request(width, -1) class WaveformScale(Gtk.EventBox): """The waveform widget.""" _rms_vals: List[int] = [] _player = None _placeholder = True def __init__(self, player): super().__init__() self._player = player self.set_size_request(40, 40) self.position = 0 self._last_drawn_position = 0 self.override_background_color( Gtk.StateFlags.NORMAL, Gdk.RGBA(alpha=0)) self.mouse_position = -1 self._last_mouse_position = -1 self.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.SCROLL_MASK) self._seeking = False @property def width(self): return self.get_allocation().width def set_placeholder(self, placeholder): self._placeholder = placeholder def reset(self, rms_vals): self._rms_vals = rms_vals self._seeking = False self.queue_draw() def compute_redraw_interval(self): allocation = self.get_allocation() width = allocation.width scale_factor = self.get_scale_factor() pixel_ratio = float(scale_factor) # Compute the coarsest time interval for redraws length = self._player.info("~#length") if (length == 0): # The length is 0 for example when playing a stream from # Internet radio. If 0 is passed forward as the update interval, # UI will freeze as it will try to update continuously. # The update interval is usually 1 second so use that instead. print_d("Length is zero for %s, using redraw interval of 1000 ms" % self._player.info) return 1000 return length * 1000 / max(width * pixel_ratio, 1) def compute_redraw_area(self): width = self.width last_position_x = self._last_drawn_position * width position_x = self.position * width return self._compute_redraw_area_between(last_position_x, position_x) def compute_hover_redraw_area(self): return self._compute_redraw_area_between(self._last_mouse_position, self.mouse_position) def _compute_redraw_area_between(self, x1, x2): allocation = self.get_allocation() width = allocation.width height = allocation.height scale_factor = self.get_scale_factor() pixel_ratio = float(scale_factor) line_width = 1.0 / pixel_ratio # Compute the thinnest rectangle to redraw x = max(0.0, min(x1, x2) - line_width * 5) w = min(width, abs(x2 - x1) + line_width * 10) return x, 0.0, w, height def draw_waveform(self, cr, width, height, elapsed_color, hover_color, remaining_color, show_current_pos_config): if width == 0 or height == 0: return scale_factor = self.get_scale_factor() pixel_ratio = float(scale_factor) line_width = 1.0 / pixel_ratio half_height = self.compute_half_height(height, pixel_ratio) value_count = len(self._rms_vals) max_value = max(self._rms_vals) ratio_width = value_count / (float(width) * pixel_ratio) ratio_height = max_value / half_height cr.set_line_width(line_width) cr.set_line_cap(cairo.LINE_CAP_ROUND) cr.set_line_join(cairo.LINE_JOIN_ROUND) position_width = self.position * width * pixel_ratio mouse_position = self.mouse_position * scale_factor hw = line_width / 2.0 # Avoiding object lookups is slightly faster data = self._rms_vals # Use the clip rectangles to redraw only what is necessary for (cx, cy, cw, ch) in cr.copy_clip_rectangle_list(): for x in range(int(floor(cx * pixel_ratio)), int(ceil((cx + cw) * pixel_ratio)), 1): if mouse_position >= 0: if self._seeking: # The user is seeking (holding mousebutton down) fg_color = (elapsed_color if x < mouse_position else remaining_color) elif show_current_pos_config: # Use hover color and elapsed color to display the # current playing position while hovering if x < mouse_position: if x < position_width: fg_color = elapsed_color else: fg_color = hover_color elif x < position_width: fg_color = hover_color else: fg_color = remaining_color else: # The mouse is hovering the seekbar fg_color = (hover_color if x < mouse_position else remaining_color) else: fg_color = (elapsed_color if x < position_width else remaining_color) cr.set_source_rgba(*list(fg_color)) # Basic anti-aliasing / oversampling u1 = max(0, int(floor((x - hw) * ratio_width))) u2 = min(int(ceil((x + hw) * ratio_width)), len(data)) val = (sum(data[u1:u2]) / (ratio_height * (u2 - u1)) if u1 != u2 else 0.0) hx = x / pixel_ratio + hw cr.move_to(hx, half_height - val) cr.line_to(hx, half_height + val) cr.stroke() self._last_drawn_position = self.position self._last_mouse_position = self.mouse_position def draw_placeholder(self, cr, width, height, color): if width == 0 or height == 0: return scale_factor = self.get_scale_factor() pixel_ratio = float(scale_factor) line_width = 1.0 / pixel_ratio half_height = self.compute_half_height(height, pixel_ratio) hw = line_width / 2.0 cr.set_line_width(line_width) cr.set_line_cap(cairo.LINE_CAP_ROUND) cr.set_line_join(cairo.LINE_JOIN_ROUND) cr.set_source_rgba(*list(color)) cr.move_to(hw, half_height) cr.line_to(width - hw, half_height) cr.stroke() @staticmethod def compute_half_height(height, pixel_ratio): # Ensure half_height is in the middle of a pixel (c.f. Cairo's FAQ) height_px = int(height * pixel_ratio) half_height = \ (height_px if height_px % 2 else height_px - 1) / pixel_ratio / 2 return half_height def do_draw(self, cr): context = self.get_style_context() # Get colors context.save() context.set_state(Gtk.StateFlags.NORMAL) bg_color = context.get_background_color(context.get_state()) remaining_color = context.get_color(context.get_state()) context.restore() elapsed_color = get_fg_highlight_color(self) # Check if the user set a different elapsed color in the config elapsed_color_config = CONFIG.elapsed_color if elapsed_color_config and Gdk.RGBA().parse(elapsed_color_config): elapsed_color = Gdk.RGBA() elapsed_color.parse(elapsed_color_config) # Check if the user set a different remaining color in the config remaining_color_config = CONFIG.remaining_color if remaining_color_config and Gdk.RGBA().parse(remaining_color_config): remaining_color = Gdk.RGBA() remaining_color.parse(remaining_color_config) # Check if the user set a hover color in the config hover_color_config = CONFIG.hover_color if hover_color_config and Gdk.RGBA().parse(hover_color_config): hover_color = Gdk.RGBA() hover_color.parse(hover_color_config) else: # Generate default hover_color by blending elapsed_color and # remaining_color opacity = 0.4 r = (opacity * elapsed_color.alpha * elapsed_color.red + (1 - opacity) * remaining_color.alpha * remaining_color.red) g = (opacity * elapsed_color.alpha * elapsed_color.green + (1 - opacity) * remaining_color.alpha * remaining_color.green) b = (opacity * elapsed_color.alpha * elapsed_color.blue + (1 - opacity) * remaining_color.alpha * remaining_color.blue) a = (opacity * elapsed_color.alpha + (1 - opacity) * remaining_color.alpha) hover_color = Gdk.RGBA(r, g, b, a) # Check if the user turned on showing current position show_current_pos_config = CONFIG.show_current_pos # Paint the background cr.set_source_rgba(*list(bg_color)) cr.paint() allocation = self.get_allocation() width = allocation.width height = allocation.height if not self._placeholder and self._rms_vals: self.draw_waveform(cr, width, height, elapsed_color, hover_color, remaining_color, show_current_pos_config) else: self.draw_placeholder(cr, width, height, remaining_color) def do_button_press_event(self, event): # Left mouse button if event.button == 1 and self._player: self._seeking = True self.queue_draw() def do_button_release_event(self, event): # Left mouse button if event.button == 1 and self._player: ratio = event.x / self.get_allocation().width length = self._player.info("~#length") self._player.seek(ratio * length * 1000) self._seeking = False self.queue_draw() return True def do_scroll_event(self, event): if event.direction == Gdk.ScrollDirection.UP: self._player.seek(self._player.get_position() + CONFIG.seek_amount) self.queue_draw() elif event.direction == Gdk.ScrollDirection.DOWN: self._player.seek(self._player.get_position() - CONFIG.seek_amount) self.queue_draw() def set_position(self, position): self.position = position def set_mouse_x_position(self, mouse_position): """Set the horizontal position of the mouse in pixel""" self.mouse_position = mouse_position def get_mouse_position(self): """Return the position of the song pointed by the mouse in seconds""" ratio = self.mouse_position / self.get_allocation().width length = self._player.info("~#length") return ratio * length class Config: _config = PluginConfig(__name__) elapsed_color = ConfProp(_config, "elapsed_color", "") hover_color = ConfProp(_config, "hover_color", "") remaining_color = ConfProp(_config, "remaining_color", "") show_current_pos = BoolConfProp(_config, "show_current_pos", False) seek_amount = IntConfProp(_config, "seek_amount", 5000) max_data_points = IntConfProp(_config, "max_data_points", 3000) show_time_labels = BoolConfProp(_config, "show_time_labels", True) CONFIG = Config() class WaveformSeekBarPlugin(EventPlugin): """The plugin class.""" PLUGIN_ID = "WaveformSeekBar" PLUGIN_NAME = _("Waveform Seek Bar") PLUGIN_ICON = Icons.GO_JUMP PLUGIN_CONFIG_SECTION = __name__ PLUGIN_DESC = _( "A seekbar in the shape of the waveform of the current song.") def __init__(self): self._bar = None def enabled(self): self._bar = WaveformSeekBar(app.player, app.librarian) self._bar.show() app.window.set_seekbar_widget(self._bar) def disabled(self): app.window.set_seekbar_widget(None) self._bar.destroy() self._bar = None def PluginPreferences(self, parent): red = Gdk.RGBA() red.parse("#ff0000") def validate_color(entry): text = entry.get_text() if not Gdk.RGBA().parse(text): # Invalid color, make text red entry.override_color(Gtk.StateFlags.NORMAL, red) else: # Reset text color entry.override_color(Gtk.StateFlags.NORMAL, None) def elapsed_color_changed(entry): validate_color(entry) CONFIG.elapsed_color = entry.get_text() def hover_color_changed(entry): validate_color(entry) CONFIG.hover_color = entry.get_text() def remaining_color_changed(entry): validate_color(entry) CONFIG.remaining_color = entry.get_text() def on_show_pos_toggled(button, *args): CONFIG.show_current_pos = button.get_active() def seek_amount_changed(spinbox): CONFIG.seek_amount = spinbox.get_value_as_int() vbox = Gtk.VBox(spacing=6) def on_show_time_labels_toggled(button, *args): CONFIG.show_time_labels = button.get_active() if self._bar is not None: self._bar.set_time_label_visibility(CONFIG.show_time_labels) def create_color(label_text, color, callback): hbox = Gtk.HBox(spacing=6) hbox.set_border_width(6) label = Gtk.Label(label=label_text) hbox.pack_start(label, False, True, 0) entry = Gtk.Entry() if color: entry.set_text(color) entry.connect('changed', callback) hbox.pack_start(entry, True, True, 0) return hbox box = create_color(_("Override foreground color:"), CONFIG.elapsed_color, elapsed_color_changed) vbox.pack_start(box, True, True, 0) box = create_color(_("Override hover color:"), CONFIG.hover_color, hover_color_changed) vbox.pack_start(box, True, True, 0) box = create_color(_("Override remaining color:"), CONFIG.remaining_color, remaining_color_changed) vbox.pack_start(box, True, True, 0) show_current_pos = Gtk.CheckButton(label=_("Show current position")) show_current_pos.set_active(CONFIG.show_current_pos) show_current_pos.connect("toggled", on_show_pos_toggled) vbox.pack_start(show_current_pos, True, True, 0) show_time_labels = Gtk.CheckButton(label=_("Show time labels")) show_time_labels.set_active(CONFIG.show_time_labels) show_time_labels.connect("toggled", on_show_time_labels_toggled) vbox.pack_start(show_time_labels, True, True, 0) hbox = Gtk.HBox(spacing=6) hbox.set_border_width(6) label = Gtk.Label(label=_( "Seek amount when scrolling (milliseconds):" )) hbox.pack_start(label, False, True, 0) seek_amount = Gtk.SpinButton( adjustment=Gtk.Adjustment(CONFIG.seek_amount, 0, 60000, 1000, 1000, 0) ) seek_amount.set_numeric(True) seek_amount.connect("changed", seek_amount_changed) hbox.pack_start(seek_amount, True, True, 0) vbox.pack_start(hbox, True, True, 0) return vbox
gpl-2.0
[ 3, 1898, 7800, 378, 88, 8881, 23, 199, 3, 263, 7800, 13, 1196, 653, 2000, 5088, 427, 19446, 199, 3, 3698, 9708, 3757, 328, 281, 812, 17142, 637, 79, 374, 199, 3, 3698, 9708, 28919, 3389, 199, 3, 3698, 9708, 662, 89, 677, 79, 199, 3, 3698, 14894, 1603, 736, 335, 1458, 598, 11438, 84, 199, 3, 3698, 14894, 699, 4175, 573, 199, 3, 3698, 14894, 593, 13876, 869, 352, 262, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 504, 3473, 492, 30449, 12, 19841, 199, 504, 14090, 492, 3820, 199, 199, 504, 18895, 14, 8421, 492, 11424, 12, 31392, 12, 598, 270, 199, 646, 1704, 14352, 199, 199, 504, 2173, 364, 773, 386, 492, 5501, 1145, 199, 504, 2173, 364, 773, 386, 492, 870, 63, 87, 199, 504, 2173, 364, 773, 386, 492, 4884, 199, 504, 2173, 364, 773, 386, 14, 5265, 492, 11349, 2028, 12, 9805, 8930, 9955, 12, 971, 272, 32539, 9955, 12, 19287, 8930, 9955, 199, 504, 2173, 364, 773, 386, 14, 5265, 14, 4368, 492, 6763, 5061, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 15170, 784, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 473, 8704, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 14, 5507, 3887, 492, 4703, 4314, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 14, 8877, 492, 4703, 13652, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 664, 63, 9681, 63, 14337, 63, 2326, 199, 504, 2173, 364, 773, 386, 14, 1974, 492, 4907, 63, 7237, 12, 870, 63, 68, 199, 504, 2173, 364, 773, 386, 14, 1974, 14, 515, 492, 5108, 18, 23908, 2302, 421, 199, 533, 644, 811, 964, 19168, 5281, 8, 18891, 14, 3532, 304, 272, 408, 33, 3938, 3035, 3628, 436, 314, 12005, 1700, 1041, 339, 347, 636, 826, 721, 277, 12, 7748, 12, 3555, 304, 267, 1613, 11027, 826, 4533, 398, 291, 423, 6147, 275, 7748, 267, 291, 423, 24444, 63, 3643, 275, 942, 267, 291, 423, 22797, 316, 275, 756, 398, 291, 423, 16691, 63, 1302, 275, 4703, 4314, 342, 267, 291, 423, 11266, 63, 1302, 275, 4703, 4314, 342, 267, 291, 423, 10024, 964, 63, 3467, 275, 644, 811, 964, 9944, 8, 6147, 9, 398, 291, 14, 1389, 63, 928, 8, 9497, 8, 277, 423, 16691, 63, 1302, 12, 9162, 29, 22, 395, 756, 12, 715, 12, 378, 9, 267, 291, 14, 1389, 63, 928, 8, 277, 423, 10024, 964, 63, 3467, 12, 715, 12, 715, 12, 378, 9, 267, 291, 14, 1389, 63, 928, 8, 9497, 8, 277, 423, 11266, 63, 1302, 12, 9162, 29, 22, 395, 756, 12, 715, 12, 378, 9, 398, 367, 1982, 315, 291, 14, 362, 63, 3223, 837, 288, 1982, 14, 2384, 63, 452, 342, 267, 291, 14, 409, 63, 521, 63, 1302, 63, 11269, 8, 5569, 14, 2384, 63, 521, 63, 3512, 9, 398, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 890, 13, 12991, 297, 3660, 291, 423, 873, 63, 581, 1773, 63, 4284, 9, 267, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 15335, 13, 6814, 13, 1430, 297, 3660, 291, 423, 265, 63, 10544, 63, 22797, 9, 267, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 12422, 13, 6814, 13, 1430, 297, 3660, 291, 423, 265, 63, 10544, 63, 12422, 9, 398, 291, 423, 1302, 63, 8877, 275, 4703, 13652, 8, 6147, 9, 267, 291, 423, 1302, 63, 8877, 14, 2242, 360, 8284, 297, 291, 423, 265, 63, 8284, 63, 1302, 12, 7748, 9, 398, 291, 423, 581, 1773, 63, 8877, 275, 4703, 13652, 8, 6147, 9, 267, 291, 423, 581, 1773, 63, 8877, 14, 2242, 360, 8284, 297, 291, 423, 265, 63, 8284, 63, 10024, 964, 12, 7748, 9, 398, 4907, 63, 7237, 8, 6147, 12, 283, 5507, 297, 291, 423, 265, 63, 6147, 63, 5507, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 19351, 13, 8924, 297, 291, 423, 265, 63, 19351, 63, 8924, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 19351, 13, 8960, 297, 291, 423, 265, 63, 19351, 63, 8960, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 6814, 447, 25895, 297, 291, 423, 265, 63, 25895, 63, 2489, 9, 267, 4907, 63, 7237, 8, 4342, 12, 283, 2489, 297, 291, 423, 265, 63, 19351, 63, 2489, 12, 7748, 9, 398, 291, 14, 2242, 360, 7237, 297, 291, 423, 265, 63, 7237, 9, 267, 291, 423, 873, 8, 6147, 9, 398, 340, 7748, 14, 815, 26, 288, 291, 423, 981, 63, 10024, 964, 8, 6147, 14, 815, 12, 15869, 14, 988, 63, 576, 63, 3438, 9, 339, 347, 663, 63, 521, 63, 1302, 63, 11269, 8, 277, 12, 365, 63, 6604, 304, 267, 291, 423, 521, 63, 3512, 63, 6604, 275, 365, 63, 6604, 267, 340, 365, 63, 6604, 26, 288, 291, 423, 16691, 63, 1302, 14, 2384, 342, 288, 291, 423, 11266, 63, 1302, 14, 2384, 342, 267, 587, 26, 288, 291, 423, 16691, 63, 1302, 14, 8191, 342, 288, 291, 423, 11266, 63, 1302, 14, 8191, 342, 339, 347, 485, 981, 63, 10024, 964, 8, 277, 12, 20178, 12, 4501, 304, 267, 327, 15524, 1263, 3411, 7679, 370, 5126, 1026, 14631, 267, 291, 423, 3118, 63, 7379, 342, 398, 340, 440, 20178, 14, 374, 63, 493, 26, 288, 372, 398, 1414, 63, 1160, 275, 408, 267, 5108, 2708, 1393, 536, 29, 2302, 7778, 267, 8546, 10491, 3916, 267, 8546, 2166, 536, 29, 8130, 1896, 6252, 7622, 2963, 13, 3431, 29, 2052, 267, 8546, 14063, 2292, 7604, 29, 3910, 624, 267, 6252, 275, 1109, 8, 19351, 20793, 3, 1267, 531, 627, 413, 37, 25, 1182, 4501, 9, 267, 340, 440, 6252, 26, 288, 372, 267, 870, 63, 68, 480, 2404, 4655, 666, 367, 1924, 10536, 19, 70, 4696, 2, 450, 334, 4284, 1182, 413, 37, 25, 430, 398, 1414, 275, 1414, 63, 1160, 14 ]
[ 1898, 7800, 378, 88, 8881, 23, 199, 3, 263, 7800, 13, 1196, 653, 2000, 5088, 427, 19446, 199, 3, 3698, 9708, 3757, 328, 281, 812, 17142, 637, 79, 374, 199, 3, 3698, 9708, 28919, 3389, 199, 3, 3698, 9708, 662, 89, 677, 79, 199, 3, 3698, 14894, 1603, 736, 335, 1458, 598, 11438, 84, 199, 3, 3698, 14894, 699, 4175, 573, 199, 3, 3698, 14894, 593, 13876, 869, 352, 262, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 504, 3473, 492, 30449, 12, 19841, 199, 504, 14090, 492, 3820, 199, 199, 504, 18895, 14, 8421, 492, 11424, 12, 31392, 12, 598, 270, 199, 646, 1704, 14352, 199, 199, 504, 2173, 364, 773, 386, 492, 5501, 1145, 199, 504, 2173, 364, 773, 386, 492, 870, 63, 87, 199, 504, 2173, 364, 773, 386, 492, 4884, 199, 504, 2173, 364, 773, 386, 14, 5265, 492, 11349, 2028, 12, 9805, 8930, 9955, 12, 971, 272, 32539, 9955, 12, 19287, 8930, 9955, 199, 504, 2173, 364, 773, 386, 14, 5265, 14, 4368, 492, 6763, 5061, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 15170, 784, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 473, 8704, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 14, 5507, 3887, 492, 4703, 4314, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 14, 8877, 492, 4703, 13652, 199, 504, 2173, 364, 773, 386, 14, 1710, 2663, 492, 664, 63, 9681, 63, 14337, 63, 2326, 199, 504, 2173, 364, 773, 386, 14, 1974, 492, 4907, 63, 7237, 12, 870, 63, 68, 199, 504, 2173, 364, 773, 386, 14, 1974, 14, 515, 492, 5108, 18, 23908, 2302, 421, 199, 533, 644, 811, 964, 19168, 5281, 8, 18891, 14, 3532, 304, 272, 408, 33, 3938, 3035, 3628, 436, 314, 12005, 1700, 1041, 339, 347, 636, 826, 721, 277, 12, 7748, 12, 3555, 304, 267, 1613, 11027, 826, 4533, 398, 291, 423, 6147, 275, 7748, 267, 291, 423, 24444, 63, 3643, 275, 942, 267, 291, 423, 22797, 316, 275, 756, 398, 291, 423, 16691, 63, 1302, 275, 4703, 4314, 342, 267, 291, 423, 11266, 63, 1302, 275, 4703, 4314, 342, 267, 291, 423, 10024, 964, 63, 3467, 275, 644, 811, 964, 9944, 8, 6147, 9, 398, 291, 14, 1389, 63, 928, 8, 9497, 8, 277, 423, 16691, 63, 1302, 12, 9162, 29, 22, 395, 756, 12, 715, 12, 378, 9, 267, 291, 14, 1389, 63, 928, 8, 277, 423, 10024, 964, 63, 3467, 12, 715, 12, 715, 12, 378, 9, 267, 291, 14, 1389, 63, 928, 8, 9497, 8, 277, 423, 11266, 63, 1302, 12, 9162, 29, 22, 395, 756, 12, 715, 12, 378, 9, 398, 367, 1982, 315, 291, 14, 362, 63, 3223, 837, 288, 1982, 14, 2384, 63, 452, 342, 267, 291, 14, 409, 63, 521, 63, 1302, 63, 11269, 8, 5569, 14, 2384, 63, 521, 63, 3512, 9, 398, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 890, 13, 12991, 297, 3660, 291, 423, 873, 63, 581, 1773, 63, 4284, 9, 267, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 15335, 13, 6814, 13, 1430, 297, 3660, 291, 423, 265, 63, 10544, 63, 22797, 9, 267, 291, 423, 10024, 964, 63, 3467, 14, 2242, 360, 12422, 13, 6814, 13, 1430, 297, 3660, 291, 423, 265, 63, 10544, 63, 12422, 9, 398, 291, 423, 1302, 63, 8877, 275, 4703, 13652, 8, 6147, 9, 267, 291, 423, 1302, 63, 8877, 14, 2242, 360, 8284, 297, 291, 423, 265, 63, 8284, 63, 1302, 12, 7748, 9, 398, 291, 423, 581, 1773, 63, 8877, 275, 4703, 13652, 8, 6147, 9, 267, 291, 423, 581, 1773, 63, 8877, 14, 2242, 360, 8284, 297, 291, 423, 265, 63, 8284, 63, 10024, 964, 12, 7748, 9, 398, 4907, 63, 7237, 8, 6147, 12, 283, 5507, 297, 291, 423, 265, 63, 6147, 63, 5507, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 19351, 13, 8924, 297, 291, 423, 265, 63, 19351, 63, 8924, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 19351, 13, 8960, 297, 291, 423, 265, 63, 19351, 63, 8960, 9, 267, 4907, 63, 7237, 8, 6147, 12, 283, 6814, 447, 25895, 297, 291, 423, 265, 63, 25895, 63, 2489, 9, 267, 4907, 63, 7237, 8, 4342, 12, 283, 2489, 297, 291, 423, 265, 63, 19351, 63, 2489, 12, 7748, 9, 398, 291, 14, 2242, 360, 7237, 297, 291, 423, 265, 63, 7237, 9, 267, 291, 423, 873, 8, 6147, 9, 398, 340, 7748, 14, 815, 26, 288, 291, 423, 981, 63, 10024, 964, 8, 6147, 14, 815, 12, 15869, 14, 988, 63, 576, 63, 3438, 9, 339, 347, 663, 63, 521, 63, 1302, 63, 11269, 8, 277, 12, 365, 63, 6604, 304, 267, 291, 423, 521, 63, 3512, 63, 6604, 275, 365, 63, 6604, 267, 340, 365, 63, 6604, 26, 288, 291, 423, 16691, 63, 1302, 14, 2384, 342, 288, 291, 423, 11266, 63, 1302, 14, 2384, 342, 267, 587, 26, 288, 291, 423, 16691, 63, 1302, 14, 8191, 342, 288, 291, 423, 11266, 63, 1302, 14, 8191, 342, 339, 347, 485, 981, 63, 10024, 964, 8, 277, 12, 20178, 12, 4501, 304, 267, 327, 15524, 1263, 3411, 7679, 370, 5126, 1026, 14631, 267, 291, 423, 3118, 63, 7379, 342, 398, 340, 440, 20178, 14, 374, 63, 493, 26, 288, 372, 398, 1414, 63, 1160, 275, 408, 267, 5108, 2708, 1393, 536, 29, 2302, 7778, 267, 8546, 10491, 3916, 267, 8546, 2166, 536, 29, 8130, 1896, 6252, 7622, 2963, 13, 3431, 29, 2052, 267, 8546, 14063, 2292, 7604, 29, 3910, 624, 267, 6252, 275, 1109, 8, 19351, 20793, 3, 1267, 531, 627, 413, 37, 25, 1182, 4501, 9, 267, 340, 440, 6252, 26, 288, 372, 267, 870, 63, 68, 480, 2404, 4655, 666, 367, 1924, 10536, 19, 70, 4696, 2, 450, 334, 4284, 1182, 413, 37, 25, 430, 398, 1414, 275, 1414, 63, 1160, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
prospwro/odoo
addons/website_certification/certification.py
385
1789
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-TODAY OpenERP S.A. <http://www.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/>. # ############################################################################## from openerp.osv import osv, fields class certification_type(osv.Model): _name = 'certification.type' _order = 'name ASC' _columns = { 'name': fields.char("Certification Type", required=True) } class certification_certification(osv.Model): _name = 'certification.certification' _order = 'certification_date DESC' _columns = { 'partner_id': fields.many2one('res.partner', string="Partner", required=True), 'type_id': fields.many2one('certification.type', string="Certification", required=True), 'certification_date': fields.date("Certification Date", required=True), 'certification_score': fields.char("Certification Score", required=True), 'certification_hidden_score': fields.boolean("Hide score on website?") }
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 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, 421, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 533, 3361, 3793, 63, 466, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 2247, 3793, 14, 466, 7, 272, 485, 1648, 275, 283, 354, 20955, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 480, 7851, 3793, 2434, 401, 1415, 29, 549, 9, 272, 789, 421, 199, 533, 3361, 3793, 63, 2247, 3793, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 2247, 3793, 14, 2247, 3793, 7, 272, 485, 1648, 275, 221, 283, 2247, 3793, 63, 602, 23915, 7, 272, 485, 3406, 275, 469, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 1059, 628, 24120, 401, 1415, 29, 549, 395, 267, 283, 466, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2247, 3793, 14, 466, 297, 1059, 628, 7851, 3793, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 602, 356, 1504, 14, 602, 480, 7851, 3793, 6148, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 3397, 356, 1504, 14, 1560, 480, 7851, 3793, 25318, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 5642, 63, 3397, 356, 1504, 14, 4871, 480, 18224, 5396, 641, 10691, 18582, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 11267, 14, 957, 30, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 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, 421, 199, 504, 5166, 14, 4795, 492, 9506, 12, 1504, 421, 199, 533, 3361, 3793, 63, 466, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 2247, 3793, 14, 466, 7, 272, 485, 1648, 275, 283, 354, 20955, 7, 272, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 480, 7851, 3793, 2434, 401, 1415, 29, 549, 9, 272, 789, 421, 199, 533, 3361, 3793, 63, 2247, 3793, 8, 4795, 14, 1685, 304, 272, 485, 354, 275, 283, 2247, 3793, 14, 2247, 3793, 7, 272, 485, 1648, 275, 221, 283, 2247, 3793, 63, 602, 23915, 7, 272, 485, 3406, 275, 469, 267, 283, 3899, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 297, 1059, 628, 24120, 401, 1415, 29, 549, 395, 267, 283, 466, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 2247, 3793, 14, 466, 297, 1059, 628, 7851, 3793, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 602, 356, 1504, 14, 602, 480, 7851, 3793, 6148, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 3397, 356, 1504, 14, 1560, 480, 7851, 3793, 25318, 401, 1415, 29, 549, 395, 267, 283, 2247, 3793, 63, 5642, 63, 3397, 356, 1504, 14, 4871, 480, 18224, 5396, 641, 10691, 18582, 272, 789, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
harshilasu/LinkurApp
y/google-cloud-sdk/platform/gcutil/lib/google_apputils/google/apputils/debug.py
24
1752
#!/usr/bin/env python # Copyright 2004 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. """Import this module to add a hook to call pdb on uncaught exceptions. To enable this, do the following in your top-level application: import google.apputils.debug and then in your main(): google.apputils.debug.Init() Then run your program with --pdb. """ import sys import gflags as flags flags.DEFINE_boolean('pdb', 0, 'Drop into pdb on uncaught exceptions') old_excepthook = None def _DebugHandler(exc_class, value, tb): if not flags.FLAGS.pdb or hasattr(sys, 'ps1') or not sys.stderr.isatty(): # we aren't in interactive mode or we don't have a tty-like # device, so we call the default hook old_excepthook(exc_class, value, tb) else: # Don't impose import overhead on apps that never raise an exception. import traceback import pdb # we are in interactive mode, print the exception... traceback.print_exception(exc_class, value, tb) print # ...then start the debugger in post-mortem mode. pdb.pm() def Init(): # Must back up old excepthook. global old_excepthook # pylint: disable-msg=W0603 old_excepthook = sys.excepthook sys.excepthook = _DebugHandler
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 8353, 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, 13, 1311, 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, 6295, 642, 859, 370, 1050, 282, 5759, 370, 1240, 10543, 641, 625, 24872, 4967, 14, 199, 199, 1378, 4756, 642, 12, 886, 314, 2569, 315, 2195, 2746, 13, 1896, 4223, 26, 199, 199, 646, 6233, 14, 571, 1208, 14, 1757, 199, 199, 460, 2066, 315, 2195, 2446, 837, 199, 199, 3098, 14, 571, 1208, 14, 1757, 14, 9346, 342, 199, 199, 28226, 1255, 2195, 2240, 543, 1553, 10511, 14, 199, 624, 4388, 199, 646, 984, 199, 199, 646, 486, 2469, 465, 3285, 199, 199, 2469, 14, 14603, 63, 4871, 360, 10511, 297, 378, 12, 283, 11070, 1901, 10543, 641, 625, 24872, 4967, 358, 199, 199, 1753, 63, 476, 301, 13316, 6992, 275, 488, 421, 199, 318, 485, 7084, 2461, 8, 2804, 63, 533, 12, 574, 12, 7070, 304, 523, 340, 440, 3285, 14, 4831, 14, 10511, 503, 2688, 8, 1274, 12, 283, 1190, 17, 358, 503, 440, 984, 14, 3083, 14, 21122, 837, 272, 327, 781, 10621, 1133, 315, 12777, 818, 503, 781, 2793, 1133, 1172, 282, 21862, 13, 2930, 272, 327, 2243, 12, 880, 781, 1240, 314, 849, 5759, 272, 2269, 63, 476, 301, 13316, 6992, 8, 2804, 63, 533, 12, 574, 12, 7070, 9, 523, 587, 26, 272, 327, 7529, 1133, 1742, 3362, 492, 24075, 641, 8686, 626, 7078, 746, 376, 1919, 14, 272, 492, 5190, 272, 492, 10543, 272, 327, 781, 787, 315, 12777, 818, 12, 870, 314, 1919, 1396, 272, 5190, 14, 1361, 63, 1971, 8, 2804, 63, 533, 12, 574, 12, 7070, 9, 272, 870, 272, 327, 2263, 12726, 1343, 314, 14958, 315, 2963, 13, 12416, 563, 818, 14, 272, 10543, 14, 7073, 342, 421, 199, 318, 21026, 837, 523, 327, 9498, 1771, 1536, 2269, 11553, 13316, 6992, 14, 523, 2288, 2269, 63, 476, 301, 13316, 6992, 221, 327, 4287, 26, 3507, 13, 1328, 29, 55, 1690, 1644, 523, 2269, 63, 476, 301, 13316, 6992, 275, 984, 14, 476, 301, 13316, 6992, 523, 984, 14, 476, 301, 13316, 6992, 275, 485, 7084, 2461, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1898, 8353, 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, 13, 1311, 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, 6295, 642, 859, 370, 1050, 282, 5759, 370, 1240, 10543, 641, 625, 24872, 4967, 14, 199, 199, 1378, 4756, 642, 12, 886, 314, 2569, 315, 2195, 2746, 13, 1896, 4223, 26, 199, 199, 646, 6233, 14, 571, 1208, 14, 1757, 199, 199, 460, 2066, 315, 2195, 2446, 837, 199, 199, 3098, 14, 571, 1208, 14, 1757, 14, 9346, 342, 199, 199, 28226, 1255, 2195, 2240, 543, 1553, 10511, 14, 199, 624, 4388, 199, 646, 984, 199, 199, 646, 486, 2469, 465, 3285, 199, 199, 2469, 14, 14603, 63, 4871, 360, 10511, 297, 378, 12, 283, 11070, 1901, 10543, 641, 625, 24872, 4967, 358, 199, 199, 1753, 63, 476, 301, 13316, 6992, 275, 488, 421, 199, 318, 485, 7084, 2461, 8, 2804, 63, 533, 12, 574, 12, 7070, 304, 523, 340, 440, 3285, 14, 4831, 14, 10511, 503, 2688, 8, 1274, 12, 283, 1190, 17, 358, 503, 440, 984, 14, 3083, 14, 21122, 837, 272, 327, 781, 10621, 1133, 315, 12777, 818, 503, 781, 2793, 1133, 1172, 282, 21862, 13, 2930, 272, 327, 2243, 12, 880, 781, 1240, 314, 849, 5759, 272, 2269, 63, 476, 301, 13316, 6992, 8, 2804, 63, 533, 12, 574, 12, 7070, 9, 523, 587, 26, 272, 327, 7529, 1133, 1742, 3362, 492, 24075, 641, 8686, 626, 7078, 746, 376, 1919, 14, 272, 492, 5190, 272, 492, 10543, 272, 327, 781, 787, 315, 12777, 818, 12, 870, 314, 1919, 1396, 272, 5190, 14, 1361, 63, 1971, 8, 2804, 63, 533, 12, 574, 12, 7070, 9, 272, 870, 272, 327, 2263, 12726, 1343, 314, 14958, 315, 2963, 13, 12416, 563, 818, 14, 272, 10543, 14, 7073, 342, 421, 199, 318, 21026, 837, 523, 327, 9498, 1771, 1536, 2269, 11553, 13316, 6992, 14, 523, 2288, 2269, 63, 476, 301, 13316, 6992, 221, 327, 4287, 26, 3507, 13, 1328, 29, 55, 1690, 1644, 523, 2269, 63, 476, 301, 13316, 6992, 275, 984, 14, 476, 301, 13316, 6992, 523, 984, 14, 476, 301, 13316, 6992, 275, 485, 7084, 2461, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
Semi-global/edx-platform
common/lib/xmodule/xmodule/html_module.py
32
14609
import os import sys import re import copy import logging import textwrap from lxml import etree from path import Path as path from fs.errors import ResourceNotFoundError from pkg_resources import resource_string import dogstats_wrapper as dog_stats_api from xmodule.util.misc import escape_html_characters from xmodule.contentstore.content import StaticContent from xmodule.editing_module import EditingDescriptor from xmodule.edxnotes_utils import edxnotes from xmodule.html_checker import check_html from xmodule.stringify import stringify_children from xmodule.x_module import XModule, DEPRECATION_VSCOMPAT_EVENT from xmodule.xml_module import XmlDescriptor, name_to_pathname from xblock.core import XBlock from xblock.fields import Scope, String, Boolean, List log = logging.getLogger("edx.courseware") # Make '_' a no-op so we can scrape strings _ = lambda text: text class HtmlFields(object): display_name = String( display_name=_("Display Name"), help=_("This name appears in the horizontal navigation at the top of the page."), scope=Scope.settings, # it'd be nice to have a useful default but it screws up other things; so, # use display_name_with_default for those default=_("Text") ) data = String(help=_("Html contents to display for this module"), default=u"", scope=Scope.content) source_code = String(help=_("Source code for LaTeX documents. This feature is not well-supported."), scope=Scope.settings) use_latex_compiler = Boolean( help=_("Enable LaTeX templates?"), default=False, scope=Scope.settings ) editor = String( help=_("Select Visual to enter content and have the editor automatically create the HTML. Select Raw to edit HTML directly. If you change this setting, you must save the component and then re-open it for editing."), display_name=_("Editor"), default="visual", values=[ {"display_name": _("Visual"), "value": "visual"}, {"display_name": _("Raw"), "value": "raw"} ], scope=Scope.settings ) class HtmlModuleMixin(HtmlFields, XModule): """ Attributes and methods used by HtmlModules internally. """ js = { 'coffee': [ resource_string(__name__, 'js/src/javascript_loader.coffee'), resource_string(__name__, 'js/src/html/display.coffee'), ], 'js': [ resource_string(__name__, 'js/src/collapsible.js'), resource_string(__name__, 'js/src/html/imageModal.js'), resource_string(__name__, 'js/common_static/js/vendor/draggabilly.pkgd.js'), ] } js_module_name = "HTMLModule" css = {'scss': [resource_string(__name__, 'css/html/display.scss')]} def get_html(self): if self.system.anonymous_student_id: return self.data.replace("%%USER_ID%%", self.system.anonymous_student_id) return self.data @edxnotes class HtmlModule(HtmlModuleMixin): """ Module for putting raw html in a course """ @XBlock.supports("multi_device") def student_view(self, context): return super(HtmlModule, self).student_view(context) class HtmlDescriptor(HtmlFields, XmlDescriptor, EditingDescriptor): # pylint: disable=abstract-method """ Module for putting raw html in a course """ mako_template = "widgets/html-edit.html" module_class = HtmlModule filename_extension = "xml" template_dir_name = "html" show_in_read_only_mode = True js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]} js_module_name = "HTMLEditingDescriptor" css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/html/edit.scss')]} # VS[compat] TODO (cpennington): Delete this method once all fall 2012 course # are being edited in the cms @classmethod def backcompat_paths(cls, path): dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=["location:html_descriptor_backcompat_paths"] ) if path.endswith('.html.xml'): path = path[:-9] + '.html' # backcompat--look for html instead of xml if path.endswith('.html.html'): path = path[:-5] # some people like to include .html in filenames.. candidates = [] while os.sep in path: candidates.append(path) _, _, path = path.partition(os.sep) # also look for .html versions instead of .xml nc = [] for candidate in candidates: if candidate.endswith('.xml'): nc.append(candidate[:-4] + '.html') return candidates + nc @classmethod def filter_templates(cls, template, course): """ Filter template that contains 'latex' from templates. Show them only if use_latex_compiler is set to True in course settings. """ return 'latex' not in template['template_id'] or course.use_latex_compiler def get_context(self): """ an override to add in specific rendering context, in this case we need to add in a base path to our c4x content addressing scheme """ _context = EditingDescriptor.get_context(self) # Add some specific HTML rendering context when editing HTML modules where we pass # the root /c4x/ url for assets. This allows client-side substitutions to occur. _context.update({ 'base_asset_url': StaticContent.get_base_url_path_for_course_assets(self.location.course_key), 'enable_latex_compiler': self.use_latex_compiler, 'editor': self.editor }) return _context # NOTE: html descriptors are special. We do not want to parse and # export them ourselves, because that can break things (e.g. lxml # adds body tags when it exports, but they should just be html # snippets that will be included in the middle of pages. @classmethod def load_definition(cls, xml_object, system, location, id_generator): '''Load a descriptor from the specified xml_object: If there is a filename attribute, load it as a string, and log a warning if it is not parseable by etree.HTMLParser. If there is not a filename attribute, the definition is the body of the xml_object, without the root tag (do not want <html> in the middle of a page) Args: xml_object: an lxml.etree._Element containing the definition to load system: the modulestore system or runtime which caches data location: the usage id for the block--used to compute the filename if none in the xml_object id_generator: used by other impls of this method to generate the usage_id ''' filename = xml_object.get('filename') if filename is None: definition_xml = copy.deepcopy(xml_object) cls.clean_metadata_from_xml(definition_xml) return {'data': stringify_children(definition_xml)}, [] else: # html is special. cls.filename_extension is 'xml', but # if 'filename' is in the definition, that means to load # from .html # 'filename' in html pointers is a relative path # (not same as 'html/blah.html' when the pointer is in a directory itself) pointer_path = "{category}/{url_path}".format( category='html', url_path=name_to_pathname(location.name) ) base = path(pointer_path).dirname() # log.debug("base = {0}, base.dirname={1}, filename={2}".format(base, base.dirname(), filename)) filepath = "{base}/{name}.html".format(base=base, name=filename) # log.debug("looking for html file for {0} at {1}".format(location, filepath)) # VS[compat] # TODO (cpennington): If the file doesn't exist at the right path, # give the class a chance to fix it up. The file will be written out # again in the correct format. This should go away once the CMS is # online and has imported all current (fall 2012) courses from xml if not system.resources_fs.exists(filepath): dog_stats_api.increment( DEPRECATION_VSCOMPAT_EVENT, tags=["location:html_descriptor_load_definition"] ) candidates = cls.backcompat_paths(filepath) # log.debug("candidates = {0}".format(candidates)) for candidate in candidates: if system.resources_fs.exists(candidate): filepath = candidate break try: with system.resources_fs.open(filepath) as file: html = file.read().decode('utf-8') # Log a warning if we can't parse the file, but don't error if not check_html(html) and len(html) > 0: msg = "Couldn't parse html in {0}, content = {1}".format(filepath, html) log.warning(msg) system.error_tracker("Warning: " + msg) definition = {'data': html} # TODO (ichuang): remove this after migration # for Fall 2012 LMS migration: keep filename (and unmangled filename) definition['filename'] = [filepath, filename] return definition, [] except (ResourceNotFoundError) as err: msg = 'Unable to load file contents at path {0}: {1} '.format( filepath, err) # add more info and re-raise raise Exception(msg), None, sys.exc_info()[2] # TODO (vshnayder): make export put things in the right places. def definition_to_xml(self, resource_fs): ''' Write <html filename="" [meta-attrs="..."]> to filename.xml, and the html string to filename.html. ''' # Write html to file, return an empty tag pathname = name_to_pathname(self.url_name) filepath = u'{category}/{pathname}.html'.format( category=self.category, pathname=pathname ) resource_fs.makedir(os.path.dirname(filepath), recursive=True, allow_recreate=True) with resource_fs.open(filepath, 'w') as filestream: html_data = self.data.encode('utf-8') filestream.write(html_data) # write out the relative name relname = path(pathname).basename() elt = etree.Element('html') elt.set("filename", relname) return elt @property def non_editable_metadata_fields(self): """ `use_latex_compiler` should not be editable in the Studio settings editor. """ non_editable_fields = super(HtmlDescriptor, self).non_editable_metadata_fields non_editable_fields.append(HtmlDescriptor.use_latex_compiler) return non_editable_fields def index_dictionary(self): xblock_body = super(HtmlDescriptor, self).index_dictionary() # Removing script and style html_content = re.sub( re.compile( r""" <script>.*?</script> | <style>.*?</style> """, re.DOTALL | re.VERBOSE), "", self.data ) html_content = escape_html_characters(html_content) html_body = { "html_content": html_content, "display_name": self.display_name, } if "content" in xblock_body: xblock_body["content"].update(html_body) else: xblock_body["content"] = html_body xblock_body["content_type"] = "Text" return xblock_body class AboutFields(object): display_name = String( help=_("Display name for this module"), scope=Scope.settings, default="overview", ) data = String( help=_("Html contents to display for this module"), default=u"", scope=Scope.content ) @XBlock.tag("detached") class AboutModule(AboutFields, HtmlModuleMixin): """ Overriding defaults but otherwise treated as HtmlModule. """ pass @XBlock.tag("detached") class AboutDescriptor(AboutFields, HtmlDescriptor): """ These pieces of course content are treated as HtmlModules but we need to overload where the templates are located in order to be able to create new ones """ template_dir_name = "about" module_class = AboutModule class StaticTabFields(object): """ The overrides for Static Tabs """ display_name = String( display_name=_("Display Name"), help=_("This name appears in the horizontal navigation at the top of the page."), scope=Scope.settings, default="Empty", ) data = String( default=textwrap.dedent(u"""\ <p>Add the content you want students to see on this page.</p> """), scope=Scope.content, help=_("HTML for the additional pages") ) @XBlock.tag("detached") class StaticTabModule(StaticTabFields, HtmlModuleMixin): """ Supports the field overrides """ pass @XBlock.tag("detached") class StaticTabDescriptor(StaticTabFields, HtmlDescriptor): """ These pieces of course content are treated as HtmlModules but we need to overload where the templates are located in order to be able to create new ones """ template_dir_name = None module_class = StaticTabModule class CourseInfoFields(object): """ Field overrides """ items = List( help=_("List of course update items"), default=[], scope=Scope.content ) data = String( help=_("Html contents to display for this module"), default=u"<ol></ol>", scope=Scope.content ) @XBlock.tag("detached") class CourseInfoModule(CourseInfoFields, HtmlModuleMixin): """ Just to support xblock field overrides """ # statuses STATUS_VISIBLE = 'visible' STATUS_DELETED = 'deleted' @XBlock.tag("detached") class CourseInfoDescriptor(CourseInfoFields, HtmlDescriptor): """ These pieces of course content are treated as HtmlModules but we need to overload where the templates are located in order to be able to create new ones """ template_dir_name = None module_class = CourseInfoModule
agpl-3.0
[ 646, 747, 199, 646, 984, 199, 646, 295, 199, 646, 1331, 199, 646, 2050, 199, 646, 13390, 199, 504, 14490, 492, 7559, 199, 504, 931, 492, 6912, 465, 931, 199, 504, 7449, 14, 2550, 492, 28783, 199, 504, 5496, 63, 4435, 492, 2073, 63, 875, 199, 199, 646, 23454, 3200, 63, 5029, 465, 23454, 63, 3200, 63, 1246, 199, 504, 9872, 14, 1974, 14, 9923, 492, 4772, 63, 1360, 63, 16516, 199, 504, 9872, 14, 28160, 14, 1317, 492, 13599, 2714, 199, 504, 9872, 14, 27057, 63, 578, 492, 662, 328, 1337, 4311, 199, 504, 9872, 14, 8268, 5983, 63, 1208, 492, 22435, 5983, 199, 504, 9872, 14, 1360, 63, 6743, 492, 1104, 63, 1360, 199, 504, 9872, 14, 875, 2021, 492, 1059, 2021, 63, 3223, 199, 504, 9872, 14, 88, 63, 578, 492, 25656, 12, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 199, 504, 9872, 14, 1652, 63, 578, 492, 24881, 4311, 12, 536, 63, 475, 63, 12445, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 12971, 14, 955, 492, 20488, 12, 2624, 12, 9411, 12, 3820, 199, 199, 793, 275, 2050, 14, 5572, 480, 8268, 14, 17744, 531, 199, 199, 3, 4155, 14135, 282, 949, 13, 411, 880, 781, 883, 10328, 321, 3326, 199, 63, 275, 2400, 1318, 26, 1318, 421, 199, 533, 20880, 7304, 8, 785, 304, 272, 2929, 63, 354, 275, 2624, 8, 267, 2929, 63, 354, 9384, 7687, 2812, 1288, 267, 1720, 9384, 2765, 536, 11337, 315, 314, 17528, 19191, 737, 314, 2746, 402, 314, 2034, 7651, 267, 4194, 29, 7812, 14, 1751, 12, 267, 327, 652, 5121, 506, 14213, 370, 1172, 282, 2997, 849, 1325, 652, 308, 1353, 3569, 1536, 1163, 7645, 27, 880, 12, 267, 327, 675, 2929, 63, 354, 63, 1045, 63, 885, 367, 5204, 267, 849, 9384, 1872, 531, 272, 776, 272, 666, 275, 2624, 8, 3437, 9384, 12957, 4072, 370, 2929, 367, 642, 859, 1288, 849, 29, 85, 5151, 4194, 29, 7812, 14, 1317, 9, 272, 1350, 63, 600, 275, 2624, 8, 3437, 9384, 2980, 1233, 367, 14081, 8247, 14, 961, 3878, 365, 440, 5521, 13, 4946, 7651, 4194, 29, 7812, 14, 1751, 9, 272, 675, 63, 7572, 63, 5772, 275, 9411, 8, 267, 1720, 9384, 6476, 14081, 7009, 31, 1288, 267, 849, 29, 797, 12, 267, 4194, 29, 7812, 14, 1751, 272, 776, 272, 8823, 275, 2624, 8, 267, 1720, 9384, 5446, 14702, 370, 9509, 1564, 436, 1172, 314, 8823, 5847, 1218, 314, 4163, 14, 9496, 13480, 370, 5283, 4163, 5370, 14, 982, 1265, 1570, 642, 4260, 12, 1265, 1471, 3354, 314, 3931, 436, 2066, 295, 13, 1490, 652, 367, 20401, 7651, 267, 2929, 63, 354, 9384, 10423, 1288, 267, 849, 628, 16948, 401, 267, 1338, 1524, 288, 2420, 2918, 63, 354, 582, 3824, 15039, 1288, 298, 585, 582, 298, 16948, 6018, 288, 2420, 2918, 63, 354, 582, 3824, 7963, 1288, 298, 585, 582, 298, 1773, 3570, 267, 2156, 267, 4194, 29, 7812, 14, 1751, 272, 776, 421, 199, 533, 20880, 2377, 4256, 8, 12957, 7304, 12, 25656, 304, 272, 408, 272, 9382, 436, 3102, 1202, 701, 20880, 17981, 14448, 14, 272, 408, 272, 8586, 275, 469, 267, 283, 331, 24715, 356, 359, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 9554, 63, 3422, 14, 331, 24715, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 2918, 14, 331, 24715, 659, 267, 2156, 267, 283, 3596, 356, 359, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 761, 4762, 1164, 14, 3596, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 1569, 23689, 14, 3596, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2330, 63, 1986, 15, 3596, 15, 9884, 15, 14479, 71, 371, 382, 590, 14, 4600, 68, 14, 3596, 659, 267, 1622, 272, 789, 272, 8586, 63, 578, 63, 354, 275, 298, 4943, 2377, 2, 272, 11431, 275, 791, 551, 385, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3919, 15, 1360, 15, 2918, 14, 551, 385, 5440, 93, 339, 347, 664, 63, 1360, 8, 277, 304, 267, 340, 291, 14, 2253, 14, 12628, 63, 5500, 63, 344, 26, 288, 372, 291, 14, 576, 14, 1814, 3647, 5, 3791, 63, 998, 8530, 401, 291, 14, 2253, 14, 12628, 63, 5500, 63, 344, 9, 267, 372, 291, 14, 576, 421, 199, 32, 8268, 5983, 199, 533, 20880, 2377, 8, 12957, 2377, 4256, 304, 272, 408, 272, 5673, 367, 32670, 3066, 3517, 315, 282, 2518, 272, 408, 272, 768, 24784, 14, 9823, 480, 3029, 63, 1782, 531, 272, 347, 6474, 63, 1345, 8, 277, 12, 1067, 304, 267, 372, 1613, 8, 12957, 2377, 12, 291, 680, 5500, 63, 1345, 8, 1100, 9, 421, 199, 533, 20880, 4311, 8, 12957, 7304, 12, 24881, 4311, 12, 662, 328, 1337, 4311, 304, 221, 327, 4287, 26, 3507, 29, 6198, 13, 765, 272, 408, 272, 5673, 367, 32670, 3066, 3517, 315, 282, 2518, 272, 408, 272, 26834, 63, 1160, 275, 298, 8583, 15, 1360, 13, 3773, 14, 1360, 2, 272, 859, 63, 533, 275, 20880, 2377, 272, 1788, 63, 3435, 275, 298, 1652, 2, 272, 1978, 63, 694, 63, 354, 275, 298, 1360, 2, 272, 2498, 63, 262, 63, 739, 63, 2118, 63, 632, 275, 715, 339, 8586, 275, 791, 331, 24715, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 3773, 14, 331, 24715, 5440, 93, 272, 8586, 63, 578, 63, 354, 275, 298, 31428, 328, 1337, 4311, 2, 272, 11431, 275, 791, 551, 385, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3919, 15, 7515, 15, 3773, 14, 551, 385, 659, 2073, 63, 875, 3460, 354, 3108, 283, 3919, 15, 1360, 15, 3773, 14, 551, 385, 5440, 93, 339, 327, 21685, 59, 5819, 61, 3254, 334, 67, 897, 1835, 1860, 304, 8496, 642, 1083, 5403, 1006, 11264, 6029, 2518, 272, 327, 787, 3769, 21062, 315, 314, 19240, 272, 768, 3744, 272, 347, 1771, 5819, 63, 3771, 8, 1886, 12, 931, 304, 398, 23454, 63, 3200, 63, 1246, 14, 9728, 8, 288, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 12, 288, 3762, 6270 ]
[ 747, 199, 646, 984, 199, 646, 295, 199, 646, 1331, 199, 646, 2050, 199, 646, 13390, 199, 504, 14490, 492, 7559, 199, 504, 931, 492, 6912, 465, 931, 199, 504, 7449, 14, 2550, 492, 28783, 199, 504, 5496, 63, 4435, 492, 2073, 63, 875, 199, 199, 646, 23454, 3200, 63, 5029, 465, 23454, 63, 3200, 63, 1246, 199, 504, 9872, 14, 1974, 14, 9923, 492, 4772, 63, 1360, 63, 16516, 199, 504, 9872, 14, 28160, 14, 1317, 492, 13599, 2714, 199, 504, 9872, 14, 27057, 63, 578, 492, 662, 328, 1337, 4311, 199, 504, 9872, 14, 8268, 5983, 63, 1208, 492, 22435, 5983, 199, 504, 9872, 14, 1360, 63, 6743, 492, 1104, 63, 1360, 199, 504, 9872, 14, 875, 2021, 492, 1059, 2021, 63, 3223, 199, 504, 9872, 14, 88, 63, 578, 492, 25656, 12, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 199, 504, 9872, 14, 1652, 63, 578, 492, 24881, 4311, 12, 536, 63, 475, 63, 12445, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 12971, 14, 955, 492, 20488, 12, 2624, 12, 9411, 12, 3820, 199, 199, 793, 275, 2050, 14, 5572, 480, 8268, 14, 17744, 531, 199, 199, 3, 4155, 14135, 282, 949, 13, 411, 880, 781, 883, 10328, 321, 3326, 199, 63, 275, 2400, 1318, 26, 1318, 421, 199, 533, 20880, 7304, 8, 785, 304, 272, 2929, 63, 354, 275, 2624, 8, 267, 2929, 63, 354, 9384, 7687, 2812, 1288, 267, 1720, 9384, 2765, 536, 11337, 315, 314, 17528, 19191, 737, 314, 2746, 402, 314, 2034, 7651, 267, 4194, 29, 7812, 14, 1751, 12, 267, 327, 652, 5121, 506, 14213, 370, 1172, 282, 2997, 849, 1325, 652, 308, 1353, 3569, 1536, 1163, 7645, 27, 880, 12, 267, 327, 675, 2929, 63, 354, 63, 1045, 63, 885, 367, 5204, 267, 849, 9384, 1872, 531, 272, 776, 272, 666, 275, 2624, 8, 3437, 9384, 12957, 4072, 370, 2929, 367, 642, 859, 1288, 849, 29, 85, 5151, 4194, 29, 7812, 14, 1317, 9, 272, 1350, 63, 600, 275, 2624, 8, 3437, 9384, 2980, 1233, 367, 14081, 8247, 14, 961, 3878, 365, 440, 5521, 13, 4946, 7651, 4194, 29, 7812, 14, 1751, 9, 272, 675, 63, 7572, 63, 5772, 275, 9411, 8, 267, 1720, 9384, 6476, 14081, 7009, 31, 1288, 267, 849, 29, 797, 12, 267, 4194, 29, 7812, 14, 1751, 272, 776, 272, 8823, 275, 2624, 8, 267, 1720, 9384, 5446, 14702, 370, 9509, 1564, 436, 1172, 314, 8823, 5847, 1218, 314, 4163, 14, 9496, 13480, 370, 5283, 4163, 5370, 14, 982, 1265, 1570, 642, 4260, 12, 1265, 1471, 3354, 314, 3931, 436, 2066, 295, 13, 1490, 652, 367, 20401, 7651, 267, 2929, 63, 354, 9384, 10423, 1288, 267, 849, 628, 16948, 401, 267, 1338, 1524, 288, 2420, 2918, 63, 354, 582, 3824, 15039, 1288, 298, 585, 582, 298, 16948, 6018, 288, 2420, 2918, 63, 354, 582, 3824, 7963, 1288, 298, 585, 582, 298, 1773, 3570, 267, 2156, 267, 4194, 29, 7812, 14, 1751, 272, 776, 421, 199, 533, 20880, 2377, 4256, 8, 12957, 7304, 12, 25656, 304, 272, 408, 272, 9382, 436, 3102, 1202, 701, 20880, 17981, 14448, 14, 272, 408, 272, 8586, 275, 469, 267, 283, 331, 24715, 356, 359, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 9554, 63, 3422, 14, 331, 24715, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 2918, 14, 331, 24715, 659, 267, 2156, 267, 283, 3596, 356, 359, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 761, 4762, 1164, 14, 3596, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 1569, 23689, 14, 3596, 659, 288, 2073, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2330, 63, 1986, 15, 3596, 15, 9884, 15, 14479, 71, 371, 382, 590, 14, 4600, 68, 14, 3596, 659, 267, 1622, 272, 789, 272, 8586, 63, 578, 63, 354, 275, 298, 4943, 2377, 2, 272, 11431, 275, 791, 551, 385, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3919, 15, 1360, 15, 2918, 14, 551, 385, 5440, 93, 339, 347, 664, 63, 1360, 8, 277, 304, 267, 340, 291, 14, 2253, 14, 12628, 63, 5500, 63, 344, 26, 288, 372, 291, 14, 576, 14, 1814, 3647, 5, 3791, 63, 998, 8530, 401, 291, 14, 2253, 14, 12628, 63, 5500, 63, 344, 9, 267, 372, 291, 14, 576, 421, 199, 32, 8268, 5983, 199, 533, 20880, 2377, 8, 12957, 2377, 4256, 304, 272, 408, 272, 5673, 367, 32670, 3066, 3517, 315, 282, 2518, 272, 408, 272, 768, 24784, 14, 9823, 480, 3029, 63, 1782, 531, 272, 347, 6474, 63, 1345, 8, 277, 12, 1067, 304, 267, 372, 1613, 8, 12957, 2377, 12, 291, 680, 5500, 63, 1345, 8, 1100, 9, 421, 199, 533, 20880, 4311, 8, 12957, 7304, 12, 24881, 4311, 12, 662, 328, 1337, 4311, 304, 221, 327, 4287, 26, 3507, 29, 6198, 13, 765, 272, 408, 272, 5673, 367, 32670, 3066, 3517, 315, 282, 2518, 272, 408, 272, 26834, 63, 1160, 275, 298, 8583, 15, 1360, 13, 3773, 14, 1360, 2, 272, 859, 63, 533, 275, 20880, 2377, 272, 1788, 63, 3435, 275, 298, 1652, 2, 272, 1978, 63, 694, 63, 354, 275, 298, 1360, 2, 272, 2498, 63, 262, 63, 739, 63, 2118, 63, 632, 275, 715, 339, 8586, 275, 791, 331, 24715, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3596, 15, 2164, 15, 1360, 15, 3773, 14, 331, 24715, 5440, 93, 272, 8586, 63, 578, 63, 354, 275, 298, 31428, 328, 1337, 4311, 2, 272, 11431, 275, 791, 551, 385, 356, 359, 1927, 63, 875, 3460, 354, 3108, 283, 3919, 15, 7515, 15, 3773, 14, 551, 385, 659, 2073, 63, 875, 3460, 354, 3108, 283, 3919, 15, 1360, 15, 3773, 14, 551, 385, 5440, 93, 339, 327, 21685, 59, 5819, 61, 3254, 334, 67, 897, 1835, 1860, 304, 8496, 642, 1083, 5403, 1006, 11264, 6029, 2518, 272, 327, 787, 3769, 21062, 315, 314, 19240, 272, 768, 3744, 272, 347, 1771, 5819, 63, 3771, 8, 1886, 12, 931, 304, 398, 23454, 63, 3200, 63, 1246, 14, 9728, 8, 288, 3265, 14246, 2594, 63, 7428, 29720, 63, 8193, 12, 288, 3762, 6270, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
doomsterinc/odoo
addons/sale_mrp/__openerp__.py
262
1912
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Sales and MRP Management', 'version': '1.0', 'category': 'Hidden', 'description': """ This module provides facility to the user to install mrp and sales modulesat a time. ==================================================================================== It is basically used when we want to keep track of production orders generated from sales order. It adds sales name and sales Reference on production order. """, 'author': 'OpenERP SA', 'website': 'https://www.odoo.com/page/manufacturing', 'depends': ['mrp', 'sale_stock'], 'data': [ 'security/ir.model.access.csv', 'sale_mrp_view.xml', ], 'demo': [], 'test':[ 'test/cancellation_propagated.yml', 'test/sale_mrp.yml', ], 'installable': True, 'auto_install': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 421, 199, 91, 272, 283, 354, 356, 283, 18220, 436, 603, 18612, 8259, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 14983, 297, 272, 283, 1802, 356, 408, 199, 2765, 859, 6571, 21395, 370, 314, 922, 370, 3907, 333, 4599, 436, 21702, 4621, 292, 282, 900, 14, 199, 5695, 1280, 532, 199, 199, 7940, 365, 26014, 1202, 1380, 781, 2934, 370, 4215, 4426, 402, 9920, 15460, 4046, 199, 504, 21702, 1865, 14, 2779, 9584, 21702, 536, 436, 21702, 10944, 641, 9920, 1865, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1237, 7415, 319, 4039, 297, 272, 283, 8912, 356, 788, 17058, 297, 283, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 8515, 63, 17058, 63, 1345, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 990, 272, 283, 396, 15211, 288, 283, 396, 15, 6406, 2212, 63, 496, 15351, 972, 14, 11714, 297, 288, 283, 396, 15, 8515, 63, 17058, 14, 11714, 297, 12793, 288, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 421, 199, 91, 272, 283, 354, 356, 283, 18220, 436, 603, 18612, 8259, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 14983, 297, 272, 283, 1802, 356, 408, 199, 2765, 859, 6571, 21395, 370, 314, 922, 370, 3907, 333, 4599, 436, 21702, 4621, 292, 282, 900, 14, 199, 5695, 1280, 532, 199, 199, 7940, 365, 26014, 1202, 1380, 781, 2934, 370, 4215, 4426, 402, 9920, 15460, 4046, 199, 504, 21702, 1865, 14, 2779, 9584, 21702, 536, 436, 21702, 10944, 641, 9920, 1865, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 2859, 921, 1544, 14, 22058, 14, 957, 15, 1606, 15, 1237, 7415, 319, 4039, 297, 272, 283, 8912, 356, 788, 17058, 297, 283, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 8515, 63, 17058, 63, 1345, 14, 1652, 297, 272, 2156, 272, 283, 8768, 356, 990, 272, 283, 396, 15211, 288, 283, 396, 15, 6406, 2212, 63, 496, 15351, 972, 14, 11714, 297, 288, 283, 396, 15, 8515, 63, 17058, 14, 11714, 297, 12793, 288, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 715, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
chamakov/namebench
nb_third_party/graphy/backends/google_chart_api/__init__.py
205
2023
#!/usr/bin/python2.4 # # Copyright 2008 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Backend which can generate charts using the Google Chart API.""" from graphy import line_chart from graphy import bar_chart from graphy import pie_chart from graphy.backends.google_chart_api import encoders def _GetChartFactory(chart_class, display_class): """Create a factory method for instantiating charts with displays. Returns a method which, when called, will create & return a chart with chart.display already populated. """ def Inner(*args, **kwargs): chart = chart_class(*args, **kwargs) chart.display = display_class(chart) return chart return Inner # These helper methods make it easy to get chart objects with display # objects already setup. For example, this: # chart = google_chart_api.LineChart() # is equivalent to: # chart = line_chart.LineChart() # chart.display = google_chart_api.encoders.LineChartEncoder(chart) # # (If there's some chart type for which a helper method isn't available, you # can always just instantiate the correct encoder manually, like in the 2nd # example above). # TODO: fix these so they have nice docs in ipython (give them __doc__) LineChart = _GetChartFactory(line_chart.LineChart, encoders.LineChartEncoder) Sparkline = _GetChartFactory(line_chart.Sparkline, encoders.SparklineEncoder) BarChart = _GetChartFactory(bar_chart.BarChart, encoders.BarChartEncoder) PieChart = _GetChartFactory(pie_chart.PieChart, encoders.PieChartEncoder)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 8447, 1314, 883, 3550, 10943, 83, 1808, 314, 4475, 24874, 3261, 1041, 199, 199, 504, 3343, 89, 492, 1004, 63, 9019, 199, 504, 3343, 89, 492, 4681, 63, 9019, 199, 504, 3343, 89, 492, 7708, 63, 9019, 199, 504, 3343, 89, 14, 7765, 14, 3098, 63, 9019, 63, 1246, 492, 10295, 83, 199, 199, 318, 485, 1002, 16372, 2927, 8, 9019, 63, 533, 12, 2929, 63, 533, 304, 523, 408, 2499, 282, 6434, 1083, 367, 9034, 1958, 10943, 83, 543, 17561, 14, 819, 1803, 282, 1083, 1314, 12, 1380, 2797, 12, 911, 1218, 1253, 372, 282, 10943, 543, 523, 10943, 14, 2918, 2575, 16460, 14, 523, 408, 523, 347, 19646, 2031, 589, 12, 1011, 958, 304, 272, 10943, 275, 10943, 63, 533, 2031, 589, 12, 1011, 958, 9, 272, 10943, 14, 2918, 275, 2929, 63, 533, 8, 9019, 9, 272, 372, 10943, 523, 372, 19646, 199, 199, 3, 5723, 5922, 3102, 1852, 652, 8837, 370, 664, 10943, 2251, 543, 2929, 199, 3, 2251, 2575, 3272, 14, 221, 2104, 2893, 12, 642, 26, 199, 3, 257, 10943, 275, 6233, 63, 9019, 63, 1246, 14, 3049, 16372, 342, 199, 3, 365, 7353, 370, 26, 199, 3, 257, 10943, 275, 1004, 63, 9019, 14, 3049, 16372, 342, 199, 3, 257, 10943, 14, 2918, 275, 6233, 63, 9019, 63, 1246, 14, 9347, 83, 14, 3049, 16372, 6679, 8, 9019, 9, 199, 3, 199, 3, 334, 3917, 2337, 1159, 2005, 10943, 730, 367, 1314, 282, 5922, 1083, 5712, 1133, 2808, 12, 1265, 199, 3, 883, 3544, 2951, 17321, 314, 3211, 10295, 10250, 12, 2839, 315, 314, 499, 977, 199, 3, 2893, 3432, 680, 199, 3, 3254, 26, 5325, 3520, 880, 2985, 1172, 14213, 9149, 315, 284, 1548, 334, 26035, 3062, 636, 1301, 3368, 199, 3049, 16372, 275, 485, 1002, 16372, 2927, 8, 604, 63, 9019, 14, 3049, 16372, 12, 10295, 83, 14, 3049, 16372, 6679, 9, 199, 27110, 604, 275, 485, 1002, 16372, 2927, 8, 604, 63, 9019, 14, 27110, 604, 12, 10295, 83, 14, 27110, 604, 6679, 9, 199, 5281, 16372, 221, 275, 485, 1002, 16372, 2927, 8, 1700, 63, 9019, 14, 5281, 16372, 12, 10295, 83, 14, 5281, 16372, 6679, 9, 199, 48, 1873, 16372, 221, 275, 485, 1002, 16372, 2927, 8, 9890, 63, 9019, 14, 48, 1873, 16372, 12, 10295, 83, 14, 48, 1873, 16372, 6679, 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 ]
[ 2647, 15, 1393, 15, 1548, 18, 14, 20, 199, 3, 199, 3, 1898, 9079, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 8447, 1314, 883, 3550, 10943, 83, 1808, 314, 4475, 24874, 3261, 1041, 199, 199, 504, 3343, 89, 492, 1004, 63, 9019, 199, 504, 3343, 89, 492, 4681, 63, 9019, 199, 504, 3343, 89, 492, 7708, 63, 9019, 199, 504, 3343, 89, 14, 7765, 14, 3098, 63, 9019, 63, 1246, 492, 10295, 83, 199, 199, 318, 485, 1002, 16372, 2927, 8, 9019, 63, 533, 12, 2929, 63, 533, 304, 523, 408, 2499, 282, 6434, 1083, 367, 9034, 1958, 10943, 83, 543, 17561, 14, 819, 1803, 282, 1083, 1314, 12, 1380, 2797, 12, 911, 1218, 1253, 372, 282, 10943, 543, 523, 10943, 14, 2918, 2575, 16460, 14, 523, 408, 523, 347, 19646, 2031, 589, 12, 1011, 958, 304, 272, 10943, 275, 10943, 63, 533, 2031, 589, 12, 1011, 958, 9, 272, 10943, 14, 2918, 275, 2929, 63, 533, 8, 9019, 9, 272, 372, 10943, 523, 372, 19646, 199, 199, 3, 5723, 5922, 3102, 1852, 652, 8837, 370, 664, 10943, 2251, 543, 2929, 199, 3, 2251, 2575, 3272, 14, 221, 2104, 2893, 12, 642, 26, 199, 3, 257, 10943, 275, 6233, 63, 9019, 63, 1246, 14, 3049, 16372, 342, 199, 3, 365, 7353, 370, 26, 199, 3, 257, 10943, 275, 1004, 63, 9019, 14, 3049, 16372, 342, 199, 3, 257, 10943, 14, 2918, 275, 6233, 63, 9019, 63, 1246, 14, 9347, 83, 14, 3049, 16372, 6679, 8, 9019, 9, 199, 3, 199, 3, 334, 3917, 2337, 1159, 2005, 10943, 730, 367, 1314, 282, 5922, 1083, 5712, 1133, 2808, 12, 1265, 199, 3, 883, 3544, 2951, 17321, 314, 3211, 10295, 10250, 12, 2839, 315, 314, 499, 977, 199, 3, 2893, 3432, 680, 199, 3, 3254, 26, 5325, 3520, 880, 2985, 1172, 14213, 9149, 315, 284, 1548, 334, 26035, 3062, 636, 1301, 3368, 199, 3049, 16372, 275, 485, 1002, 16372, 2927, 8, 604, 63, 9019, 14, 3049, 16372, 12, 10295, 83, 14, 3049, 16372, 6679, 9, 199, 27110, 604, 275, 485, 1002, 16372, 2927, 8, 604, 63, 9019, 14, 27110, 604, 12, 10295, 83, 14, 27110, 604, 6679, 9, 199, 5281, 16372, 221, 275, 485, 1002, 16372, 2927, 8, 1700, 63, 9019, 14, 5281, 16372, 12, 10295, 83, 14, 5281, 16372, 6679, 9, 199, 48, 1873, 16372, 221, 275, 485, 1002, 16372, 2927, 8, 9890, 63, 9019, 14, 48, 1873, 16372, 12, 10295, 83, 14, 48, 1873, 16372, 6679, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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lyle # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. class RedLeaderError(Exception): """ Base exception for all redleader exceptions """ message = 'An unknown error has occured' def __init__(self, **kwargs): msg = self.message.format(**kwargs) Exception.__init__(self, msg) self.kwargs = kwargs class MissingDependencyError(RedLeaderError): message = 'Resource {source_resource} missing dependency {missing_resource}. Ensure {missing_resource} has been added to the cluster.' class OfflineContextError(RedLeaderError): message = 'Attempting to use offline context like an online context.' class OfflineContextError(RedLeaderError): message = 'OfflineContext cannot perform action {action}'
apache-2.0
[ 3, 10697, 844, 199, 199, 3, 1898, 334, 67, 9, 7800, 603, 19916, 22895, 17793, 30034, 84, 1253, 17815, 14243, 590, 274, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 421, 199, 533, 9572, 2553, 669, 547, 8, 1726, 304, 272, 408, 272, 3523, 1919, 367, 1006, 295, 3011, 669, 4967, 272, 408, 339, 1245, 275, 283, 2493, 5809, 1125, 965, 28408, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1499, 275, 291, 14, 1188, 14, 908, 3682, 958, 9, 267, 2186, 855, 826, 721, 277, 12, 1499, 9, 267, 291, 14, 958, 275, 2074, 421, 199, 533, 15626, 14403, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 4031, 469, 1365, 63, 1927, 93, 4124, 5936, 469, 4752, 63, 1927, 5565, 7523, 469, 4752, 63, 1927, 93, 965, 2757, 3483, 370, 314, 4350, 3530, 199, 199, 533, 28856, 604, 2998, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 15322, 1337, 370, 675, 26302, 1067, 2839, 376, 18470, 1067, 3530, 199, 199, 533, 28856, 604, 2998, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 5195, 604, 2998, 3913, 5147, 1595, 469, 1287, 6834, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10697, 844, 199, 199, 3, 1898, 334, 67, 9, 7800, 603, 19916, 22895, 17793, 30034, 84, 1253, 17815, 14243, 590, 274, 199, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 3, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 199, 3, 4141, 14, 421, 199, 533, 9572, 2553, 669, 547, 8, 1726, 304, 272, 408, 272, 3523, 1919, 367, 1006, 295, 3011, 669, 4967, 272, 408, 339, 1245, 275, 283, 2493, 5809, 1125, 965, 28408, 7, 339, 347, 636, 826, 721, 277, 12, 1011, 958, 304, 267, 1499, 275, 291, 14, 1188, 14, 908, 3682, 958, 9, 267, 2186, 855, 826, 721, 277, 12, 1499, 9, 267, 291, 14, 958, 275, 2074, 421, 199, 533, 15626, 14403, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 4031, 469, 1365, 63, 1927, 93, 4124, 5936, 469, 4752, 63, 1927, 5565, 7523, 469, 4752, 63, 1927, 93, 965, 2757, 3483, 370, 314, 4350, 3530, 199, 199, 533, 28856, 604, 2998, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 15322, 1337, 370, 675, 26302, 1067, 2839, 376, 18470, 1067, 3530, 199, 199, 533, 28856, 604, 2998, 547, 8, 10858, 2553, 669, 547, 304, 272, 1245, 275, 283, 5195, 604, 2998, 3913, 5147, 1595, 469, 1287, 6834, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
bsmedberg/socorro
socorro/unittest/processor/test_registration_client.py
2
22049
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import mock from datetime import datetime, timedelta from configman import ConfigurationManager from nose.tools import eq_, ok_, assert_raises from socorro.processor.registration_client import ( ProcessorAppRegistrationClient, RegistrationError ) from socorro.external.postgresql.dbapi2_util import SQLDidNotReturnSingleValue from socorro.lib.datetimeutil import UTC from socorro.unittest.testbase import TestCase def sequencer(*args): active_iter = iter(args) def foo(*args, **kwargs): try: value = active_iter.next() except StopIteration: raise Exception('out of values') if isinstance(value, Exception): raise value return value return foo class TestProcessorAppRegistrationAgent(TestCase): def test_basic_setup(self): mock_logging = mock.Mock() mock_postgres = mock.Mock() required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres }], argv_source=[] ) m_registration = mock.Mock() class NoRegister(ProcessorAppRegistrationClient): _registration = m_registration with config_manager.context() as config: registrar = NoRegister(config) eq_(registrar.last_checkin_ts, datetime(1999, 1, 1, tzinfo=UTC)) ok_(registrar.processor_id is None) eq_(registrar.processor_name, 'unknown') eq_(m_registration.call_count, 1) def test_checkin_done(self): mock_logging = mock.Mock() mock_postgres = mock.Mock() required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres }], argv_source=[] ) m_registration = mock.Mock() class NoRegister(ProcessorAppRegistrationClient): _registration = m_registration with config_manager.context() as config: registrar = NoRegister(config) utc_now_mock_str = 'socorro.processor.registration_client.utc_now' with mock.patch(utc_now_mock_str) as m_utc_now: a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) m_utc_now.return_value = a_date m_database = mock.MagicMock() m_database.__enter__.return_value = m_database m_connection = m_database registrar.database.return_value = m_database registrar.processor_id = 17 m_cursor = mock.Mock() m_connection.cursor.return_value = m_cursor m_execute = mock.Mock() m_cursor.execute = m_execute registrar.checkin() m_execute.assert_called_once_with( "update processors set lastseendatetime = %s where id = %s", (a_date, 17) ) def test_checkin_not_necessary(self): mock_logging = mock.Mock() mock_postgres = mock.Mock() required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres }], argv_source=[] ) m_registration = mock.Mock() class NoRegister(ProcessorAppRegistrationClient): _registration = m_registration with config_manager.context() as config: registrar = NoRegister(config) utc_now_mock_str = 'socorro.processor.registration_client.utc_now' with mock.patch(utc_now_mock_str) as m_utc_now: a_date = datetime(year=1999, month=1, day=1, hour=0, minute=2, tzinfo=UTC) m_utc_now.return_value = a_date m_database = mock.MagicMock() m_database.__enter__.return_value = m_database m_connection = m_database registrar.database.return_value = m_database registrar.processor_id = 17 m_cursor = mock.Mock() m_connection.cursor.return_value = m_cursor m_execute = mock.Mock() m_cursor.execute = m_execute registrar.checkin() eq_(m_execute.call_count, 0) def test_requested_processor_id(self): mock_logging = mock.Mock() mock_postgres = mock.Mock() required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres }], argv_source=[] ) m_registration = mock.Mock() class NoRegister(ProcessorAppRegistrationClient): _registration = m_registration with config_manager.context() as config: registrar = NoRegister(config) i = registrar._requested_processor_id(0) eq_(i, 0) i = registrar._requested_processor_id(1) eq_(1, i) i = registrar._requested_processor_id('host') eq_('host', i) i = registrar._requested_processor_id('auto') eq_('auto', i) assert_raises(ValueError, registrar._requested_processor_id, 'dwight') def test_select_host_mode_success(self): a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) frequency = timedelta(0, 300) threshold = a_date - frequency mock_logging = mock.Mock() mock_connection = mock.MagicMock() mock_postgres = mock.MagicMock(return_value=mock_connection) mock_connection.return_value = mock_connection mock_connection.__enter__.return_value = mock_connection mock_cursor = mock.Mock() mock_connection.cursor.return_value = mock_cursor mock_execute = mock.Mock() mock_cursor.execute = mock_execute fetchall_returns = sequencer(((threshold,),), ((17,),)) mock_fetchall = mock.Mock(side_effect=fetchall_returns) mock_cursor.fetchall = mock_fetchall mock_fetchone = mock.Mock() mock_cursor.fetchone = mock_fetchone required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres, 'processor_id': 'host', }], argv_source=[] ) with config_manager.context() as config: mock_os_uname_str = 'os.uname' with mock.patch(mock_os_uname_str) as mock_uname: mock_uname.return_value = (0, 'dwight.wilma.sarita') registrar = ProcessorAppRegistrationClient(config) name = registrar.processor_name # There should be 1 and only 1 occurance of a '.' in the name eq_(name.find('.'), name.rfind('.')) eq_(mock_execute.call_count, 4) expected_execute_args = ( (("select now() - interval %s", (frequency,)),), ((("select id from processors" " where lastseendatetime < %s" " and name like %s limit 1"), (threshold, 'dwight_wilma_sarita%')),), ((("update processors set name = %s, " "startdatetime = now(), lastseendatetime = now()" " where id = %s"), (name, 17)),), ((("update jobs set" " starteddatetime = NULL," " completeddatetime = NULL," " success = NULL " "where" " owner = %s"), (17,)),), ) actual_execute_args = mock_execute.call_args_list for expected, actual in zip(expected_execute_args, actual_execute_args): eq_(expected, actual) def test_select_forcehost_mode_success(self): a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) frequency = timedelta(0, 300) threshold = a_date - frequency mock_logging = mock.Mock() mock_connection = mock.MagicMock() mock_postgres = mock.MagicMock(return_value=mock_connection) mock_connection.return_value = mock_connection mock_connection.__enter__.return_value = mock_connection mock_cursor = mock.Mock() mock_connection.cursor.return_value = mock_cursor mock_execute = mock.Mock() mock_cursor.execute = mock_execute fetchall_returns = sequencer(((threshold,),), ((17,),)) mock_fetchall = mock.Mock(side_effect=fetchall_returns) mock_cursor.fetchall = mock_fetchall mock_fetchone = mock.Mock() mock_cursor.fetchone = mock_fetchone required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres, 'processor_id': 'forcehost', }], argv_source=[] ) with config_manager.context() as config: mock_os_uname_str = 'os.uname' with mock.patch(mock_os_uname_str) as mock_uname: mock_uname.return_value = (0, 'wilma') registrar = ProcessorAppRegistrationClient(config) name = registrar.processor_name eq_(mock_execute.call_count, 4) expected_execute_args = ( (("select now() - interval %s", (frequency,)),), ((("select id from processors" " where name like %s limit 1"), ('wilma%',)),), ((("update processors set name = %s, " "startdatetime = now(), lastseendatetime = now()" " where id = %s"), (name, 17)),), ((("update jobs set" " starteddatetime = NULL," " completeddatetime = NULL," " success = NULL " "where" " owner = %s"), (17,)),), ) actual_execute_args = mock_execute.call_args_list for expected, actual in zip(expected_execute_args, actual_execute_args): eq_(expected, actual) def test_select_host_mode_not_found_start_new(self): a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) frequency = timedelta(0, 300) threshold = a_date - frequency mock_logging = mock.Mock() mock_connection = mock.MagicMock() mock_postgres = mock.MagicMock(return_value=mock_connection) mock_connection.return_value = mock_connection mock_connection.__enter__.return_value = mock_connection mock_cursor = mock.Mock() mock_connection.cursor.return_value = mock_cursor mock_execute = mock.Mock() mock_cursor.execute = mock_execute fetchall_returns = sequencer(((threshold,),), SQLDidNotReturnSingleValue(), SQLDidNotReturnSingleValue(), ((92,),),) mock_fetchall = mock.Mock(side_effect=fetchall_returns) mock_cursor.fetchall = mock_fetchall mock_fetchone = mock.Mock() mock_cursor.fetchone = mock_fetchone required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres, 'processor_id': 'host', }], argv_source=[] ) with config_manager.context() as config: mock_os_uname_str = 'os.uname' with mock.patch(mock_os_uname_str) as mock_uname: mock_uname.return_value = (0, 'wilma') registrar = ProcessorAppRegistrationClient(config) name = registrar.processor_name eq_(mock_execute.call_count, 4) expected_execute_args = ( (("select now() - interval %s", (frequency,)),), ((("select id from processors" " where lastseendatetime < %s" " and name like %s limit 1"), (threshold, 'wilma%')),), ((("select id from processors" " where name like 'wilma%'"), None),), ((("insert into processors" " (id," " name," " startdatetime," " lastseendatetime) " "values" " (default," " %s," " now()," " now()) " "returning id"), (name,)),), ) actual_execute_args = mock_execute.call_args_list for expected, actual in zip(expected_execute_args, actual_execute_args): eq_(expected, actual) def test_select_forcehost_mode_not_found_start_new(self): a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) frequency = timedelta(0, 300) threshold = a_date - frequency mock_logging = mock.Mock() mock_connection = mock.MagicMock() mock_postgres = mock.MagicMock(return_value=mock_connection) mock_connection.return_value = mock_connection mock_connection.__enter__.return_value = mock_connection mock_cursor = mock.Mock() mock_connection.cursor.return_value = mock_cursor mock_execute = mock.Mock() mock_cursor.execute = mock_execute fetchall_returns = sequencer(((threshold,),), SQLDidNotReturnSingleValue(), ((92,),),) mock_fetchall = mock.Mock(side_effect=fetchall_returns) mock_cursor.fetchall = mock_fetchall mock_fetchone = mock.Mock() mock_cursor.fetchone = mock_fetchone required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres, 'processor_id': 'forcehost', }], argv_source=[] ) with config_manager.context() as config: mock_os_uname_str = 'os.uname' with mock.patch(mock_os_uname_str) as mock_uname: mock_uname.return_value = (0, 'wilma') registrar = ProcessorAppRegistrationClient(config) name = registrar.processor_name eq_(mock_execute.call_count, 3) expected_execute_args = ( (("select now() - interval %s", (frequency,)),), ((("select id from processors" " where name like %s limit 1"), ('wilma%',)),), ((("insert into processors" " (id," " name," " startdatetime," " lastseendatetime) " "values" " (default," " %s," " now()," " now()) " "returning id"), (name,)),), ) actual_execute_args = mock_execute.call_args_list for expected, actual in zip(expected_execute_args, actual_execute_args): eq_(expected, actual) def test_select_host_mode_not_dead_fail(self): a_date = datetime(year=2012, month=5, day=4, hour=15, minute=10, tzinfo=UTC) frequency = timedelta(0, 300) threshold = a_date - frequency mock_logging = mock.Mock() mock_connection = mock.MagicMock() mock_postgres = mock.MagicMock(return_value=mock_connection) mock_connection.return_value = mock_connection mock_connection.__enter__.return_value = mock_connection mock_cursor = mock.Mock() mock_connection.cursor.return_value = mock_cursor mock_execute = mock.Mock() mock_cursor.execute = mock_execute fetchall_returns = sequencer(((threshold,),), SQLDidNotReturnSingleValue(), ((92,),),) mock_fetchall = mock.Mock(side_effect=fetchall_returns) mock_cursor.fetchall = mock_fetchall mock_fetchone = mock.Mock() mock_cursor.fetchone = mock_fetchone required_config = ProcessorAppRegistrationClient.required_config required_config.add_option('logger', default=mock_logging) config_manager = ConfigurationManager( [required_config], app_name='testapp', app_version='1.0', app_description='app description', values_source_list=[{ 'logger': mock_logging, 'database_class': mock_postgres, 'processor_id': 'host', }], argv_source=[] ) with config_manager.context() as config: mock_os_uname_str = 'os.uname' with mock.patch(mock_os_uname_str) as mock_uname: mock_uname.return_value = (0, 'wilma') assert_raises(RegistrationError, ProcessorAppRegistrationClient, config) eq_(mock_execute.call_count, 3) expected_execute_args = ( (("select now() - interval %s", (frequency,)),), ((("select id from processors" " where lastseendatetime < %s" " and name like %s limit 1"), (threshold, 'wilma%')),), ((("select id from processors" " where name like 'wilma%'"), None),), ) actual_execute_args = mock_execute.call_args_list for expected, actual in zip(expected_execute_args, actual_execute_args): eq_(expected, actual)
mpl-2.0
[ 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 1683, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 504, 1101, 1237, 492, 11595, 2988, 199, 504, 11354, 14, 2537, 492, 3850, 3131, 4112, 3131, 702, 63, 3536, 199, 199, 504, 308, 28720, 293, 14, 6459, 14, 8054, 63, 1258, 492, 334, 523, 31500, 2640, 11757, 3041, 12, 523, 20764, 547, 199, 9, 199, 504, 308, 28720, 293, 14, 5159, 14, 15437, 14, 22103, 18, 63, 1974, 492, 5385, 17366, 1763, 1767, 7200, 1110, 199, 504, 308, 28720, 293, 14, 773, 14, 2083, 1974, 492, 12174, 199, 504, 308, 28720, 293, 14, 2796, 14, 396, 1095, 492, 7640, 199, 199, 318, 542, 1514, 2247, 2031, 589, 304, 272, 4702, 63, 1661, 275, 2740, 8, 589, 9, 339, 347, 3925, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 574, 275, 4702, 63, 1661, 14, 2184, 342, 267, 871, 10852, 26, 288, 746, 2186, 360, 548, 402, 1338, 358, 267, 340, 1228, 8, 585, 12, 2186, 304, 288, 746, 574, 267, 372, 574, 272, 372, 3925, 421, 199, 533, 1379, 10438, 2640, 11757, 7788, 8, 1746, 304, 339, 347, 511, 63, 4316, 63, 2758, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145, 63, 1802, 534, 571, 1369, 297, 881, 1338, 63, 1365, 63, 513, 1524, 91, 288, 283, 2921, 356, 1683, 63, 4806, 12, 288, 283, 4659, 63, 533, 356, 1683, 63, 10675, 881, 19971, 881, 9238, 63, 1365, 9811, 267, 776, 267, 333, 63, 8054, 275, 1683, 14, 3346, 342, 398, 1021, 3091, 7099, 8, 10438, 2640, 11757, 3041, 304, 288, 485, 8054, 275, 333, 63, 8054, 398, 543, 1101, 63, 2609, 14, 1100, 342, 465, 1101, 26, 288, 1295, 31777, 275, 3091, 7099, 8, 888, 9, 288, 3850, 2531, 1135, 31777, 14, 2019, 63, 1074, 262, 63, 1086, 12, 2490, 2197, 8, 16278, 12, 413, 12, 413, 12, 10313, 29, 11288, 430, 288, 4112, 2531, 1135, 31777, 14, 6459, 63, 344, 365, 488, 9, 288, 3850, 2531, 1135, 31777, 14, 6459, 63, 354, 12, 283, 5187, 358, 288, 3850, 2531, 77, 63, 8054, 14, 1250, 63, 835, 12, 413, 9, 339, 347, 511, 63, 1074, 262, 63, 4456, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145, 63, 1802, 534, 571, 1369, 297, 881, 1338, 63, 1365, 63, 513, 1524, 91, 288, 283, 2921, 356, 1683, 63, 4806, 12, 288, 283, 4659, 63, 533, 356, 1683, 63, 10675, 881, 19971, 881, 9238, 63, 1365, 9811, 267, 776, 267, 333, 63, 8054, 275, 1683, 14, 3346, 342, 398, 1021, 3091, 7099, 8, 10438, 2640, 11757, 3041, 304, 288, 485, 8054, 275, 333, 63, 8054, 398, 543, 1101, 63, 2609, 14, 1100, 342, 465, 1101, 26, 288, 1295, 31777, 275, 3091, 7099, 8, 888, 9, 953, 19314, 63, 2131, 63, 1805, 63, 495, 275, 283, 83, 28720, 293, 14, 6459, 14, 8054, 63, 1258, 14, 5834, 63, 2131, 7, 288, 543, 1683, 14, 2068, 8, 5834, 63, 2131, 63, 1805, 63, 495, 9, 465, 333, 63, 5834, 63, 2131, 26, 355, 282, 63, 602, 275, 2197, 8, 3403, 29, 7409, 12, 3303, 5794, 29, 21, 12, 3303, 5382, 29, 20, 12, 3303, 6925, 29, 1046, 12, 3303, 12709, 29, 709, 12, 3303, 10313, 29, 11288, 9, 355, 333, 63, 5834, 63, 2131, 14, 1107, 63, 585, 275, 282, 63, 602, 355, 333, 63, 4659, 275, 1683, 14, 11988, 342, 355, 333, 63, 4659, 855, 4200, 4343, 1107, 63, 585, 275, 333, 63, 4659, 355, 333, 63, 2105, 275, 333, 63, 4659, 355, 1295, 31777, 14, 4659, 14, 1107, 63, 585, 275, 333, 63, 4659, 355, 1295, 31777, 14, 6459, 63, 344, 275, 5557, 2234, 333, 63, 3937, 275, 1683, 14, 3346, 342, 355, 333, 63, 2105, 14, 3937, 14, 1107, 63, 585, 275, 333, 63, 3937, 355, 333, 63, 2526, 275, 1683, 14, 3346, 342, 355, 333, 63, 3937, 14, 2526, 275, 333, 63, 2526, 2234, 1295, 31777, 14, 1074, 262, 342, 2234, 333, 63, 2526, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 2116, 298, 873, 21620, 663, 2061, 261, 500, 323, 521, 275, 450, 83, 2382, 1305, 275, 450, 83, 401, 2116, 334, 65, 63, 602, 12, 5557, 9, 355, 776, 339, 347, 511, 63, 1074, 262, 63, 1397, 63, 17927, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145, 63, 1802, 534, 571, 1369, 297, 881, 1338, 63, 1365, 63, 513, 1524, 91, 288, 283, 2921, 356, 1683, 63, 4806, 12, 288, 283, 4659, 63, 533, 356, 1683, 63, 10675, 881, 19971, 881, 9238, 63, 1365 ]
[ 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 646, 1683, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 504, 1101, 1237, 492, 11595, 2988, 199, 504, 11354, 14, 2537, 492, 3850, 3131, 4112, 3131, 702, 63, 3536, 199, 199, 504, 308, 28720, 293, 14, 6459, 14, 8054, 63, 1258, 492, 334, 523, 31500, 2640, 11757, 3041, 12, 523, 20764, 547, 199, 9, 199, 504, 308, 28720, 293, 14, 5159, 14, 15437, 14, 22103, 18, 63, 1974, 492, 5385, 17366, 1763, 1767, 7200, 1110, 199, 504, 308, 28720, 293, 14, 773, 14, 2083, 1974, 492, 12174, 199, 504, 308, 28720, 293, 14, 2796, 14, 396, 1095, 492, 7640, 199, 199, 318, 542, 1514, 2247, 2031, 589, 304, 272, 4702, 63, 1661, 275, 2740, 8, 589, 9, 339, 347, 3925, 2031, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 574, 275, 4702, 63, 1661, 14, 2184, 342, 267, 871, 10852, 26, 288, 746, 2186, 360, 548, 402, 1338, 358, 267, 340, 1228, 8, 585, 12, 2186, 304, 288, 746, 574, 267, 372, 574, 272, 372, 3925, 421, 199, 533, 1379, 10438, 2640, 11757, 7788, 8, 1746, 304, 339, 347, 511, 63, 4316, 63, 2758, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145, 63, 1802, 534, 571, 1369, 297, 881, 1338, 63, 1365, 63, 513, 1524, 91, 288, 283, 2921, 356, 1683, 63, 4806, 12, 288, 283, 4659, 63, 533, 356, 1683, 63, 10675, 881, 19971, 881, 9238, 63, 1365, 9811, 267, 776, 267, 333, 63, 8054, 275, 1683, 14, 3346, 342, 398, 1021, 3091, 7099, 8, 10438, 2640, 11757, 3041, 304, 288, 485, 8054, 275, 333, 63, 8054, 398, 543, 1101, 63, 2609, 14, 1100, 342, 465, 1101, 26, 288, 1295, 31777, 275, 3091, 7099, 8, 888, 9, 288, 3850, 2531, 1135, 31777, 14, 2019, 63, 1074, 262, 63, 1086, 12, 2490, 2197, 8, 16278, 12, 413, 12, 413, 12, 10313, 29, 11288, 430, 288, 4112, 2531, 1135, 31777, 14, 6459, 63, 344, 365, 488, 9, 288, 3850, 2531, 1135, 31777, 14, 6459, 63, 354, 12, 283, 5187, 358, 288, 3850, 2531, 77, 63, 8054, 14, 1250, 63, 835, 12, 413, 9, 339, 347, 511, 63, 1074, 262, 63, 4456, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145, 63, 1802, 534, 571, 1369, 297, 881, 1338, 63, 1365, 63, 513, 1524, 91, 288, 283, 2921, 356, 1683, 63, 4806, 12, 288, 283, 4659, 63, 533, 356, 1683, 63, 10675, 881, 19971, 881, 9238, 63, 1365, 9811, 267, 776, 267, 333, 63, 8054, 275, 1683, 14, 3346, 342, 398, 1021, 3091, 7099, 8, 10438, 2640, 11757, 3041, 304, 288, 485, 8054, 275, 333, 63, 8054, 398, 543, 1101, 63, 2609, 14, 1100, 342, 465, 1101, 26, 288, 1295, 31777, 275, 3091, 7099, 8, 888, 9, 953, 19314, 63, 2131, 63, 1805, 63, 495, 275, 283, 83, 28720, 293, 14, 6459, 14, 8054, 63, 1258, 14, 5834, 63, 2131, 7, 288, 543, 1683, 14, 2068, 8, 5834, 63, 2131, 63, 1805, 63, 495, 9, 465, 333, 63, 5834, 63, 2131, 26, 355, 282, 63, 602, 275, 2197, 8, 3403, 29, 7409, 12, 3303, 5794, 29, 21, 12, 3303, 5382, 29, 20, 12, 3303, 6925, 29, 1046, 12, 3303, 12709, 29, 709, 12, 3303, 10313, 29, 11288, 9, 355, 333, 63, 5834, 63, 2131, 14, 1107, 63, 585, 275, 282, 63, 602, 355, 333, 63, 4659, 275, 1683, 14, 11988, 342, 355, 333, 63, 4659, 855, 4200, 4343, 1107, 63, 585, 275, 333, 63, 4659, 355, 333, 63, 2105, 275, 333, 63, 4659, 355, 1295, 31777, 14, 4659, 14, 1107, 63, 585, 275, 333, 63, 4659, 355, 1295, 31777, 14, 6459, 63, 344, 275, 5557, 2234, 333, 63, 3937, 275, 1683, 14, 3346, 342, 355, 333, 63, 2105, 14, 3937, 14, 1107, 63, 585, 275, 333, 63, 3937, 355, 333, 63, 2526, 275, 1683, 14, 3346, 342, 355, 333, 63, 3937, 14, 2526, 275, 333, 63, 2526, 2234, 1295, 31777, 14, 1074, 262, 342, 2234, 333, 63, 2526, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 2116, 298, 873, 21620, 663, 2061, 261, 500, 323, 521, 275, 450, 83, 2382, 1305, 275, 450, 83, 401, 2116, 334, 65, 63, 602, 12, 5557, 9, 355, 776, 339, 347, 511, 63, 1074, 262, 63, 1397, 63, 17927, 8, 277, 304, 267, 1683, 63, 4806, 275, 1683, 14, 3346, 342, 267, 1683, 63, 10675, 275, 1683, 14, 3346, 342, 267, 1415, 63, 888, 275, 31500, 2640, 11757, 3041, 14, 2427, 63, 888, 267, 1415, 63, 888, 14, 525, 63, 1422, 360, 2921, 297, 849, 29, 1805, 63, 4806, 9, 398, 1101, 63, 2609, 275, 11595, 2988, 8, 881, 359, 2427, 63, 888, 467, 881, 1145, 63, 354, 534, 19700, 297, 881, 1145, 63, 1023, 534, 17, 14, 16, 297, 881, 1145,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
3dfxmadscientist/CBSS
addons/document_page/document_page.py
51
5465
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import fields, osv from openerp.tools.translate import _ import difflib from openerp import tools class document_page(osv.osv): _name = "document.page" _description = "Document Page" _order = 'name' def _get_page_index(self, cr, uid, page, link=True): index = [] for subpage in page.child_ids: index += ["<li>"+ self._get_page_index(cr, uid, subpage) +"</li>"] r = '' if link: r = '<a href="#id=%s">%s</a>'%(page.id,page.name) if index: r += "<ul>" + "".join(index) + "</ul>" return r def _get_display_content(self, cr, uid, ids, name, args, context=None): res = {} for page in self.browse(cr, uid, ids, context=context): if page.type == "category": content = self._get_page_index(cr, uid, page, link=False) else: content = page.content res[page.id] = content return res _columns = { 'name': fields.char('Title', required=True), 'type':fields.selection([('content','Content'), ('category','Category')], 'Type', help="Page type"), 'parent_id': fields.many2one('document.page', 'Category', domain=[('type','=','category')]), 'child_ids': fields.one2many('document.page', 'parent_id', 'Children'), 'content': fields.text("Content"), 'display_content': fields.function(_get_display_content, string='Displayed Content', type='text'), 'history_ids': fields.one2many('document.page.history', 'page_id', 'History'), 'menu_id': fields.many2one('ir.ui.menu', "Menu", readonly=True), 'create_date': fields.datetime("Created on", select=True, readonly=True), 'create_uid': fields.many2one('res.users', 'Author', select=True, readonly=True), 'write_date': fields.datetime("Modification Date", select=True, readonly=True), 'write_uid': fields.many2one('res.users', "Last Contributor", select=True, readonly=True), } _defaults = { 'type':'content', } def onchange_parent_id(self, cr, uid, ids, parent_id, content, context=None): res = {} if parent_id and not content: parent = self.browse(cr, uid, parent_id, context=context) if parent.type == "category": res['value'] = { 'content': parent.content, } return res def create_history(self, cr, uid, ids, vals, context=None): for i in ids: history = self.pool.get('document.page.history') if vals.get('content'): res = { 'content': vals.get('content', ''), 'page_id': i, } history.create(cr, uid, res) def create(self, cr, uid, vals, context=None): page_id = super(document_page, self).create(cr, uid, vals, context) self.create_history(cr, uid, [page_id], vals, context) return page_id def write(self, cr, uid, ids, vals, context=None): result = super(document_page, self).write(cr, uid, ids, vals, context) self.create_history(cr, uid, ids, vals, context) return result class document_page_history(osv.osv): _name = "document.page.history" _description = "Document Page History" _order = 'id DESC' _rec_name = "create_date" _columns = { 'page_id': fields.many2one('document.page', 'Page'), 'summary': fields.char('Summary', size=256, select=True), 'content': fields.text("Content"), 'create_date': fields.datetime("Date"), 'create_uid': fields.many2one('res.users', "Modified By"), } def getDiff(self, cr, uid, v1, v2, context=None): history_pool = self.pool.get('document.page.history') text1 = history_pool.read(cr, uid, [v1], ['content'])[0]['content'] text2 = history_pool.read(cr, uid, [v2], ['content'])[0]['content'] line1 = line2 = '' if text1: line1 = text1.splitlines(1) if text2: line2 = text2.splitlines(1) if (not line1 and not line2) or (line1 == line2): raise osv.except_osv(_('Warning!'), _('There are no changes in revisions.')) diff = difflib.HtmlDiff() return diff.make_table(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=True) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 27070, 199, 504, 5166, 492, 7249, 199, 199, 533, 2213, 63, 1606, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 3554, 14, 1606, 2, 272, 485, 1802, 275, 298, 5564, 10331, 2, 272, 485, 1648, 275, 283, 354, 7, 339, 347, 485, 362, 63, 1606, 63, 1080, 8, 277, 12, 2467, 12, 1747, 12, 2034, 12, 2142, 29, 549, 304, 267, 1478, 275, 942, 267, 367, 1007, 1606, 315, 2034, 14, 1739, 63, 1580, 26, 288, 1478, 847, 24652, 317, 4335, 11, 291, 423, 362, 63, 1606, 63, 1080, 8, 1556, 12, 1747, 12, 1007, 1606, 9, 435, 2, 1108, 317, 30, 937, 267, 519, 275, 2125, 267, 340, 2142, 26, 288, 519, 275, 2650, 65, 4369, 13476, 344, 2458, 83, 14423, 83, 1108, 65, 3524, 2840, 1606, 14, 344, 12, 1606, 14, 354, 9, 267, 340, 1478, 26, 288, 519, 847, 3886, 348, 4335, 435, 10587, 904, 8, 1080, 9, 435, 15683, 348, 4335, 267, 372, 519, 339, 347, 485, 362, 63, 2918, 63, 1317, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 367, 2034, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 2034, 14, 466, 508, 298, 3710, 582, 2049, 1564, 275, 291, 423, 362, 63, 1606, 63, 1080, 8, 1556, 12, 1747, 12, 2034, 12, 2142, 29, 797, 9, 288, 587, 26, 2049, 1564, 275, 2034, 14, 1317, 288, 522, 59, 1606, 14, 344, 61, 275, 221, 1564, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 6888, 297, 1415, 29, 549, 395, 267, 283, 466, 356, 955, 14, 5592, 8318, 1317, 1673, 2714, 659, 661, 3710, 1673, 7841, 2665, 283, 804, 297, 1720, 628, 3276, 730, 1288, 24807, 283, 1708, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 3554, 14, 1606, 297, 283, 7841, 297, 2881, 11699, 466, 1673, 29511, 3710, 22864, 267, 283, 1739, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 3554, 14, 1606, 297, 283, 1708, 63, 344, 297, 283, 7139, 659, 398, 283, 1317, 356, 1504, 14, 505, 480, 2714, 1288, 267, 283, 2918, 63, 1317, 356, 1504, 14, 1593, 1547, 362, 63, 2918, 63, 1317, 12, 1059, 534, 7687, 379, 6646, 297, 730, 534, 505, 659, 398, 283, 5570, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 3554, 14, 1606, 14, 5570, 297, 283, 1606, 63, 344, 297, 283, 12114, 659, 267, 283, 4470, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 723, 14, 1907, 14, 4470, 297, 298, 5977, 401, 6863, 29, 549, 395, 398, 283, 981, 63, 602, 356, 1504, 14, 2083, 480, 10502, 641, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 981, 63, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 5949, 297, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 952, 63, 602, 356, 1504, 14, 2083, 480, 29188, 6148, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 952, 63, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 298, 6090, 17636, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 466, 5242, 1317, 297, 272, 789, 339, 347, 20258, 63, 1708, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1676, 63, 344, 12, 1564, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 340, 1676, 63, 344, 436, 440, 1564, 26, 288, 1676, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1676, 63, 344, 12, 1067, 29, 1100, 9, 288, 340, 1676, 14, 466, 508, 298, 3710, 582, 355, 522, 459, 585, 418, 275, 469, 490, 283, 1317, 356, 1676, 14, 1317, 12, 355, 789, 267, 372, 522, 339, 347, 1218, 63, 5570, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 403, 304, 267, 367, 284, 315, 2762, 26, 288, 7994, 275, 291, 14, 2293, 14, 362, 360, 3554, 14, 1606, 14, 5570, 358, 288, 340, 5322, 14, 362, 360, 1317, 735, 355, 522, 275, 469, 490, 283, 1317, 356, 5322, 14, 362, 360, 1317, 297, 9929, 490, 283, 1606, 63, 344, 356, 284, 12, 355, 789, 355, 7994, 14, 981, 8, 1556, 12, 1747, 12, 522, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 2034, 63, 344, 275, 1613, 8, 3554, 63, 1606, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 9, 267, 291, 14, 981, 63, 5570, 8, 1556, 12, 1747, 12, 359, 1606, 63, 344, 467, 5322, 12, 1067, 9, 267, 372, 2034, 63, 344, 339, 347, 2218, 8, 277, 12, 2467 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 646, 27070, 199, 504, 5166, 492, 7249, 199, 199, 533, 2213, 63, 1606, 8, 4795, 14, 4795, 304, 272, 485, 354, 275, 298, 3554, 14, 1606, 2, 272, 485, 1802, 275, 298, 5564, 10331, 2, 272, 485, 1648, 275, 283, 354, 7, 339, 347, 485, 362, 63, 1606, 63, 1080, 8, 277, 12, 2467, 12, 1747, 12, 2034, 12, 2142, 29, 549, 304, 267, 1478, 275, 942, 267, 367, 1007, 1606, 315, 2034, 14, 1739, 63, 1580, 26, 288, 1478, 847, 24652, 317, 4335, 11, 291, 423, 362, 63, 1606, 63, 1080, 8, 1556, 12, 1747, 12, 1007, 1606, 9, 435, 2, 1108, 317, 30, 937, 267, 519, 275, 2125, 267, 340, 2142, 26, 288, 519, 275, 2650, 65, 4369, 13476, 344, 2458, 83, 14423, 83, 1108, 65, 3524, 2840, 1606, 14, 344, 12, 1606, 14, 354, 9, 267, 340, 1478, 26, 288, 519, 847, 3886, 348, 4335, 435, 10587, 904, 8, 1080, 9, 435, 15683, 348, 4335, 267, 372, 519, 339, 347, 485, 362, 63, 2918, 63, 1317, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 367, 2034, 315, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 340, 2034, 14, 466, 508, 298, 3710, 582, 2049, 1564, 275, 291, 423, 362, 63, 1606, 63, 1080, 8, 1556, 12, 1747, 12, 2034, 12, 2142, 29, 797, 9, 288, 587, 26, 2049, 1564, 275, 2034, 14, 1317, 288, 522, 59, 1606, 14, 344, 61, 275, 221, 1564, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 283, 354, 356, 1504, 14, 1560, 360, 6888, 297, 1415, 29, 549, 395, 267, 283, 466, 356, 955, 14, 5592, 8318, 1317, 1673, 2714, 659, 661, 3710, 1673, 7841, 2665, 283, 804, 297, 1720, 628, 3276, 730, 1288, 24807, 283, 1708, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 3554, 14, 1606, 297, 283, 7841, 297, 2881, 11699, 466, 1673, 29511, 3710, 22864, 267, 283, 1739, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 3554, 14, 1606, 297, 283, 1708, 63, 344, 297, 283, 7139, 659, 398, 283, 1317, 356, 1504, 14, 505, 480, 2714, 1288, 267, 283, 2918, 63, 1317, 356, 1504, 14, 1593, 1547, 362, 63, 2918, 63, 1317, 12, 1059, 534, 7687, 379, 6646, 297, 730, 534, 505, 659, 398, 283, 5570, 63, 1580, 356, 1504, 14, 368, 18, 3479, 360, 3554, 14, 1606, 14, 5570, 297, 283, 1606, 63, 344, 297, 283, 12114, 659, 267, 283, 4470, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 723, 14, 1907, 14, 4470, 297, 298, 5977, 401, 6863, 29, 549, 395, 398, 283, 981, 63, 602, 356, 1504, 14, 2083, 480, 10502, 641, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 981, 63, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 283, 5949, 297, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 952, 63, 602, 356, 1504, 14, 2083, 480, 29188, 6148, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 267, 283, 952, 63, 1535, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3707, 297, 298, 6090, 17636, 401, 3504, 29, 549, 12, 6863, 29, 549, 395, 272, 789, 272, 485, 4322, 275, 469, 267, 283, 466, 5242, 1317, 297, 272, 789, 339, 347, 20258, 63, 1708, 63, 344, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1676, 63, 344, 12, 1564, 12, 1067, 29, 403, 304, 267, 522, 275, 1052, 267, 340, 1676, 63, 344, 436, 440, 1564, 26, 288, 1676, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 1676, 63, 344, 12, 1067, 29, 1100, 9, 288, 340, 1676, 14, 466, 508, 298, 3710, 582, 355, 522, 459, 585, 418, 275, 469, 490, 283, 1317, 356, 1676, 14, 1317, 12, 355, 789, 267, 372, 522, 339, 347, 1218, 63, 5570, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 5322, 12, 1067, 29, 403, 304, 267, 367, 284, 315, 2762, 26, 288, 7994, 275, 291, 14, 2293, 14, 362, 360, 3554, 14, 1606, 14, 5570, 358, 288, 340, 5322, 14, 362, 360, 1317, 735, 355, 522, 275, 469, 490, 283, 1317, 356, 5322, 14, 362, 360, 1317, 297, 9929, 490, 283, 1606, 63, 344, 356, 284, 12, 355, 789, 355, 7994, 14, 981, 8, 1556, 12, 1747, 12, 522, 9, 339, 347, 1218, 8, 277, 12, 2467, 12, 1747, 12, 5322, 12, 1067, 29, 403, 304, 267, 2034, 63, 344, 275, 1613, 8, 3554, 63, 1606, 12, 291, 680, 981, 8, 1556, 12, 1747, 12, 5322, 12, 1067, 9, 267, 291, 14, 981, 63, 5570, 8, 1556, 12, 1747, 12, 359, 1606, 63, 344, 467, 5322, 12, 1067, 9, 267, 372, 2034, 63, 344, 339, 347, 2218, 8, 277, 12, 2467, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jayceyxc/hue
desktop/core/ext-py/Django-1.6.10/tests/modeladmin/models.py
55
1527
# coding: utf-8 from django.contrib.auth.models import User from django.db import models from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Band(models.Model): name = models.CharField(max_length=100) bio = models.TextField() sign_date = models.DateField() class Meta: ordering = ('name',) def __str__(self): return self.name class Concert(models.Model): main_band = models.ForeignKey(Band, related_name='main_concerts') opening_band = models.ForeignKey(Band, related_name='opening_concerts', blank=True) day = models.CharField(max_length=3, choices=((1, 'Fri'), (2, 'Sat'))) transport = models.CharField(max_length=100, choices=( (1, 'Plane'), (2, 'Train'), (3, 'Bus') ), blank=True) class ValidationTestModel(models.Model): name = models.CharField(max_length=100) slug = models.SlugField() users = models.ManyToManyField(User) state = models.CharField(max_length=2, choices=(("CO", "Colorado"), ("WA", "Washington"))) is_active = models.BooleanField(default=False) pub_date = models.DateTimeField() band = models.ForeignKey(Band) no = models.IntegerField(verbose_name="Number", blank=True, null=True) # This field is intentionally 2 characters long. See #16080. def decade_published_in(self): return self.pub_date.strftime('%Y')[:3] + "0's" class ValidationTestInlineModel(models.Model): parent = models.ForeignKey(ValidationTestModel)
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 27709, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 28897, 275, 1709, 14, 6254, 342, 272, 2070, 63, 602, 275, 1709, 14, 14071, 342, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 1448, 4736, 8, 992, 14, 1685, 304, 272, 2446, 63, 7877, 275, 1709, 14, 3190, 8, 11675, 12, 4048, 63, 354, 534, 973, 63, 388, 8356, 358, 272, 13618, 63, 7877, 275, 1709, 14, 3190, 8, 11675, 12, 4048, 63, 354, 534, 21849, 63, 388, 8356, 297, 267, 4596, 29, 549, 9, 272, 5382, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 19, 12, 3415, 31934, 17, 12, 283, 22533, 659, 334, 18, 12, 283, 22332, 7058, 272, 7773, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 3415, 2687, 267, 334, 17, 12, 283, 23363, 659, 267, 334, 18, 12, 283, 18591, 659, 267, 334, 19, 12, 283, 12106, 358, 272, 2318, 4596, 29, 549, 9, 199, 199, 533, 19381, 18282, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8889, 275, 1709, 14, 17315, 342, 272, 4390, 275, 1709, 14, 7624, 8, 1899, 9, 272, 1174, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 12, 3415, 2687, 480, 1439, 401, 298, 4117, 5129, 1288, 1689, 9004, 401, 298, 55, 1119, 31673, 13324, 272, 365, 63, 2682, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 7974, 63, 602, 275, 1709, 14, 4626, 342, 272, 10981, 275, 1709, 14, 3190, 8, 11675, 9, 272, 949, 275, 1709, 14, 3901, 8, 3832, 63, 354, 628, 3259, 401, 4596, 29, 549, 12, 2973, 29, 549, 9, 327, 961, 901, 365, 32005, 499, 4110, 1846, 14, 1666, 327, 8488, 1257, 14, 339, 347, 477, 9490, 63, 8987, 63, 262, 8, 277, 304, 267, 372, 291, 14, 5645, 63, 602, 14, 6205, 3508, 57, 358, 1491, 19, 61, 435, 298, 16, 1159, 2, 199, 199, 533, 19381, 774, 10307, 1685, 8, 992, 14, 1685, 304, 272, 1676, 275, 1709, 14, 3190, 8, 13816, 18282, 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 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 1208, 14, 2991, 492, 2366, 63, 18, 63, 2975, 63, 6490, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 27709, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 28897, 275, 1709, 14, 6254, 342, 272, 2070, 63, 602, 275, 1709, 14, 14071, 342, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 199, 199, 533, 1448, 4736, 8, 992, 14, 1685, 304, 272, 2446, 63, 7877, 275, 1709, 14, 3190, 8, 11675, 12, 4048, 63, 354, 534, 973, 63, 388, 8356, 358, 272, 13618, 63, 7877, 275, 1709, 14, 3190, 8, 11675, 12, 4048, 63, 354, 534, 21849, 63, 388, 8356, 297, 267, 4596, 29, 549, 9, 272, 5382, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 19, 12, 3415, 31934, 17, 12, 283, 22533, 659, 334, 18, 12, 283, 22332, 7058, 272, 7773, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 12, 3415, 2687, 267, 334, 17, 12, 283, 23363, 659, 267, 334, 18, 12, 283, 18591, 659, 267, 334, 19, 12, 283, 12106, 358, 272, 2318, 4596, 29, 549, 9, 199, 199, 533, 19381, 18282, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8889, 275, 1709, 14, 17315, 342, 272, 4390, 275, 1709, 14, 7624, 8, 1899, 9, 272, 1174, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 12, 3415, 2687, 480, 1439, 401, 298, 4117, 5129, 1288, 1689, 9004, 401, 298, 55, 1119, 31673, 13324, 272, 365, 63, 2682, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 7974, 63, 602, 275, 1709, 14, 4626, 342, 272, 10981, 275, 1709, 14, 3190, 8, 11675, 9, 272, 949, 275, 1709, 14, 3901, 8, 3832, 63, 354, 628, 3259, 401, 4596, 29, 549, 12, 2973, 29, 549, 9, 327, 961, 901, 365, 32005, 499, 4110, 1846, 14, 1666, 327, 8488, 1257, 14, 339, 347, 477, 9490, 63, 8987, 63, 262, 8, 277, 304, 267, 372, 291, 14, 5645, 63, 602, 14, 6205, 3508, 57, 358, 1491, 19, 61, 435, 298, 16, 1159, 2, 199, 199, 533, 19381, 774, 10307, 1685, 8, 992, 14, 1685, 304, 272, 1676, 275, 1709, 14, 3190, 8, 13816, 18282, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jrleeman/MetPy
metpy/calc/tests/test_turbulence.py
5
15724
# Copyright (c) 2008,2015 MetPy Developers. # Distributed under the terms of the BSD 3-Clause License. # SPDX-License-Identifier: BSD-3-Clause """Test the `turbulence` module.""" import numpy as np from numpy.testing import assert_almost_equal, assert_array_equal import pytest from metpy.calc.turbulence import friction_velocity, get_perturbation, kinematic_flux, tke # # TKE Tests # @pytest.fixture() def uvw_and_known_tke(): """Provide a set of u,v,w with a known tke value.""" u = np.array([-2, -1, 0, 1, 2]) v = -u w = 2 * u # 0.5 * sqrt(2 + 2 + 8) e_true = np.sqrt(12) / 2. return u, v, w, e_true def test_no_tke_1d(): """Test tke calculation where the expected value is 0.""" observations = 5 # given all the values are the same, there should not be any tke u = np.ones(observations) v = np.ones(observations) w = np.ones(observations) e_zero = 0 assert_array_equal(e_zero, tke(u, v, w)) def test_no_tke_2d_axis_last(): """Test 0 tke calculation with 2D arrays; calculation axis is last.""" observations = 5 instruments = 2 # given all the values are the same, there should not be any tke u = np.ones((instruments, observations)) v = np.ones((instruments, observations)) w = np.ones((instruments, observations)) e_zero = np.zeros(instruments) assert_array_equal(e_zero, tke(u, v, w, axis=-1)) def test_no_tke_2d_axis_first(): """Test 0 tke calculation with 2D arrays; calculation axis is first.""" observations = 5 instruments = 2 # given all the values are the same, there should not be any tke u = np.ones((observations, instruments)) v = np.ones((observations, instruments)) w = np.ones((observations, instruments)) e_zero = np.zeros(instruments) assert_array_equal(e_zero, tke(u, v, w, axis=0)) def test_known_tke(uvw_and_known_tke): """Test basic behavior of tke with known values.""" u, v, w, e_true = uvw_and_known_tke assert_array_equal(e_true, tke(u, v, w)) def test_known_tke_2d_axis_last(uvw_and_known_tke): """Test array with shape (3, 5) [pretend time axis is -1].""" u, v, w, e_true = uvw_and_known_tke u = np.array([u, u, u]) v = np.array([v, v, v]) w = np.array([w, w, w]) e_true = e_true * np.ones(3) assert_array_equal(e_true, tke(u, v, w, axis=-1)) def test_known_tke_2d_axis_first(uvw_and_known_tke): """Test array with shape (5, 3) [pretend time axis is 0].""" u, v, w, e_true = uvw_and_known_tke u = np.array([u, u, u]).transpose() v = np.array([v, v, v]).transpose() w = np.array([w, w, w]).transpose() e_true = e_true * np.ones(3).transpose() assert_array_equal(e_true, tke(u, v, w, axis=0)) assert_array_equal(e_true, tke(u, v, w, axis=0, perturbation=True)) # # Perturbation tests # @pytest.fixture() def pert_zero_mean(): """Return time series with zero-mean and perturbations.""" ts = np.array([-2, -1, 0, 1, 2]) pert_true = ts.copy() return ts, pert_true @pytest.fixture() def pert_nonzero_mean(): """Return time seres with non-zero-mean and perturbations.""" ts = np.array([-2, 0, 2, 4, 6]) # ts.mean() = 2 pert_true = np.array([-4, -2, 0, 2, 4]) return ts, pert_true def test_no_perturbation_1d(): """Test with uniform data in 1D.""" observations = 5 # given all the values are the same, there should not be perturbations ts = np.ones(observations) pert_zero = 0 assert_array_equal(pert_zero, get_perturbation(ts)) def test_no_perturbation_2d_axis_last(): """Test with uniform data in 2D along the last axis.""" observations = 5 instruments = 2 # given all the values are the same, there should not be perturbations ts = np.ones((instruments, observations)) pert_zero = np.zeros((instruments, observations)) assert_array_equal(pert_zero, get_perturbation(ts, axis=-1)) def test_no_perturbation_2d_axis_first(): """Test with uniform data in 2D along the first axis.""" observations = 5 instruments = 2 # given all the values are the same, there should not be perturbations ts = np.ones((observations, instruments)) pert_zero = np.zeros((observations, instruments)) assert_array_equal(pert_zero, get_perturbation(ts, axis=0)) def test_known_perturbation_zero_mean_1d(pert_zero_mean): """Test with zero-mean data in 1D.""" ts, pert_known = pert_zero_mean assert_array_equal(pert_known, get_perturbation(ts)) def test_known_perturbation_zero_mean_2d_axis_last(pert_zero_mean): """Test with zero-mean data in 2D along the last axis.""" ts, pert_known = pert_zero_mean ts = np.array([ts, ts, ts]) pert_known = np.array([pert_known, pert_known, pert_known]) assert_array_equal(pert_known, get_perturbation(ts, axis=-1)) def test_known_perturbation_zero_mean_2d_axis_first(pert_zero_mean): """Test with zero-mean data in 2D along the first axis.""" ts, pert_known = pert_zero_mean ts = np.array([ts, ts, ts]).transpose() pert_known = np.array([pert_known, pert_known, pert_known]).transpose() assert_array_equal(pert_known, get_perturbation(ts, axis=0)) def test_known_perturbation_nonzero_mean_1d(pert_nonzero_mean): """Test with non-zero-mean data in 1D.""" ts, pert_known = pert_nonzero_mean assert_array_equal(pert_known, get_perturbation(ts)) def test_known_perturbation_nonzero_mean_2d_axis_last(pert_nonzero_mean): """Test with non-zero-mean data in 2D along the last axis.""" ts, pert_known = pert_nonzero_mean ts = np.array([ts, ts, ts]) pert_known = np.array([pert_known, pert_known, pert_known]) assert_array_equal(pert_known, get_perturbation(ts, axis=-1)) def test_known_perturbation_nonzero_mean_2d_axis_first(pert_nonzero_mean): """Test with non-zero-mean data in 2D along the first axis.""" ts, pert_known = pert_nonzero_mean ts = np.array([ts, ts, ts]).transpose() pert_known = np.array([pert_known, pert_known, pert_known]).transpose() assert_array_equal(pert_known, get_perturbation(ts, axis=0)) # # Kinematic Flux Tests # @pytest.fixture() def uvw_and_known_kf_zero_mean(): """Return components and kinematic flux for zero-mean time series.""" u = np.array([-2, -1, 0, 1, 2]) v = -u w = 2 * u kf_true = {'uv': -2, 'uw': 4, 'vw': -4} return u, v, w, kf_true @pytest.fixture() def uvw_and_known_kf_nonzero_mean(): """Return components and kinematic flux for non-zero-mean time series.""" u = np.array([-2, -1, 0, 1, 5]) v = -u w = 2 * u kf_true = {'uv': -5.84, 'uw': 11.68, 'vw': -11.68} return u, v, w, kf_true def test_kf_1d_zero_mean(uvw_and_known_kf_zero_mean): """Test kinematic flux calculation in 1D with zero-mean time series.""" u, v, w, kf_true = uvw_and_known_kf_zero_mean assert_array_equal(kinematic_flux(u, v, perturbation=False), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False), kf_true['vw']) # given u, v, and w have a zero mean, the kf computed with # perturbation=True and perturbation=False should be the same assert_array_equal(kinematic_flux(u, v, perturbation=False), kinematic_flux(u, v, perturbation=True)) assert_array_equal(kinematic_flux(u, w, perturbation=False), kinematic_flux(u, w, perturbation=True)) assert_array_equal(kinematic_flux(v, w, perturbation=False), kinematic_flux(v, w, perturbation=True)) def test_kf_1d_nonzero_mean(uvw_and_known_kf_nonzero_mean): """Test kinematic flux calculation in 1D with non-zero-mean time series.""" u, v, w, kf_true = uvw_and_known_kf_nonzero_mean assert_array_equal(kinematic_flux(u, v, perturbation=False), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False), kf_true['vw']) def test_kf_2d_axis_last_zero_mean(uvw_and_known_kf_zero_mean): """Test kinematic flux calculation in 2D with zero-mean time series along last axis.""" u, v, w, kf_true = uvw_and_known_kf_zero_mean u = np.array([u, u, u]) v = np.array([v, v, v]) w = np.array([w, w, w]) assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1), kf_true['vw']) # given u, v, and w have a zero mean, the kf computed with # perturbation=True and perturbation=False should be the same assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1), kinematic_flux(u, v, perturbation=True, axis=-1)) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1), kinematic_flux(u, w, perturbation=True, axis=-1)) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1), kinematic_flux(v, w, perturbation=True, axis=-1)) def test_kf_2d_axis_last_nonzero_mean(uvw_and_known_kf_nonzero_mean): """Test kinematic flux calculation in 2D with non-zero-mean time series along last axis.""" u, v, w, kf_true = uvw_and_known_kf_nonzero_mean u = np.array([u, u, u]) v = np.array([v, v, v]) w = np.array([w, w, w]) assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=-1), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=-1), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=-1), kf_true['vw']) def test_kf_2d_axis_first_zero_mean(uvw_and_known_kf_zero_mean): """Test kinematic flux calculation in 2D with zero-mean time series along first axis.""" u, v, w, kf_true = uvw_and_known_kf_zero_mean u = np.array([u, u, u]).transpose() v = np.array([v, v, v]).transpose() w = np.array([w, w, w]).transpose() assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0), kf_true['vw']) # given u, v, and w have a zero mean, the kf computed with # perturbation=True and perturbation=False should be the same assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0), kinematic_flux(u, v, perturbation=True, axis=0)) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0), kinematic_flux(u, w, perturbation=True, axis=0)) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0), kinematic_flux(v, w, perturbation=True, axis=0)) def test_kf_2d_axis_first_nonzero_mean(uvw_and_known_kf_nonzero_mean): """Test kinematic flux in 2D with non-zero-mean time series along first axis.""" u, v, w, kf_true = uvw_and_known_kf_nonzero_mean u = np.array([u, u, u]).transpose() v = np.array([v, v, v]).transpose() w = np.array([w, w, w]).transpose() assert_array_equal(kinematic_flux(u, v, perturbation=False, axis=0), kf_true['uv']) assert_array_equal(kinematic_flux(u, w, perturbation=False, axis=0), kf_true['uw']) assert_array_equal(kinematic_flux(v, w, perturbation=False, axis=0), kf_true['vw']) # # Friction Velocity Tests # @pytest.fixture() def uvw_and_known_u_star_zero_mean(): """Return components and friction velocity for a zero-mean time series.""" u = np.array([-2, -1, 0, 1, 2]) v = -u w = 2 * u u_star_true = {'uw': 2.0, 'uwvw': 2.3784142300054421} return u, v, w, u_star_true @pytest.fixture() def uvw_and_known_u_star_nonzero_mean(): """Return components and friction velocity for a non-zero-mean time series.""" u = np.array([-2, -1, 0, 1, 5]) v = -u w = 2 * u u_star_true = {'uw': 3.4176014981270124, 'uwvw': 4.0642360178166017} return u, v, w, u_star_true def test_u_star_1d_zero_mean(uvw_and_known_u_star_zero_mean): """Test friction velocity in 1D with a zero-mean time series.""" u, v, w, u_star_true = uvw_and_known_u_star_zero_mean assert_almost_equal(friction_velocity(u, w, perturbation=False), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False), u_star_true['uwvw']) def test_u_star_1d_nonzero_mean(uvw_and_known_u_star_nonzero_mean): """Test friction velocity in 1D with a non-zero-mean time series.""" u, v, w, u_star_true = uvw_and_known_u_star_nonzero_mean assert_almost_equal(friction_velocity(u, w, perturbation=False), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False), u_star_true['uwvw']) def test_u_star_2d_axis_last_zero_mean(uvw_and_known_u_star_zero_mean): """Test friction velocity in 2D with a zero-mean time series along the last axis.""" u, v, w, u_star_true = uvw_and_known_u_star_zero_mean u = np.array([u, u, u]) v = np.array([v, v, v]) w = np.array([w, w, w]) assert_almost_equal(friction_velocity(u, w, perturbation=False, axis=-1), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False, axis=-1), u_star_true['uwvw']) def test_u_star_2d_axis_last_nonzero_mean(uvw_and_known_u_star_nonzero_mean): """Test friction velocity in 2D with a non-zero-mean time series along the last axis.""" u, v, w, u_star_true = uvw_and_known_u_star_nonzero_mean u = np.array([u, u, u]) v = np.array([v, v, v]) w = np.array([w, w, w]) assert_almost_equal(friction_velocity(u, w, perturbation=False, axis=-1), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False, axis=-1), u_star_true['uwvw']) def test_u_star_2d_axis_first_zero_mean(uvw_and_known_u_star_zero_mean): """Test friction velocity in 2D with a zero-mean time series along the first axis.""" u, v, w, u_star_true = uvw_and_known_u_star_zero_mean u = np.array([u, u, u]).transpose() v = np.array([v, v, v]).transpose() w = np.array([w, w, w]).transpose() assert_almost_equal(friction_velocity(u, w, perturbation=False, axis=0), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False, axis=0), u_star_true['uwvw']) def test_u_star_2d_axis_first_nonzero_mean(uvw_and_known_u_star_nonzero_mean): """Test friction velocity in 2D with a non-zero-mean time series along the first axis.""" u, v, w, u_star_true = uvw_and_known_u_star_nonzero_mean u = np.array([u, u, u]).transpose() v = np.array([v, v, v]).transpose() w = np.array([w, w, w]).transpose() assert_almost_equal(friction_velocity(u, w, perturbation=False, axis=0), u_star_true['uw']) assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False, axis=0), u_star_true['uwvw'])
bsd-3-clause
[ 3, 1898, 334, 67, 9, 9079, 12, 7806, 10072, 2713, 23493, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 6289, 650, 13, 16009, 844, 14, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 6289, 13, 19, 13, 16009, 199, 624, 774, 314, 658, 28081, 443, 21225, 64, 859, 1041, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 4398, 63, 1452, 12, 702, 63, 1144, 63, 1452, 199, 646, 4613, 199, 199, 504, 7647, 647, 14, 8104, 14, 28081, 443, 21225, 492, 289, 322, 414, 63, 16350, 12, 664, 63, 529, 28081, 425, 12, 1022, 1132, 3889, 63, 14477, 12, 307, 415, 421, 199, 3, 199, 3, 377, 2430, 6496, 199, 3, 199, 32, 4462, 14, 5997, 342, 199, 318, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 837, 272, 408, 25107, 282, 663, 402, 399, 12, 86, 12, 87, 543, 282, 6040, 307, 415, 574, 1041, 272, 399, 275, 980, 14, 1144, 11468, 18, 12, 446, 17, 12, 378, 12, 413, 12, 499, 566, 272, 373, 275, 446, 85, 272, 336, 275, 499, 627, 399, 272, 327, 221, 378, 14, 21, 627, 7452, 8, 18, 435, 499, 435, 1695, 9, 272, 325, 63, 2052, 275, 980, 14, 5079, 8, 713, 9, 1182, 499, 14, 272, 372, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 17, 68, 837, 272, 408, 774, 307, 415, 15232, 2382, 314, 1420, 574, 365, 378, 1041, 272, 19739, 275, 959, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 373, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 336, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 325, 63, 4262, 275, 378, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 430, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2019, 837, 272, 408, 774, 378, 307, 415, 15232, 543, 499, 36, 6572, 27, 15232, 3114, 365, 2061, 1041, 272, 19739, 275, 959, 272, 14498, 83, 275, 499, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 373, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 336, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 325, 63, 4262, 275, 980, 14, 4250, 8, 13321, 83, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 4022, 17, 430, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2246, 837, 272, 408, 774, 378, 307, 415, 15232, 543, 499, 36, 6572, 27, 15232, 3114, 365, 1642, 1041, 272, 19739, 275, 959, 272, 14498, 83, 275, 499, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 373, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 336, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 325, 63, 4262, 275, 980, 14, 4250, 8, 13321, 83, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 5678, 5953, 402, 307, 415, 543, 6040, 1338, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2019, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 1625, 543, 2215, 334, 19, 12, 959, 9, 359, 657, 7169, 900, 3114, 365, 446, 17, 61, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 399, 275, 980, 14, 1144, 779, 85, 12, 399, 12, 399, 566, 272, 373, 275, 980, 14, 1144, 779, 86, 12, 373, 12, 373, 566, 272, 336, 275, 980, 14, 1144, 779, 87, 12, 336, 12, 336, 566, 272, 325, 63, 2052, 275, 325, 63, 2052, 627, 980, 14, 4548, 8, 19, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 4022, 17, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2246, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 1625, 543, 2215, 334, 21, 12, 650, 9, 359, 657, 7169, 900, 3114, 365, 378, 61, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 399, 275, 980, 14, 1144, 779, 85, 12, 399, 12, 399, 6575, 10483, 342, 272, 373, 275, 980, 14, 1144, 779, 86, 12, 373, 12, 373, 6575, 10483, 342, 272, 336, 275, 980, 14, 1144, 779, 87, 12, 336, 12, 336, 6575, 10483, 342, 272, 325, 63, 2052, 275, 325, 63, 2052, 627, 980, 14, 4548, 8, 19, 680, 10483, 342, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 430, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 12, 1126, 28081, 425, 29, 549, 430, 421, 199, 3, 199, 3, 3492, 28081, 425, 2295, 199, 3, 199, 32, 4462, 14, 5997, 342, 199, 318, 1126, 84, 63, 4262, 63, 3670, 837, 272, 408, 1767 ]
[ 1898, 334, 67, 9, 9079, 12, 7806, 10072, 2713, 23493, 14, 199, 3, 17484, 1334, 314, 2895, 402, 314, 6289, 650, 13, 16009, 844, 14, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 6289, 13, 19, 13, 16009, 199, 624, 774, 314, 658, 28081, 443, 21225, 64, 859, 1041, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 4398, 63, 1452, 12, 702, 63, 1144, 63, 1452, 199, 646, 4613, 199, 199, 504, 7647, 647, 14, 8104, 14, 28081, 443, 21225, 492, 289, 322, 414, 63, 16350, 12, 664, 63, 529, 28081, 425, 12, 1022, 1132, 3889, 63, 14477, 12, 307, 415, 421, 199, 3, 199, 3, 377, 2430, 6496, 199, 3, 199, 32, 4462, 14, 5997, 342, 199, 318, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 837, 272, 408, 25107, 282, 663, 402, 399, 12, 86, 12, 87, 543, 282, 6040, 307, 415, 574, 1041, 272, 399, 275, 980, 14, 1144, 11468, 18, 12, 446, 17, 12, 378, 12, 413, 12, 499, 566, 272, 373, 275, 446, 85, 272, 336, 275, 499, 627, 399, 272, 327, 221, 378, 14, 21, 627, 7452, 8, 18, 435, 499, 435, 1695, 9, 272, 325, 63, 2052, 275, 980, 14, 5079, 8, 713, 9, 1182, 499, 14, 272, 372, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 17, 68, 837, 272, 408, 774, 307, 415, 15232, 2382, 314, 1420, 574, 365, 378, 1041, 272, 19739, 275, 959, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 373, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 336, 275, 980, 14, 4548, 8, 2873, 12225, 9, 272, 325, 63, 4262, 275, 378, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 430, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2019, 837, 272, 408, 774, 378, 307, 415, 15232, 543, 499, 36, 6572, 27, 15232, 3114, 365, 2061, 1041, 272, 19739, 275, 959, 272, 14498, 83, 275, 499, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 373, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 336, 275, 980, 14, 4548, 1332, 13321, 83, 12, 19739, 430, 272, 325, 63, 4262, 275, 980, 14, 4250, 8, 13321, 83, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 4022, 17, 430, 421, 199, 318, 511, 63, 889, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2246, 837, 272, 408, 774, 378, 307, 415, 15232, 543, 499, 36, 6572, 27, 15232, 3114, 365, 1642, 1041, 272, 19739, 275, 959, 272, 14498, 83, 275, 499, 272, 327, 1627, 1006, 314, 1338, 787, 314, 2011, 12, 2337, 1077, 440, 506, 1263, 307, 415, 272, 399, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 373, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 336, 275, 980, 14, 4548, 1332, 2873, 12225, 12, 14498, 83, 430, 272, 325, 63, 4262, 275, 980, 14, 4250, 8, 13321, 83, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 4262, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 5678, 5953, 402, 307, 415, 543, 6040, 1338, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2019, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 1625, 543, 2215, 334, 19, 12, 959, 9, 359, 657, 7169, 900, 3114, 365, 446, 17, 61, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 399, 275, 980, 14, 1144, 779, 85, 12, 399, 12, 399, 566, 272, 373, 275, 980, 14, 1144, 779, 86, 12, 373, 12, 373, 566, 272, 336, 275, 980, 14, 1144, 779, 87, 12, 336, 12, 336, 566, 272, 325, 63, 2052, 275, 325, 63, 2052, 627, 980, 14, 4548, 8, 19, 9, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 4022, 17, 430, 421, 199, 318, 511, 63, 3159, 63, 84, 415, 63, 18, 68, 63, 3127, 63, 2246, 8, 9154, 87, 63, 460, 63, 3159, 63, 84, 415, 304, 272, 408, 774, 1625, 543, 2215, 334, 21, 12, 650, 9, 359, 657, 7169, 900, 3114, 365, 378, 61, 1041, 272, 399, 12, 373, 12, 336, 12, 325, 63, 2052, 275, 399, 19665, 63, 460, 63, 3159, 63, 84, 415, 272, 399, 275, 980, 14, 1144, 779, 85, 12, 399, 12, 399, 6575, 10483, 342, 272, 373, 275, 980, 14, 1144, 779, 86, 12, 373, 12, 373, 6575, 10483, 342, 272, 336, 275, 980, 14, 1144, 779, 87, 12, 336, 12, 336, 6575, 10483, 342, 272, 325, 63, 2052, 275, 325, 63, 2052, 627, 980, 14, 4548, 8, 19, 680, 10483, 342, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 430, 272, 702, 63, 1144, 63, 1452, 8, 69, 63, 2052, 12, 307, 415, 8, 85, 12, 373, 12, 336, 12, 3114, 29, 16, 12, 1126, 28081, 425, 29, 549, 430, 421, 199, 3, 199, 3, 3492, 28081, 425, 2295, 199, 3, 199, 32, 4462, 14, 5997, 342, 199, 318, 1126, 84, 63, 4262, 63, 3670, 837, 272, 408, 1767, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rahulbhalerao001/SparkNet
caffe/python/caffe/net_spec.py
8
7876
"""Python net specification. This module provides a way to write nets directly in Python, using a natural, functional style. See examples/pycaffe/caffenet.py for an example. Currently this works as a thin wrapper around the Python protobuf interface, with layers and parameters automatically generated for the "layers" and "params" pseudo-modules, which are actually objects using __getattr__ magic to generate protobuf messages. Note that when using to_proto or Top.to_proto, names of intermediate blobs will be automatically generated. To explicitly specify blob names, use the NetSpec class -- assign to its attributes directly to name layers, and call NetSpec.to_proto to serialize all assigned layers. This interface is expected to continue to evolve as Caffe gains new capabilities for specifying nets. In particular, the automatically generated layer names are not guaranteed to be forward-compatible. """ from collections import OrderedDict, Counter from .proto import caffe_pb2 from google import protobuf import six def param_name_dict(): """Find out the correspondence between layer names and parameter names.""" layer = caffe_pb2.LayerParameter() # get all parameter names (typically underscore case) and corresponding # type names (typically camel case), which contain the layer names # (note that not all parameters correspond to layers, but we'll ignore that) param_names = [s for s in dir(layer) if s.endswith('_param')] param_type_names = [type(getattr(layer, s)).__name__ for s in param_names] # strip the final '_param' or 'Parameter' param_names = [s[:-len('_param')] for s in param_names] param_type_names = [s[:-len('Parameter')] for s in param_type_names] return dict(zip(param_type_names, param_names)) def to_proto(*tops): """Generate a NetParameter that contains all layers needed to compute all arguments.""" layers = OrderedDict() autonames = Counter() for top in tops: top.fn._to_proto(layers, {}, autonames) net = caffe_pb2.NetParameter() net.layer.extend(layers.values()) return net def assign_proto(proto, name, val): """Assign a Python object to a protobuf message, based on the Python type (in recursive fashion). Lists become repeated fields/messages, dicts become messages, and other types are assigned directly. For convenience, repeated fields whose values are not lists are converted to single-element lists; e.g., `my_repeated_int_field=3` is converted to `my_repeated_int_field=[3]`.""" is_repeated_field = hasattr(getattr(proto, name), 'extend') if is_repeated_field and not isinstance(val, list): val = [val] if isinstance(val, list): if isinstance(val[0], dict): for item in val: proto_item = getattr(proto, name).add() for k, v in six.iteritems(item): assign_proto(proto_item, k, v) else: getattr(proto, name).extend(val) elif isinstance(val, dict): for k, v in six.iteritems(val): assign_proto(getattr(proto, name), k, v) else: setattr(proto, name, val) class Top(object): """A Top specifies a single output blob (which could be one of several produced by a layer.)""" def __init__(self, fn, n): self.fn = fn self.n = n def to_proto(self): """Generate a NetParameter that contains all layers needed to compute this top.""" return to_proto(self) def _to_proto(self, layers, names, autonames): return self.fn._to_proto(layers, names, autonames) class Function(object): """A Function specifies a layer, its parameters, and its inputs (which are Tops from other layers).""" def __init__(self, type_name, inputs, params): self.type_name = type_name self.inputs = inputs self.params = params self.ntop = self.params.get('ntop', 1) # use del to make sure kwargs are not double-processed as layer params if 'ntop' in self.params: del self.params['ntop'] self.in_place = self.params.get('in_place', False) if 'in_place' in self.params: del self.params['in_place'] self.tops = tuple(Top(self, n) for n in range(self.ntop)) def _get_name(self, names, autonames): if self not in names and self.ntop > 0: names[self] = self._get_top_name(self.tops[0], names, autonames) elif self not in names: autonames[self.type_name] += 1 names[self] = self.type_name + str(autonames[self.type_name]) return names[self] def _get_top_name(self, top, names, autonames): if top not in names: autonames[top.fn.type_name] += 1 names[top] = top.fn.type_name + str(autonames[top.fn.type_name]) return names[top] def _to_proto(self, layers, names, autonames): if self in layers: return bottom_names = [] for inp in self.inputs: inp._to_proto(layers, names, autonames) bottom_names.append(layers[inp.fn].top[inp.n]) layer = caffe_pb2.LayerParameter() layer.type = self.type_name layer.bottom.extend(bottom_names) if self.in_place: layer.top.extend(layer.bottom) else: for top in self.tops: layer.top.append(self._get_top_name(top, names, autonames)) layer.name = self._get_name(names, autonames) for k, v in six.iteritems(self.params): # special case to handle generic *params if k.endswith('param'): assign_proto(layer, k, v) else: try: assign_proto(getattr(layer, _param_names[self.type_name] + '_param'), k, v) except (AttributeError, KeyError): assign_proto(layer, k, v) layers[self] = layer class NetSpec(object): """A NetSpec contains a set of Tops (assigned directly as attributes). Calling NetSpec.to_proto generates a NetParameter containing all of the layers needed to produce all of the assigned Tops, using the assigned names.""" def __init__(self): super(NetSpec, self).__setattr__('tops', OrderedDict()) def __setattr__(self, name, value): self.tops[name] = value def __getattr__(self, name): return self.tops[name] def to_proto(self): names = {v: k for k, v in six.iteritems(self.tops)} autonames = Counter() layers = OrderedDict() for name, top in six.iteritems(self.tops): top._to_proto(layers, names, autonames) net = caffe_pb2.NetParameter() net.layer.extend(layers.values()) return net class Layers(object): """A Layers object is a pseudo-module which generates functions that specify layers; e.g., Layers().Convolution(bottom, kernel_size=3) will produce a Top specifying a 3x3 convolution applied to bottom.""" def __getattr__(self, name): def layer_fn(*args, **kwargs): fn = Function(name, args, kwargs) if fn.ntop == 0: return fn elif fn.ntop == 1: return fn.tops[0] else: return fn.tops return layer_fn class Parameters(object): """A Parameters object is a pseudo-module which generates constants used in layer parameters; e.g., Parameters().Pooling.MAX is the value used to specify max pooling.""" def __getattr__(self, name): class Param: def __getattr__(self, param_name): return getattr(getattr(caffe_pb2, name + 'Parameter'), param_name) return Param() _param_names = param_name_dict() layers = Layers() params = Parameters()
mit
[ 624, 4718, 1851, 8929, 14, 199, 199, 2765, 859, 6571, 282, 4340, 370, 2218, 1851, 83, 5370, 315, 2018, 12, 1808, 282, 19981, 12, 199, 15481, 3449, 14, 1666, 7251, 15, 647, 18260, 15, 696, 556, 287, 386, 14, 647, 367, 376, 2893, 14, 199, 199, 31499, 642, 5419, 465, 282, 30758, 4975, 6818, 314, 2018, 25886, 3217, 12, 199, 1045, 9393, 436, 2633, 5847, 4046, 367, 314, 298, 4359, 2, 436, 199, 2, 1162, 2, 15984, 13, 3112, 12, 1314, 787, 5965, 2251, 1808, 636, 5675, 363, 10628, 199, 475, 3550, 25886, 3788, 14, 199, 199, 7443, 626, 1380, 1808, 370, 63, 2625, 503, 14132, 14, 475, 63, 2625, 12, 1561, 402, 13197, 9182, 83, 911, 199, 1235, 5847, 4046, 14, 4005, 7662, 4165, 9182, 1561, 12, 675, 314, 5365, 5307, 199, 533, 1553, 5090, 370, 2399, 3004, 5370, 370, 536, 9393, 12, 436, 1240, 199, 2480, 5307, 14, 475, 63, 2625, 370, 8437, 1006, 7943, 9393, 14, 199, 199, 2765, 3217, 365, 1420, 370, 1980, 370, 8145, 3344, 465, 8790, 2026, 15334, 83, 892, 14918, 199, 509, 9176, 1851, 83, 14, 1010, 6770, 12, 314, 5847, 4046, 4045, 1561, 199, 1530, 440, 17334, 370, 506, 7568, 13, 6490, 14, 199, 624, 199, 199, 504, 5055, 492, 8773, 12, 14427, 199, 199, 504, 1275, 2625, 492, 1704, 2026, 63, 3317, 18, 199, 504, 6233, 492, 25886, 199, 646, 3816, 421, 199, 318, 1215, 63, 354, 63, 807, 837, 272, 408, 6591, 734, 314, 4327, 5606, 3382, 4045, 1561, 436, 2725, 1561, 1041, 339, 4045, 275, 1704, 2026, 63, 3317, 18, 14, 5003, 4720, 342, 272, 327, 664, 1006, 2725, 1561, 334, 32251, 18888, 1930, 9, 436, 5226, 272, 327, 730, 1561, 334, 32251, 31129, 1930, 395, 1314, 1395, 314, 4045, 1561, 272, 327, 334, 4610, 626, 440, 1006, 2633, 17118, 370, 9393, 12, 1325, 781, 7171, 3686, 626, 9, 272, 1215, 63, 1247, 275, 359, 83, 367, 308, 315, 2935, 8, 1897, 9, 340, 308, 14, 4130, 6412, 635, 5440, 272, 1215, 63, 466, 63, 1247, 275, 359, 466, 8, 5675, 8, 1897, 12, 308, 430, 855, 354, 363, 367, 308, 315, 1215, 63, 1247, 61, 272, 327, 6202, 314, 4242, 2513, 635, 7, 503, 283, 4720, 7, 272, 1215, 63, 1247, 275, 359, 83, 4439, 552, 6412, 635, 5440, 367, 308, 315, 1215, 63, 1247, 61, 272, 1215, 63, 466, 63, 1247, 275, 359, 83, 4439, 552, 360, 4720, 5440, 367, 308, 315, 1215, 63, 466, 63, 1247, 61, 272, 372, 1211, 8, 3065, 8, 635, 63, 466, 63, 1247, 12, 1215, 63, 1247, 430, 421, 199, 318, 370, 63, 2625, 2031, 84, 1483, 304, 272, 408, 6864, 282, 5365, 4720, 626, 3509, 1006, 9393, 4346, 370, 4526, 272, 1006, 2368, 1041, 339, 9393, 275, 8773, 342, 272, 6384, 265, 14015, 275, 14427, 342, 272, 367, 2746, 315, 370, 1190, 26, 267, 2746, 14, 2324, 423, 475, 63, 2625, 8, 4359, 12, 5479, 6384, 265, 14015, 9, 272, 1851, 275, 1704, 2026, 63, 3317, 18, 14, 2480, 4720, 342, 272, 1851, 14, 1897, 14, 2880, 8, 4359, 14, 1459, 1012, 272, 372, 1851, 421, 199, 318, 5090, 63, 2625, 8, 2625, 12, 536, 12, 1139, 304, 272, 408, 9595, 282, 2018, 909, 370, 282, 25886, 1245, 12, 4079, 641, 314, 2018, 272, 730, 334, 262, 9133, 32285, 680, 31289, 8649, 10877, 1504, 15, 3431, 12, 10809, 272, 8649, 3788, 12, 436, 1163, 2943, 787, 7943, 5370, 14, 2104, 16777, 12, 272, 10877, 1504, 7447, 1338, 787, 440, 5548, 787, 6702, 370, 2849, 13, 2108, 272, 5548, 27, 325, 14, 71, 2020, 658, 1662, 63, 7593, 63, 442, 63, 698, 29, 19, 64, 365, 6702, 370, 272, 658, 1662, 63, 7593, 63, 442, 63, 698, 1524, 19, 16090, 1041, 339, 365, 63, 7593, 63, 698, 275, 2688, 8, 5675, 8, 2625, 12, 536, 395, 283, 2880, 358, 272, 340, 365, 63, 7593, 63, 698, 436, 440, 1228, 8, 637, 12, 769, 304, 267, 1139, 275, 359, 637, 61, 272, 340, 1228, 8, 637, 12, 769, 304, 267, 340, 1228, 8, 637, 59, 16, 467, 1211, 304, 288, 367, 1242, 315, 1139, 26, 355, 4104, 63, 1053, 275, 2519, 8, 2625, 12, 536, 680, 525, 342, 355, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 1053, 304, 490, 5090, 63, 2625, 8, 2625, 63, 1053, 12, 1022, 12, 373, 9, 267, 587, 26, 288, 2519, 8, 2625, 12, 536, 680, 2880, 8, 637, 9, 272, 916, 1228, 8, 637, 12, 1211, 304, 267, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 637, 304, 288, 5090, 63, 2625, 8, 5675, 8, 2625, 12, 536, 395, 1022, 12, 373, 9, 272, 587, 26, 267, 5371, 8, 2625, 12, 536, 12, 1139, 9, 421, 199, 533, 14132, 8, 785, 304, 272, 408, 33, 14132, 9314, 282, 2849, 1072, 9182, 334, 6777, 4293, 506, 1373, 402, 9978, 272, 13584, 701, 282, 4045, 4959, 624, 339, 347, 636, 826, 721, 277, 12, 4325, 12, 302, 304, 267, 291, 14, 2324, 275, 4325, 267, 291, 14, 78, 275, 302, 339, 347, 370, 63, 2625, 8, 277, 304, 267, 408, 6864, 282, 5365, 4720, 626, 3509, 1006, 9393, 4346, 370, 4526, 267, 642, 2746, 1041, 398, 372, 370, 63, 2625, 8, 277, 9, 339, 347, 485, 475, 63, 2625, 8, 277, 12, 9393, 12, 1561, 12, 6384, 265, 14015, 304, 267, 372, 291, 14, 2324, 423, 475, 63, 2625, 8, 4359, 12, 1561, 12, 6384, 265, 14015, 9, 421, 199, 533, 6801, 8, 785, 304, 272, 408, 33, 6801, 9314, 282, 4045, 12, 2399, 2633, 12, 436, 2399, 4153, 334, 6777, 272, 787, 377, 1483, 687, 1163, 9393, 10477, 339, 347, 636, 826, 721, 277, 12, 730, 63, 354, 12, 4153, 12, 1862, 304, 267, 291, 14, 466, 63, 354, 275, 730, 63, 354, 267, 291, 14, 3711, 275, 4153, 267, 291, 14, 1162, 275, 1862, 267, 291, 14, 343, 411, 275, 291, 14, 1162, 14, 362, 360, 343, 411, 297, 413, 9, 267, 327, 675, 2150, 370, 1852, 3238, 2074, 787, 440, 4270, 13, 7292, 465, 4045, 1862, 267, 340, 283, 343, 411, 7, 315, 291, 14, 1162, 26, 288, 2150, 291, 14, 1162, 459, 343, 411, 418 ]
[ 4718, 1851, 8929, 14, 199, 199, 2765, 859, 6571, 282, 4340, 370, 2218, 1851, 83, 5370, 315, 2018, 12, 1808, 282, 19981, 12, 199, 15481, 3449, 14, 1666, 7251, 15, 647, 18260, 15, 696, 556, 287, 386, 14, 647, 367, 376, 2893, 14, 199, 199, 31499, 642, 5419, 465, 282, 30758, 4975, 6818, 314, 2018, 25886, 3217, 12, 199, 1045, 9393, 436, 2633, 5847, 4046, 367, 314, 298, 4359, 2, 436, 199, 2, 1162, 2, 15984, 13, 3112, 12, 1314, 787, 5965, 2251, 1808, 636, 5675, 363, 10628, 199, 475, 3550, 25886, 3788, 14, 199, 199, 7443, 626, 1380, 1808, 370, 63, 2625, 503, 14132, 14, 475, 63, 2625, 12, 1561, 402, 13197, 9182, 83, 911, 199, 1235, 5847, 4046, 14, 4005, 7662, 4165, 9182, 1561, 12, 675, 314, 5365, 5307, 199, 533, 1553, 5090, 370, 2399, 3004, 5370, 370, 536, 9393, 12, 436, 1240, 199, 2480, 5307, 14, 475, 63, 2625, 370, 8437, 1006, 7943, 9393, 14, 199, 199, 2765, 3217, 365, 1420, 370, 1980, 370, 8145, 3344, 465, 8790, 2026, 15334, 83, 892, 14918, 199, 509, 9176, 1851, 83, 14, 1010, 6770, 12, 314, 5847, 4046, 4045, 1561, 199, 1530, 440, 17334, 370, 506, 7568, 13, 6490, 14, 199, 624, 199, 199, 504, 5055, 492, 8773, 12, 14427, 199, 199, 504, 1275, 2625, 492, 1704, 2026, 63, 3317, 18, 199, 504, 6233, 492, 25886, 199, 646, 3816, 421, 199, 318, 1215, 63, 354, 63, 807, 837, 272, 408, 6591, 734, 314, 4327, 5606, 3382, 4045, 1561, 436, 2725, 1561, 1041, 339, 4045, 275, 1704, 2026, 63, 3317, 18, 14, 5003, 4720, 342, 272, 327, 664, 1006, 2725, 1561, 334, 32251, 18888, 1930, 9, 436, 5226, 272, 327, 730, 1561, 334, 32251, 31129, 1930, 395, 1314, 1395, 314, 4045, 1561, 272, 327, 334, 4610, 626, 440, 1006, 2633, 17118, 370, 9393, 12, 1325, 781, 7171, 3686, 626, 9, 272, 1215, 63, 1247, 275, 359, 83, 367, 308, 315, 2935, 8, 1897, 9, 340, 308, 14, 4130, 6412, 635, 5440, 272, 1215, 63, 466, 63, 1247, 275, 359, 466, 8, 5675, 8, 1897, 12, 308, 430, 855, 354, 363, 367, 308, 315, 1215, 63, 1247, 61, 272, 327, 6202, 314, 4242, 2513, 635, 7, 503, 283, 4720, 7, 272, 1215, 63, 1247, 275, 359, 83, 4439, 552, 6412, 635, 5440, 367, 308, 315, 1215, 63, 1247, 61, 272, 1215, 63, 466, 63, 1247, 275, 359, 83, 4439, 552, 360, 4720, 5440, 367, 308, 315, 1215, 63, 466, 63, 1247, 61, 272, 372, 1211, 8, 3065, 8, 635, 63, 466, 63, 1247, 12, 1215, 63, 1247, 430, 421, 199, 318, 370, 63, 2625, 2031, 84, 1483, 304, 272, 408, 6864, 282, 5365, 4720, 626, 3509, 1006, 9393, 4346, 370, 4526, 272, 1006, 2368, 1041, 339, 9393, 275, 8773, 342, 272, 6384, 265, 14015, 275, 14427, 342, 272, 367, 2746, 315, 370, 1190, 26, 267, 2746, 14, 2324, 423, 475, 63, 2625, 8, 4359, 12, 5479, 6384, 265, 14015, 9, 272, 1851, 275, 1704, 2026, 63, 3317, 18, 14, 2480, 4720, 342, 272, 1851, 14, 1897, 14, 2880, 8, 4359, 14, 1459, 1012, 272, 372, 1851, 421, 199, 318, 5090, 63, 2625, 8, 2625, 12, 536, 12, 1139, 304, 272, 408, 9595, 282, 2018, 909, 370, 282, 25886, 1245, 12, 4079, 641, 314, 2018, 272, 730, 334, 262, 9133, 32285, 680, 31289, 8649, 10877, 1504, 15, 3431, 12, 10809, 272, 8649, 3788, 12, 436, 1163, 2943, 787, 7943, 5370, 14, 2104, 16777, 12, 272, 10877, 1504, 7447, 1338, 787, 440, 5548, 787, 6702, 370, 2849, 13, 2108, 272, 5548, 27, 325, 14, 71, 2020, 658, 1662, 63, 7593, 63, 442, 63, 698, 29, 19, 64, 365, 6702, 370, 272, 658, 1662, 63, 7593, 63, 442, 63, 698, 1524, 19, 16090, 1041, 339, 365, 63, 7593, 63, 698, 275, 2688, 8, 5675, 8, 2625, 12, 536, 395, 283, 2880, 358, 272, 340, 365, 63, 7593, 63, 698, 436, 440, 1228, 8, 637, 12, 769, 304, 267, 1139, 275, 359, 637, 61, 272, 340, 1228, 8, 637, 12, 769, 304, 267, 340, 1228, 8, 637, 59, 16, 467, 1211, 304, 288, 367, 1242, 315, 1139, 26, 355, 4104, 63, 1053, 275, 2519, 8, 2625, 12, 536, 680, 525, 342, 355, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 1053, 304, 490, 5090, 63, 2625, 8, 2625, 63, 1053, 12, 1022, 12, 373, 9, 267, 587, 26, 288, 2519, 8, 2625, 12, 536, 680, 2880, 8, 637, 9, 272, 916, 1228, 8, 637, 12, 1211, 304, 267, 367, 1022, 12, 373, 315, 3816, 14, 4611, 8, 637, 304, 288, 5090, 63, 2625, 8, 5675, 8, 2625, 12, 536, 395, 1022, 12, 373, 9, 272, 587, 26, 267, 5371, 8, 2625, 12, 536, 12, 1139, 9, 421, 199, 533, 14132, 8, 785, 304, 272, 408, 33, 14132, 9314, 282, 2849, 1072, 9182, 334, 6777, 4293, 506, 1373, 402, 9978, 272, 13584, 701, 282, 4045, 4959, 624, 339, 347, 636, 826, 721, 277, 12, 4325, 12, 302, 304, 267, 291, 14, 2324, 275, 4325, 267, 291, 14, 78, 275, 302, 339, 347, 370, 63, 2625, 8, 277, 304, 267, 408, 6864, 282, 5365, 4720, 626, 3509, 1006, 9393, 4346, 370, 4526, 267, 642, 2746, 1041, 398, 372, 370, 63, 2625, 8, 277, 9, 339, 347, 485, 475, 63, 2625, 8, 277, 12, 9393, 12, 1561, 12, 6384, 265, 14015, 304, 267, 372, 291, 14, 2324, 423, 475, 63, 2625, 8, 4359, 12, 1561, 12, 6384, 265, 14015, 9, 421, 199, 533, 6801, 8, 785, 304, 272, 408, 33, 6801, 9314, 282, 4045, 12, 2399, 2633, 12, 436, 2399, 4153, 334, 6777, 272, 787, 377, 1483, 687, 1163, 9393, 10477, 339, 347, 636, 826, 721, 277, 12, 730, 63, 354, 12, 4153, 12, 1862, 304, 267, 291, 14, 466, 63, 354, 275, 730, 63, 354, 267, 291, 14, 3711, 275, 4153, 267, 291, 14, 1162, 275, 1862, 267, 291, 14, 343, 411, 275, 291, 14, 1162, 14, 362, 360, 343, 411, 297, 413, 9, 267, 327, 675, 2150, 370, 1852, 3238, 2074, 787, 440, 4270, 13, 7292, 465, 4045, 1862, 267, 340, 283, 343, 411, 7, 315, 291, 14, 1162, 26, 288, 2150, 291, 14, 1162, 459, 343, 411, 418, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
oblalex/django-xlivesettings
xlivesettings/functions.py
1
7450
import logging from django.utils.translation import ugettext from django.utils.translation import ugettext_lazy as _ from xlivesettings import values from xlivesettings.models import SettingNotSet from xlivesettings.utils import is_string_like log = logging.getLogger(__name__) _NOTSET = object() class ConfigurationSettings(object): """A singleton manager for ConfigurationSettings""" class __impl(object): def __init__(self): self.settings = values.SortedDotDict() self.prereg = {} def __getitem__(self, key): """Get an element either by ConfigurationGroup object or by its key""" key = self._resolve_key(key) return self.settings.get(key) def __getattr__(self, key): """Get an element either by ConfigurationGroup object or by its key""" try: return self[key] except: raise AttributeError, key def __iter__(self): for v in self.groups(): yield v def __len__(self): return len(self.settings) def __contains__(self, key): try: key = self._resolve_key(key) return self.settings.has_key(key) except: return False def _resolve_key(self, raw): if is_string_like(raw): key = raw elif isinstance(raw, values.ConfigurationGroup): key = raw.key else: group = self.groups()[raw] key = group.key return key def get_config(self, group, key): try: if isinstance(group, values.ConfigurationGroup): group = group.key cg = self.settings.get(group, None) if not cg: raise SettingNotSet(_("%s config group does not exist") % group) else: return cg[key] except KeyError: raise SettingNotSet("%s.%s" % (group, key)) def groups(self): """Return ordered list""" return self.settings.values() def has_config(self, group, key): if isinstance(group, values.ConfigurationGroup): group = group.key cfg = self.settings.get(group, None) if cfg and key in cfg: return True else: return False def preregister_choice(self, group, key, choice): """Setup a choice for a group/key which hasn't been instantiated yet.""" k = (group, key) if self.prereg.has_key(k): self.prereg[k].append(choice) else: self.prereg[k] = [choice] def register(self, value): g = value.group if not isinstance(g, values.ConfigurationGroup): raise ValueError(_("value.group should be an instance of ConfigurationGroup")) groupkey = g.key valuekey = value.key k = (groupkey, valuekey) if self.prereg.has_key(k): for choice in self.prereg[k]: value.add_choice(choice) if not groupkey in self.settings: self.settings[groupkey] = g self.settings[groupkey][valuekey] = value return value __instance = None def __init__(self): if ConfigurationSettings.__instance is None: ConfigurationSettings.__instance = ConfigurationSettings.__impl() #ConfigurationSettings.__instance.load_app_configurations() self.__dict__['_ConfigurationSettings__instance'] = ConfigurationSettings.__instance def __getattr__(self, attr): """ Delegate access to implementation """ return getattr(self.__instance, attr) def __getitem__(self, key): return self.__instance[key] def __len__(self): return len(self.__instance) def __setattr__(self, attr, value): """ Delegate access to implementation """ return setattr(self.__instance, attr, value) def __unicode__(self): return _("Configuration settings: ") + unicode(self.groups()) def config_exists(group, key): """Test to see if a setting has been registered""" return ConfigurationSettings().has_config(group, key) def config_get(group, key): """Get a configuration setting""" try: return ConfigurationSettings().get_config(group, key) except SettingNotSet: log.debug('SettingNotSet: %s.%s', group, key) raise def config_get_localized(group, key, lang_code): """Get a localized configuration setting""" return dict(config_get(group, key).value)[lang_code] def config_get_group(group): return ConfigurationSettings()[group] def config_collect_values(group, groupkey, key, unique=True, skip_missing=True): """Look up (group, groupkey) from config, then take the values returned and use them as groups for a second-stage lookup. For example: config_collect_values(PAYMENT, MODULES, CREDITCHOICES) Stage 1: ['PAYMENT_GOOGLE', 'PAYMENT_AUTHORIZENET'] Stage 2: config_value('PAYMENT_GOOGLE', 'CREDITCHOICES') + config_value('PAYMENT_AUTHORIZENET', 'CREDITCHOICES') Stage 3: (if unique is true) remove dupes """ groups = config_value(group, groupkey) ret = [] for g in groups: try: ret.append(config_value(g, key)) except KeyError, ke: if not skip_missing: raise SettingNotSet(_("No config %(grp)s.%(key)s") % {'grp': g, 'key': key}) if unique: out = [] for x in ret: if not x in out: out.append(x) ret = out return ret def config_register(value): """Register a value or values. Parameters: -A Value """ return ConfigurationSettings().register(value) def config_register_list(*args): for value in args: config_register(value) def config_value(group, key, default=_NOTSET): """Get a value from the configuration system""" try: return config_get(group, key).value except SettingNotSet: if default != _NOTSET: return default raise def config_value_safe(group, key, default_value): """Get a config value with a default fallback, safe for use during SyncDB.""" raw = default_value try: raw = config_value(group, key) except SettingNotSet: pass except ImportError, e: log.warn("Error getting %s.%s, OK if you are in SyncDB.", group, key) return raw def config_choice_values(group, key, skip_missing=True, translate=False): """Get pairs of key, label from the setting.""" try: cfg = config_get(group, key) choices = cfg.choice_values except SettingNotSet: if skip_missing: return [] else: raise SettingNotSet('%s.%s' % (group, key)) if translate: choices = [(k, ugettext(v)) for k, v in choices] return choices def config_add_choice(group, key, choice): """Add a choice to a value""" if config_exists(group, key): cfg = config_get(group, key) cfg.add_choice(choice) else: ConfigurationSettings().preregister_choice(group, key, choice)
bsd-3-clause
[ 646, 2050, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 671, 6442, 1751, 492, 1338, 199, 504, 671, 6442, 1751, 14, 992, 492, 13510, 15953, 199, 504, 671, 6442, 1751, 14, 1208, 492, 365, 63, 875, 63, 2930, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 4609, 3597, 275, 909, 342, 199, 199, 533, 11595, 5268, 8, 785, 304, 272, 408, 33, 19768, 5256, 367, 11595, 5268, 624, 339, 1021, 636, 5472, 8, 785, 304, 267, 347, 636, 826, 721, 277, 304, 288, 291, 14, 1751, 275, 1338, 14, 22861, 14004, 2141, 342, 288, 291, 14, 657, 1135, 275, 1052, 398, 347, 636, 6095, 721, 277, 12, 790, 304, 288, 408, 1002, 376, 1819, 1902, 701, 11595, 2448, 909, 503, 701, 2399, 790, 624, 288, 790, 275, 291, 423, 6983, 63, 498, 8, 498, 9, 288, 372, 291, 14, 1751, 14, 362, 8, 498, 9, 398, 347, 636, 5675, 721, 277, 12, 790, 304, 288, 408, 1002, 376, 1819, 1902, 701, 11595, 2448, 909, 503, 701, 2399, 790, 624, 288, 862, 26, 355, 372, 291, 59, 498, 61, 288, 871, 26, 355, 746, 4281, 12, 790, 398, 347, 636, 1661, 721, 277, 304, 288, 367, 373, 315, 291, 14, 2634, 837, 355, 1995, 373, 398, 347, 636, 552, 721, 277, 304, 288, 372, 822, 8, 277, 14, 1751, 9, 398, 347, 636, 6134, 721, 277, 12, 790, 304, 288, 862, 26, 355, 790, 275, 291, 423, 6983, 63, 498, 8, 498, 9, 355, 372, 291, 14, 1751, 14, 1989, 63, 498, 8, 498, 9, 288, 871, 26, 355, 372, 756, 398, 347, 485, 6983, 63, 498, 8, 277, 12, 3066, 304, 288, 340, 365, 63, 875, 63, 2930, 8, 1773, 304, 355, 790, 275, 3066, 953, 916, 1228, 8, 1773, 12, 1338, 14, 5688, 2448, 304, 355, 790, 275, 3066, 14, 498, 953, 587, 26, 355, 1572, 275, 291, 14, 2634, 3430, 1773, 61, 355, 790, 275, 1572, 14, 498, 953, 372, 790, 398, 347, 664, 63, 888, 8, 277, 12, 1572, 12, 790, 304, 288, 862, 26, 355, 340, 1228, 8, 923, 12, 1338, 14, 5688, 2448, 304, 490, 1572, 275, 1572, 14, 498, 2234, 19711, 275, 291, 14, 1751, 14, 362, 8, 923, 12, 488, 9, 355, 340, 440, 19711, 26, 490, 746, 13510, 15953, 1547, 3647, 83, 1101, 1572, 1630, 440, 2187, 531, 450, 1572, 9, 2234, 587, 26, 490, 372, 19711, 59, 498, 61, 288, 871, 4067, 26, 355, 746, 13510, 15953, 3647, 83, 4111, 83, 2, 450, 334, 923, 12, 790, 430, 398, 347, 4652, 8, 277, 304, 288, 408, 1767, 7741, 769, 624, 288, 372, 291, 14, 1751, 14, 1459, 342, 398, 347, 965, 63, 888, 8, 277, 12, 1572, 12, 790, 304, 288, 340, 1228, 8, 923, 12, 1338, 14, 5688, 2448, 304, 355, 1572, 275, 1572, 14, 498, 953, 4810, 275, 291, 14, 1751, 14, 362, 8, 923, 12, 488, 9, 288, 340, 4810, 436, 790, 315, 4810, 26, 355, 372, 715, 288, 587, 26, 355, 372, 756, 398, 347, 876, 2683, 63, 5095, 8, 277, 12, 1572, 12, 790, 12, 7141, 304, 288, 408, 8555, 282, 7141, 367, 282, 1572, 15, 498, 1314, 18699, 1133, 2757, 17544, 5966, 1041, 288, 1022, 275, 334, 923, 12, 790, 9, 288, 340, 291, 14, 657, 1135, 14, 1989, 63, 498, 8, 75, 304, 355, 291, 14, 657, 1135, 59, 75, 1055, 740, 8, 5095, 9, 288, 587, 26, 355, 291, 14, 657, 1135, 59, 75, 61, 275, 359, 5095, 61, 398, 347, 2274, 8, 277, 12, 574, 304, 288, 486, 275, 574, 14, 923, 288, 340, 440, 1228, 8, 71, 12, 1338, 14, 5688, 2448, 304, 355, 746, 1722, 6115, 585, 14, 923, 1077, 506, 376, 1256, 402, 11595, 2448, 2237, 953, 1572, 498, 275, 486, 14, 498, 288, 574, 498, 275, 574, 14, 498, 953, 1022, 275, 334, 923, 498, 12, 574, 498, 9, 288, 340, 291, 14, 657, 1135, 14, 1989, 63, 498, 8, 75, 304, 355, 367, 7141, 315, 291, 14, 657, 1135, 59, 75, 2189, 490, 574, 14, 525, 63, 5095, 8, 5095, 9, 953, 340, 440, 1572, 498, 315, 291, 14, 1751, 26, 355, 291, 14, 1751, 59, 923, 498, 61, 275, 486, 953, 291, 14, 1751, 59, 923, 498, 1527, 585, 498, 61, 275, 574, 953, 372, 574, 339, 636, 842, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 340, 11595, 5268, 855, 842, 365, 488, 26, 288, 11595, 5268, 855, 842, 275, 11595, 5268, 855, 5472, 342, 288, 327, 5688, 5268, 855, 842, 14, 912, 63, 571, 63, 10057, 342, 398, 291, 855, 807, 363, 8680, 5688, 5268, 363, 842, 418, 275, 11595, 5268, 855, 842, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 288, 408, 12035, 3237, 2879, 370, 4514, 408, 288, 372, 2519, 8, 277, 855, 842, 12, 1921, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 855, 842, 59, 498, 61, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 855, 842, 9, 339, 347, 636, 10202, 721, 277, 12, 1921, 12, 574, 304, 267, 408, 12035, 3237, 2879, 370, 4514, 408, 267, 372, 5371, 8, 277, 855, 842, 12, 1921, 12, 574, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 3824, 5688, 2202, 26, 6099, 435, 2649, 8, 277, 14, 2634, 1012, 199, 199, 318, 1101, 63, 2444, 8, 923, 12, 790, 304, 272, 408, 774, 370, 1937, 340, 282, 4260, 965, 2757, 7264, 624, 339, 372, 11595, 5268, 1252, 1989, 63, 888, 8, 923, 12, 790, 9, 199, 199, 318, 1101, 63, 362, 8, 923, 12, 790, 304, 272, 408, 1002, 282, 2897, 4260, 624, 272, 862, 26, 267, 372, 11595, 5268, 1252, 362, 63, 888, 8, 923, 12, 790, 9, 272, 871, 13510, 15953, 26, 267, 943, 14, 1757, 360, 7776, 15953, 26, 450, 83, 4111, 83, 297, 1572, 12, 790, 9, 267, 746, 199, 199, 318, 1101, 63, 362, 63, 22729, 8, 923, 12, 790, 12, 6339, 63, 600, 304, 272, 408, 1002, 282, 25460, 2897, 4260, 624 ]
[ 2050, 199, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 671, 6442, 1751, 492, 1338, 199, 504, 671, 6442, 1751, 14, 992, 492, 13510, 15953, 199, 504, 671, 6442, 1751, 14, 1208, 492, 365, 63, 875, 63, 2930, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 63, 4609, 3597, 275, 909, 342, 199, 199, 533, 11595, 5268, 8, 785, 304, 272, 408, 33, 19768, 5256, 367, 11595, 5268, 624, 339, 1021, 636, 5472, 8, 785, 304, 267, 347, 636, 826, 721, 277, 304, 288, 291, 14, 1751, 275, 1338, 14, 22861, 14004, 2141, 342, 288, 291, 14, 657, 1135, 275, 1052, 398, 347, 636, 6095, 721, 277, 12, 790, 304, 288, 408, 1002, 376, 1819, 1902, 701, 11595, 2448, 909, 503, 701, 2399, 790, 624, 288, 790, 275, 291, 423, 6983, 63, 498, 8, 498, 9, 288, 372, 291, 14, 1751, 14, 362, 8, 498, 9, 398, 347, 636, 5675, 721, 277, 12, 790, 304, 288, 408, 1002, 376, 1819, 1902, 701, 11595, 2448, 909, 503, 701, 2399, 790, 624, 288, 862, 26, 355, 372, 291, 59, 498, 61, 288, 871, 26, 355, 746, 4281, 12, 790, 398, 347, 636, 1661, 721, 277, 304, 288, 367, 373, 315, 291, 14, 2634, 837, 355, 1995, 373, 398, 347, 636, 552, 721, 277, 304, 288, 372, 822, 8, 277, 14, 1751, 9, 398, 347, 636, 6134, 721, 277, 12, 790, 304, 288, 862, 26, 355, 790, 275, 291, 423, 6983, 63, 498, 8, 498, 9, 355, 372, 291, 14, 1751, 14, 1989, 63, 498, 8, 498, 9, 288, 871, 26, 355, 372, 756, 398, 347, 485, 6983, 63, 498, 8, 277, 12, 3066, 304, 288, 340, 365, 63, 875, 63, 2930, 8, 1773, 304, 355, 790, 275, 3066, 953, 916, 1228, 8, 1773, 12, 1338, 14, 5688, 2448, 304, 355, 790, 275, 3066, 14, 498, 953, 587, 26, 355, 1572, 275, 291, 14, 2634, 3430, 1773, 61, 355, 790, 275, 1572, 14, 498, 953, 372, 790, 398, 347, 664, 63, 888, 8, 277, 12, 1572, 12, 790, 304, 288, 862, 26, 355, 340, 1228, 8, 923, 12, 1338, 14, 5688, 2448, 304, 490, 1572, 275, 1572, 14, 498, 2234, 19711, 275, 291, 14, 1751, 14, 362, 8, 923, 12, 488, 9, 355, 340, 440, 19711, 26, 490, 746, 13510, 15953, 1547, 3647, 83, 1101, 1572, 1630, 440, 2187, 531, 450, 1572, 9, 2234, 587, 26, 490, 372, 19711, 59, 498, 61, 288, 871, 4067, 26, 355, 746, 13510, 15953, 3647, 83, 4111, 83, 2, 450, 334, 923, 12, 790, 430, 398, 347, 4652, 8, 277, 304, 288, 408, 1767, 7741, 769, 624, 288, 372, 291, 14, 1751, 14, 1459, 342, 398, 347, 965, 63, 888, 8, 277, 12, 1572, 12, 790, 304, 288, 340, 1228, 8, 923, 12, 1338, 14, 5688, 2448, 304, 355, 1572, 275, 1572, 14, 498, 953, 4810, 275, 291, 14, 1751, 14, 362, 8, 923, 12, 488, 9, 288, 340, 4810, 436, 790, 315, 4810, 26, 355, 372, 715, 288, 587, 26, 355, 372, 756, 398, 347, 876, 2683, 63, 5095, 8, 277, 12, 1572, 12, 790, 12, 7141, 304, 288, 408, 8555, 282, 7141, 367, 282, 1572, 15, 498, 1314, 18699, 1133, 2757, 17544, 5966, 1041, 288, 1022, 275, 334, 923, 12, 790, 9, 288, 340, 291, 14, 657, 1135, 14, 1989, 63, 498, 8, 75, 304, 355, 291, 14, 657, 1135, 59, 75, 1055, 740, 8, 5095, 9, 288, 587, 26, 355, 291, 14, 657, 1135, 59, 75, 61, 275, 359, 5095, 61, 398, 347, 2274, 8, 277, 12, 574, 304, 288, 486, 275, 574, 14, 923, 288, 340, 440, 1228, 8, 71, 12, 1338, 14, 5688, 2448, 304, 355, 746, 1722, 6115, 585, 14, 923, 1077, 506, 376, 1256, 402, 11595, 2448, 2237, 953, 1572, 498, 275, 486, 14, 498, 288, 574, 498, 275, 574, 14, 498, 953, 1022, 275, 334, 923, 498, 12, 574, 498, 9, 288, 340, 291, 14, 657, 1135, 14, 1989, 63, 498, 8, 75, 304, 355, 367, 7141, 315, 291, 14, 657, 1135, 59, 75, 2189, 490, 574, 14, 525, 63, 5095, 8, 5095, 9, 953, 340, 440, 1572, 498, 315, 291, 14, 1751, 26, 355, 291, 14, 1751, 59, 923, 498, 61, 275, 486, 953, 291, 14, 1751, 59, 923, 498, 1527, 585, 498, 61, 275, 574, 953, 372, 574, 339, 636, 842, 275, 488, 339, 347, 636, 826, 721, 277, 304, 267, 340, 11595, 5268, 855, 842, 365, 488, 26, 288, 11595, 5268, 855, 842, 275, 11595, 5268, 855, 5472, 342, 288, 327, 5688, 5268, 855, 842, 14, 912, 63, 571, 63, 10057, 342, 398, 291, 855, 807, 363, 8680, 5688, 5268, 363, 842, 418, 275, 11595, 5268, 855, 842, 339, 347, 636, 5675, 721, 277, 12, 1921, 304, 288, 408, 12035, 3237, 2879, 370, 4514, 408, 288, 372, 2519, 8, 277, 855, 842, 12, 1921, 9, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 372, 291, 855, 842, 59, 498, 61, 339, 347, 636, 552, 721, 277, 304, 267, 372, 822, 8, 277, 855, 842, 9, 339, 347, 636, 10202, 721, 277, 12, 1921, 12, 574, 304, 267, 408, 12035, 3237, 2879, 370, 4514, 408, 267, 372, 5371, 8, 277, 855, 842, 12, 1921, 12, 574, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 3824, 5688, 2202, 26, 6099, 435, 2649, 8, 277, 14, 2634, 1012, 199, 199, 318, 1101, 63, 2444, 8, 923, 12, 790, 304, 272, 408, 774, 370, 1937, 340, 282, 4260, 965, 2757, 7264, 624, 339, 372, 11595, 5268, 1252, 1989, 63, 888, 8, 923, 12, 790, 9, 199, 199, 318, 1101, 63, 362, 8, 923, 12, 790, 304, 272, 408, 1002, 282, 2897, 4260, 624, 272, 862, 26, 267, 372, 11595, 5268, 1252, 362, 63, 888, 8, 923, 12, 790, 9, 272, 871, 13510, 15953, 26, 267, 943, 14, 1757, 360, 7776, 15953, 26, 450, 83, 4111, 83, 297, 1572, 12, 790, 9, 267, 746, 199, 199, 318, 1101, 63, 362, 63, 22729, 8, 923, 12, 790, 12, 6339, 63, 600, 304, 272, 408, 1002, 282, 25460, 2897, 4260, 624, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mdietrichc2c/OCB
addons/l10n_cl/__init__.py
2120
1456
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (c) 2011 Cubic ERP - Teradata SAC. (http://cubicerp.com). # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # ############################################################################## # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 1898, 334, 67, 9, 7760, 445, 456, 530, 221, 6758, 446, 13861, 1517, 428, 1348, 14, 334, 1014, 921, 18455, 530, 281, 80, 14, 957, 680, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 4605, 4388, 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 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 1898, 334, 67, 9, 7760, 445, 456, 530, 221, 6758, 446, 13861, 1517, 428, 1348, 14, 334, 1014, 921, 18455, 530, 281, 80, 14, 957, 680, 199, 3, 199, 3, 14750, 26, 961, 2240, 465, 4066, 365, 11619, 370, 506, 1202, 701, 22398, 28661, 199, 3, 2240, 16465, 3963, 5452, 314, 8852, 9163, 83, 3616, 402, 465, 5480, 316, 1006, 12330, 199, 3, 406, 13436, 9183, 687, 2399, 1566, 1061, 315, 9587, 27164, 2578, 436, 18227, 199, 3, 9599, 4390, 3963, 787, 10023, 367, 282, 10144, 13, 475, 13, 1180, 8744, 543, 2414, 23012, 199, 3, 486, 10475, 397, 436, 2291, 787, 30390, 1503, 722, 68, 370, 16077, 282, 2868, 2290, 199, 3, 7591, 15878, 199, 3, 199, 3, 961, 2240, 365, 2868, 2290, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 199, 3, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 199, 3, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 4605, 4388, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
partofthething/home-assistant
homeassistant/components/rachio/device.py
4
9585
"""Adapter to wrap the rachiopy api for home assistant.""" import logging from typing import Optional import voluptuous as vol from homeassistant.const import EVENT_HOMEASSISTANT_STOP, HTTP_OK from homeassistant.helpers import config_validation as cv from .const import ( DOMAIN, KEY_DEVICES, KEY_ENABLED, KEY_EXTERNAL_ID, KEY_FLEX_SCHEDULES, KEY_ID, KEY_MAC_ADDRESS, KEY_MODEL, KEY_NAME, KEY_SCHEDULES, KEY_SERIAL_NUMBER, KEY_STATUS, KEY_USERNAME, KEY_ZONES, MODEL_GENERATION_1, SERVICE_PAUSE_WATERING, SERVICE_RESUME_WATERING, ) from .webhooks import LISTEN_EVENT_TYPES, WEBHOOK_CONST_ID _LOGGER = logging.getLogger(__name__) ATTR_DEVICES = "devices" ATTR_DURATION = "duration" PERMISSION_ERROR = "7" PAUSE_SERVICE_SCHEMA = vol.Schema( { vol.Optional(ATTR_DEVICES): cv.string, vol.Optional(ATTR_DURATION, default=60): cv.positive_int, } ) RESUME_SERVICE_SCHEMA = vol.Schema({vol.Optional(ATTR_DEVICES): cv.string}) class RachioPerson: """Represent a Rachio user.""" def __init__(self, rachio, config_entry): """Create an object from the provided API instance.""" # Use API token to get user ID self.rachio = rachio self.config_entry = config_entry self.username = None self._id = None self._controllers = [] def setup(self, hass): """Rachio device setup.""" all_devices = [] can_pause = False response = self.rachio.person.info() assert int(response[0][KEY_STATUS]) == HTTP_OK, "API key error" self._id = response[1][KEY_ID] # Use user ID to get user data data = self.rachio.person.get(self._id) assert int(data[0][KEY_STATUS]) == HTTP_OK, "User ID error" self.username = data[1][KEY_USERNAME] devices = data[1][KEY_DEVICES] for controller in devices: webhooks = self.rachio.notification.get_device_webhook(controller[KEY_ID])[ 1 ] # The API does not provide a way to tell if a controller is shared # or if they are the owner. To work around this problem we fetch the webooks # before we setup the device so we can skip it instead of failing. # webhooks are normally a list, however if there is an error # rachio hands us back a dict if isinstance(webhooks, dict): if webhooks.get("code") == PERMISSION_ERROR: _LOGGER.info( "Not adding controller '%s', only controllers owned by '%s' may be added", controller[KEY_NAME], self.username, ) else: _LOGGER.error( "Failed to add rachio controller '%s' because of an error: %s", controller[KEY_NAME], webhooks.get("error", "Unknown Error"), ) continue rachio_iro = RachioIro(hass, self.rachio, controller, webhooks) rachio_iro.setup() self._controllers.append(rachio_iro) all_devices.append(rachio_iro.name) # Generation 1 controllers don't support pause or resume if rachio_iro.model.split("_")[0] != MODEL_GENERATION_1: can_pause = True _LOGGER.info('Using Rachio API as user "%s"', self.username) def pause_water(service): """Service to pause watering on all or specific controllers.""" duration = service.data[ATTR_DURATION] devices = service.data.get(ATTR_DEVICES, all_devices) for iro in self._controllers: if iro.name in devices: iro.pause_watering(duration) def resume_water(service): """Service to resume watering on all or specific controllers.""" devices = service.data.get(ATTR_DEVICES, all_devices) for iro in self._controllers: if iro.name in devices: iro.resume_watering() if can_pause: hass.services.register( DOMAIN, SERVICE_PAUSE_WATERING, pause_water, schema=PAUSE_SERVICE_SCHEMA, ) hass.services.register( DOMAIN, SERVICE_RESUME_WATERING, resume_water, schema=RESUME_SERVICE_SCHEMA, ) @property def user_id(self) -> str: """Get the user ID as defined by the Rachio API.""" return self._id @property def controllers(self) -> list: """Get a list of controllers managed by this account.""" return self._controllers def start_multiple_zones(self, zones) -> None: """Start multiple zones.""" self.rachio.zone.start_multiple(zones) class RachioIro: """Represent a Rachio Iro.""" def __init__(self, hass, rachio, data, webhooks): """Initialize a Rachio device.""" self.hass = hass self.rachio = rachio self._id = data[KEY_ID] self.name = data[KEY_NAME] self.serial_number = data[KEY_SERIAL_NUMBER] self.mac_address = data[KEY_MAC_ADDRESS] self.model = data[KEY_MODEL] self._zones = data[KEY_ZONES] self._schedules = data[KEY_SCHEDULES] self._flex_schedules = data[KEY_FLEX_SCHEDULES] self._init_data = data self._webhooks = webhooks _LOGGER.debug('%s has ID "%s"', self, self.controller_id) def setup(self): """Rachio Iro setup for webhooks.""" # Listen for all updates self._init_webhooks() def _init_webhooks(self) -> None: """Start getting updates from the Rachio API.""" current_webhook_id = None # First delete any old webhooks that may have stuck around def _deinit_webhooks(_) -> None: """Stop getting updates from the Rachio API.""" if not self._webhooks: # We fetched webhooks when we created the device, however if we call _init_webhooks # again we need to fetch again self._webhooks = self.rachio.notification.get_device_webhook( self.controller_id )[1] for webhook in self._webhooks: if ( webhook[KEY_EXTERNAL_ID].startswith(WEBHOOK_CONST_ID) or webhook[KEY_ID] == current_webhook_id ): self.rachio.notification.delete(webhook[KEY_ID]) self._webhooks = None _deinit_webhooks(None) # Choose which events to listen for and get their IDs event_types = [] for event_type in self.rachio.notification.get_webhook_event_type()[1]: if event_type[KEY_NAME] in LISTEN_EVENT_TYPES: event_types.append({"id": event_type[KEY_ID]}) # Register to listen to these events from the device url = self.rachio.webhook_url auth = WEBHOOK_CONST_ID + self.rachio.webhook_auth new_webhook = self.rachio.notification.add( self.controller_id, auth, url, event_types ) # Save ID for deletion at shutdown current_webhook_id = new_webhook[1][KEY_ID] self.hass.bus.listen(EVENT_HOMEASSISTANT_STOP, _deinit_webhooks) def __str__(self) -> str: """Display the controller as a string.""" return f'Rachio controller "{self.name}"' @property def controller_id(self) -> str: """Return the Rachio API controller ID.""" return self._id @property def current_schedule(self) -> str: """Return the schedule that the device is running right now.""" return self.rachio.device.current_schedule(self.controller_id)[1] @property def init_data(self) -> dict: """Return the information used to set up the controller.""" return self._init_data def list_zones(self, include_disabled=False) -> list: """Return a list of the zone dicts connected to the device.""" # All zones if include_disabled: return self._zones # Only enabled zones return [z for z in self._zones if z[KEY_ENABLED]] def get_zone(self, zone_id) -> Optional[dict]: """Return the zone with the given ID.""" for zone in self.list_zones(include_disabled=True): if zone[KEY_ID] == zone_id: return zone return None def list_schedules(self) -> list: """Return a list of fixed schedules.""" return self._schedules def list_flex_schedules(self) -> list: """Return a list of flex schedules.""" return self._flex_schedules def stop_watering(self) -> None: """Stop watering all zones connected to this controller.""" self.rachio.device.stop_water(self.controller_id) _LOGGER.info("Stopped watering of all zones on %s", self) def pause_watering(self, duration) -> None: """Pause watering on this controller.""" self.rachio.device.pause_zone_run(self.controller_id, duration * 60) _LOGGER.debug("Paused watering on %s for %s minutes", self, duration) def resume_watering(self) -> None: """Resume paused watering on this controller.""" self.rachio.device.resume_zone_run(self.controller_id) _LOGGER.debug("Resuming watering on %s", self)
mit
[ 624, 10200, 370, 4816, 314, 660, 13175, 927, 2986, 367, 5629, 465, 18832, 1041, 199, 646, 2050, 199, 504, 14090, 492, 4879, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 1297, 492, 6461, 63, 9524, 16435, 840, 1441, 63, 11632, 12, 3101, 63, 3593, 199, 504, 8846, 14, 7546, 492, 1101, 63, 6136, 465, 6277, 199, 199, 504, 1275, 1297, 492, 334, 272, 15265, 12, 272, 9301, 63, 1093, 8670, 12, 272, 9301, 63, 15704, 12, 272, 9301, 63, 21043, 63, 998, 12, 272, 9301, 63, 9851, 63, 27944, 24392, 12, 272, 9301, 63, 998, 12, 272, 9301, 63, 9410, 63, 12368, 12, 272, 9301, 63, 11429, 12, 272, 9301, 63, 2339, 12, 272, 9301, 63, 27944, 24392, 12, 272, 9301, 63, 19637, 63, 9190, 12, 272, 9301, 63, 6305, 12, 272, 9301, 63, 11958, 12, 272, 9301, 63, 58, 615, 654, 12, 272, 10362, 4424, 63, 12795, 2594, 63, 17, 12, 272, 16655, 63, 8470, 4701, 63, 55, 10447, 1206, 12, 272, 16655, 63, 3830, 13847, 63, 55, 10447, 1206, 12, 199, 9, 199, 504, 1275, 2520, 7922, 492, 21716, 742, 63, 8193, 63, 7893, 12, 644, 14138, 28706, 63, 13310, 63, 998, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5280, 63, 1093, 8670, 275, 298, 6410, 2, 199, 5280, 63, 36, 15301, 275, 298, 5553, 2, 199, 4227, 22320, 63, 3170, 275, 298, 23, 2, 199, 199, 8470, 4701, 63, 10486, 63, 10926, 275, 5236, 14, 6700, 8, 272, 469, 267, 5236, 14, 7012, 8, 5280, 63, 1093, 8670, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 5280, 63, 36, 15301, 12, 849, 29, 2259, 304, 6277, 14, 8965, 63, 442, 12, 272, 789, 199, 9, 199, 199, 3830, 13847, 63, 10486, 63, 10926, 275, 5236, 14, 6700, 2561, 5650, 14, 7012, 8, 5280, 63, 1093, 8670, 304, 6277, 14, 875, 1552, 421, 199, 533, 820, 1225, 2308, 7344, 26, 272, 408, 10755, 282, 820, 1225, 2308, 922, 1041, 339, 347, 636, 826, 721, 277, 12, 660, 335, 2308, 12, 1101, 63, 2373, 304, 267, 408, 2499, 376, 909, 687, 314, 2741, 3261, 1256, 1041, 267, 327, 3645, 3261, 1526, 370, 664, 922, 2870, 267, 291, 14, 345, 335, 2308, 275, 660, 335, 2308, 267, 291, 14, 888, 63, 2373, 275, 1101, 63, 2373, 267, 291, 14, 2473, 275, 488, 267, 291, 423, 344, 275, 488, 267, 291, 423, 20531, 275, 942, 339, 347, 3272, 8, 277, 12, 6298, 304, 267, 408, 50, 1225, 2308, 2243, 3272, 1041, 267, 1006, 63, 6410, 275, 942, 267, 883, 63, 11241, 275, 756, 267, 1177, 275, 291, 14, 345, 335, 2308, 14, 5484, 14, 815, 342, 267, 702, 1109, 8, 1310, 59, 16, 1527, 3078, 63, 6305, 566, 508, 3101, 63, 3593, 12, 298, 3735, 790, 1125, 2, 267, 291, 423, 344, 275, 1177, 59, 17, 1527, 3078, 63, 998, 61, 398, 327, 3645, 922, 2870, 370, 664, 922, 666, 267, 666, 275, 291, 14, 345, 335, 2308, 14, 5484, 14, 362, 8, 277, 423, 344, 9, 267, 702, 1109, 8, 576, 59, 16, 1527, 3078, 63, 6305, 566, 508, 3101, 63, 3593, 12, 298, 1899, 2870, 1125, 2, 267, 291, 14, 2473, 275, 666, 59, 17, 1527, 3078, 63, 11958, 61, 267, 7256, 275, 666, 59, 17, 1527, 3078, 63, 1093, 8670, 61, 267, 367, 7614, 315, 7256, 26, 288, 3330, 7922, 275, 291, 14, 345, 335, 2308, 14, 6761, 14, 362, 63, 1782, 63, 22944, 8, 5538, 59, 3078, 63, 998, 11057, 355, 413, 288, 1622, 288, 327, 710, 3261, 1630, 440, 5647, 282, 4340, 370, 11480, 340, 282, 7614, 365, 5709, 288, 327, 503, 340, 2985, 787, 314, 5771, 14, 4005, 1736, 6818, 642, 5160, 781, 5267, 314, 781, 8858, 288, 327, 2544, 781, 3272, 314, 2243, 880, 781, 883, 3372, 652, 3140, 402, 18648, 14, 288, 327, 3330, 7922, 787, 12252, 282, 769, 12, 13432, 340, 2337, 365, 376, 1125, 288, 327, 660, 335, 2308, 4926, 83, 2739, 1771, 282, 1211, 288, 340, 1228, 8, 2520, 7922, 12, 1211, 304, 355, 340, 3330, 7922, 14, 362, 480, 600, 531, 508, 13873, 22320, 63, 3170, 26, 490, 485, 10186, 14, 815, 8, 717, 298, 1763, 7791, 7614, 1543, 83, 297, 1454, 27325, 23191, 701, 1543, 83, 7, 1443, 506, 3483, 401, 717, 7614, 59, 3078, 63, 2339, 467, 717, 291, 14, 2473, 12, 490, 776, 355, 587, 26, 490, 485, 10186, 14, 705, 8, 717, 298, 4276, 370, 1050, 660, 335, 2308, 7614, 1543, 83, 7, 2952, 402, 376, 1125, 26, 450, 83, 401, 717, 7614, 59, 3078, 63, 2339, 467, 717, 3330, 7922, 14, 362, 480, 705, 401, 298, 5912, 4520, 1288, 490, 776, 355, 1980, 953, 660, 335, 2308, 63, 14352, 275, 820, 1225, 2308, 41, 293, 8, 5387, 12, 291, 14, 345, 335, 2308, 12, 7614, 12, 3330, 7922, 9, 288, 660, 335, 2308, 63, 14352, 14, 2758, 342, 288, 291, 423, 20531, 14, 740, 8, 345, 335, 2308, 63, 14352, 9, 288, 1006, 63, 6410, 14, 740, 8, 345, 335, 2308, 63, 14352, 14, 354, 9, 288, 327, 1464, 425, 413, 27325, 2793, 1133, 2291, 16834, 503, 14604, 288, 340, 660, 335, 2308, 63, 14352, 14, 1238, 14, 1294, 11008, 9981, 16, 61, 1137, 10362, 4424, 63, 12795, 2594, 63, 17, 26, 355, 883, 63, 11241, 275, 715, 398, 485, 10186, 14, 815, 360, 10369, 820, 1225, 2308, 3261, 465, 922, 2071, 83, 6949, 291, 14, 2473, 9, 398, 347, 16834, 63, 17217, 8, 1364, 304, 288, 408, 3167, 370, 16834, 336, 323, 5985, 641, 1006, 503, 2488, 27325, 1041, 288, 7373, 275, 2435, 14, 576, 59, 5280, 63, 36, 15301, 61, 288, 7256, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 1093, 8670, 12, 1006, 63, 6410, 9, 288, 367, 284, 293, 315, 291, 423, 20531, 26, 355, 340, 284, 293, 14, 354, 315, 7256, 26, 490, 284, 293, 14, 11241, 63, 87, 323, 5985, 8, 5553, 9, 398, 347, 14604, 63, 17217, 8, 1364, 304, 288, 408, 3167, 370, 14604, 336, 323, 5985, 641, 1006, 503, 2488, 27325, 1041, 288, 7256, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 1093, 8670, 12, 1006 ]
[ 10200, 370, 4816, 314, 660, 13175, 927, 2986, 367, 5629, 465, 18832, 1041, 199, 646, 2050, 199, 504, 14090, 492, 4879, 199, 199, 646, 30291, 465, 5236, 199, 199, 504, 8846, 14, 1297, 492, 6461, 63, 9524, 16435, 840, 1441, 63, 11632, 12, 3101, 63, 3593, 199, 504, 8846, 14, 7546, 492, 1101, 63, 6136, 465, 6277, 199, 199, 504, 1275, 1297, 492, 334, 272, 15265, 12, 272, 9301, 63, 1093, 8670, 12, 272, 9301, 63, 15704, 12, 272, 9301, 63, 21043, 63, 998, 12, 272, 9301, 63, 9851, 63, 27944, 24392, 12, 272, 9301, 63, 998, 12, 272, 9301, 63, 9410, 63, 12368, 12, 272, 9301, 63, 11429, 12, 272, 9301, 63, 2339, 12, 272, 9301, 63, 27944, 24392, 12, 272, 9301, 63, 19637, 63, 9190, 12, 272, 9301, 63, 6305, 12, 272, 9301, 63, 11958, 12, 272, 9301, 63, 58, 615, 654, 12, 272, 10362, 4424, 63, 12795, 2594, 63, 17, 12, 272, 16655, 63, 8470, 4701, 63, 55, 10447, 1206, 12, 272, 16655, 63, 3830, 13847, 63, 55, 10447, 1206, 12, 199, 9, 199, 504, 1275, 2520, 7922, 492, 21716, 742, 63, 8193, 63, 7893, 12, 644, 14138, 28706, 63, 13310, 63, 998, 199, 199, 63, 10186, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 5280, 63, 1093, 8670, 275, 298, 6410, 2, 199, 5280, 63, 36, 15301, 275, 298, 5553, 2, 199, 4227, 22320, 63, 3170, 275, 298, 23, 2, 199, 199, 8470, 4701, 63, 10486, 63, 10926, 275, 5236, 14, 6700, 8, 272, 469, 267, 5236, 14, 7012, 8, 5280, 63, 1093, 8670, 304, 6277, 14, 875, 12, 267, 5236, 14, 7012, 8, 5280, 63, 36, 15301, 12, 849, 29, 2259, 304, 6277, 14, 8965, 63, 442, 12, 272, 789, 199, 9, 199, 199, 3830, 13847, 63, 10486, 63, 10926, 275, 5236, 14, 6700, 2561, 5650, 14, 7012, 8, 5280, 63, 1093, 8670, 304, 6277, 14, 875, 1552, 421, 199, 533, 820, 1225, 2308, 7344, 26, 272, 408, 10755, 282, 820, 1225, 2308, 922, 1041, 339, 347, 636, 826, 721, 277, 12, 660, 335, 2308, 12, 1101, 63, 2373, 304, 267, 408, 2499, 376, 909, 687, 314, 2741, 3261, 1256, 1041, 267, 327, 3645, 3261, 1526, 370, 664, 922, 2870, 267, 291, 14, 345, 335, 2308, 275, 660, 335, 2308, 267, 291, 14, 888, 63, 2373, 275, 1101, 63, 2373, 267, 291, 14, 2473, 275, 488, 267, 291, 423, 344, 275, 488, 267, 291, 423, 20531, 275, 942, 339, 347, 3272, 8, 277, 12, 6298, 304, 267, 408, 50, 1225, 2308, 2243, 3272, 1041, 267, 1006, 63, 6410, 275, 942, 267, 883, 63, 11241, 275, 756, 267, 1177, 275, 291, 14, 345, 335, 2308, 14, 5484, 14, 815, 342, 267, 702, 1109, 8, 1310, 59, 16, 1527, 3078, 63, 6305, 566, 508, 3101, 63, 3593, 12, 298, 3735, 790, 1125, 2, 267, 291, 423, 344, 275, 1177, 59, 17, 1527, 3078, 63, 998, 61, 398, 327, 3645, 922, 2870, 370, 664, 922, 666, 267, 666, 275, 291, 14, 345, 335, 2308, 14, 5484, 14, 362, 8, 277, 423, 344, 9, 267, 702, 1109, 8, 576, 59, 16, 1527, 3078, 63, 6305, 566, 508, 3101, 63, 3593, 12, 298, 1899, 2870, 1125, 2, 267, 291, 14, 2473, 275, 666, 59, 17, 1527, 3078, 63, 11958, 61, 267, 7256, 275, 666, 59, 17, 1527, 3078, 63, 1093, 8670, 61, 267, 367, 7614, 315, 7256, 26, 288, 3330, 7922, 275, 291, 14, 345, 335, 2308, 14, 6761, 14, 362, 63, 1782, 63, 22944, 8, 5538, 59, 3078, 63, 998, 11057, 355, 413, 288, 1622, 288, 327, 710, 3261, 1630, 440, 5647, 282, 4340, 370, 11480, 340, 282, 7614, 365, 5709, 288, 327, 503, 340, 2985, 787, 314, 5771, 14, 4005, 1736, 6818, 642, 5160, 781, 5267, 314, 781, 8858, 288, 327, 2544, 781, 3272, 314, 2243, 880, 781, 883, 3372, 652, 3140, 402, 18648, 14, 288, 327, 3330, 7922, 787, 12252, 282, 769, 12, 13432, 340, 2337, 365, 376, 1125, 288, 327, 660, 335, 2308, 4926, 83, 2739, 1771, 282, 1211, 288, 340, 1228, 8, 2520, 7922, 12, 1211, 304, 355, 340, 3330, 7922, 14, 362, 480, 600, 531, 508, 13873, 22320, 63, 3170, 26, 490, 485, 10186, 14, 815, 8, 717, 298, 1763, 7791, 7614, 1543, 83, 297, 1454, 27325, 23191, 701, 1543, 83, 7, 1443, 506, 3483, 401, 717, 7614, 59, 3078, 63, 2339, 467, 717, 291, 14, 2473, 12, 490, 776, 355, 587, 26, 490, 485, 10186, 14, 705, 8, 717, 298, 4276, 370, 1050, 660, 335, 2308, 7614, 1543, 83, 7, 2952, 402, 376, 1125, 26, 450, 83, 401, 717, 7614, 59, 3078, 63, 2339, 467, 717, 3330, 7922, 14, 362, 480, 705, 401, 298, 5912, 4520, 1288, 490, 776, 355, 1980, 953, 660, 335, 2308, 63, 14352, 275, 820, 1225, 2308, 41, 293, 8, 5387, 12, 291, 14, 345, 335, 2308, 12, 7614, 12, 3330, 7922, 9, 288, 660, 335, 2308, 63, 14352, 14, 2758, 342, 288, 291, 423, 20531, 14, 740, 8, 345, 335, 2308, 63, 14352, 9, 288, 1006, 63, 6410, 14, 740, 8, 345, 335, 2308, 63, 14352, 14, 354, 9, 288, 327, 1464, 425, 413, 27325, 2793, 1133, 2291, 16834, 503, 14604, 288, 340, 660, 335, 2308, 63, 14352, 14, 1238, 14, 1294, 11008, 9981, 16, 61, 1137, 10362, 4424, 63, 12795, 2594, 63, 17, 26, 355, 883, 63, 11241, 275, 715, 398, 485, 10186, 14, 815, 360, 10369, 820, 1225, 2308, 3261, 465, 922, 2071, 83, 6949, 291, 14, 2473, 9, 398, 347, 16834, 63, 17217, 8, 1364, 304, 288, 408, 3167, 370, 16834, 336, 323, 5985, 641, 1006, 503, 2488, 27325, 1041, 288, 7373, 275, 2435, 14, 576, 59, 5280, 63, 36, 15301, 61, 288, 7256, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 1093, 8670, 12, 1006, 63, 6410, 9, 288, 367, 284, 293, 315, 291, 423, 20531, 26, 355, 340, 284, 293, 14, 354, 315, 7256, 26, 490, 284, 293, 14, 11241, 63, 87, 323, 5985, 8, 5553, 9, 398, 347, 14604, 63, 17217, 8, 1364, 304, 288, 408, 3167, 370, 14604, 336, 323, 5985, 641, 1006, 503, 2488, 27325, 1041, 288, 7256, 275, 2435, 14, 576, 14, 362, 8, 5280, 63, 1093, 8670, 12, 1006, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
TomasDuro/paparazzi
sw/ground_segment/python/ivytoredis/ivy_to_redis.py
36
2399
#!/usr/bin/env python from __future__ import print_function import redis import time import signal import argparse import sys import os # if PAPARAZZI_SRC not set, then assume the tree containing this # file is a reasonable substitute PPRZ_SRC = os.getenv("PAPARAZZI_SRC", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../../'))) PPRZ_LIB_PYTHON = os.path.join(PPRZ_SRC, "sw/lib/python") sys.path.append(PPRZ_LIB_PYTHON) from pprzlink.ivy import IvyMessagesInterface server = None class Ivy2RedisServer(): def __init__(self, redishost, redisport, verbose=False): self.verbose = verbose self.interface = IvyMessagesInterface("Ivy2Redis") self.interface.subscribe(self.message_recv) self.r = redis.StrictRedis(host=redishost, port=redisport, db=0) self.keep_running = True print("Connected to redis server %s on port %i" % (redishost, redisport)) def message_recv(self, ac_id, msg): # if ac_id is not 0 (i.e. telemetry from an aircraft) include it in the key # don't add it to the key for ground messages if ac_id: key = "{0}.{1}.{2}".format(msg.msg_class, msg.name, ac_id) else: key = "{0}.{1}".format(msg.msg_class, msg.name) if self.verbose: print("received message, key=%s, msg=%s" % (key, msg.to_json(payload_only=True))) sys.stdout.flush() self.r.publish(key, msg.to_json(payload_only=True)) self.r.set(key, msg.to_json(payload_only=True)) def run(self): while self.keep_running: time.sleep(0.1) def stop(self): self.keep_running = False self.interface.shutdown() def signal_handler(signal, frame): global server server.stop() def main(): global server parser = argparse.ArgumentParser() parser.add_argument("-s", "--server", help="hostname here redis runs", default="localhost") parser.add_argument("-p", "--port", help="port used by redis", type=int, default=6379) parser.add_argument("-v", "--verbose", dest="verbose", action="store_true") args = parser.parse_args() server = Ivy2RedisServer(args.server, args.port, args.verbose) signal.signal(signal.SIGINT, signal_handler) server.run() if __name__ == '__main__': main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 16967, 199, 646, 900, 199, 646, 4673, 199, 646, 7534, 199, 646, 984, 199, 646, 747, 199, 199, 3, 340, 510, 1282, 689, 33, 9909, 41, 63, 12447, 440, 663, 12, 2066, 5534, 314, 3123, 3035, 642, 199, 3, 570, 365, 282, 23255, 23080, 199, 48, 3311, 58, 63, 12447, 275, 747, 14, 12959, 480, 48, 1282, 689, 33, 9909, 41, 63, 12447, 401, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 22159, 25405, 283, 9707, 9707, 7058, 199, 48, 3311, 58, 63, 5617, 63, 11720, 275, 747, 14, 515, 14, 904, 8, 48, 3311, 58, 63, 12447, 12, 298, 3519, 15, 773, 15, 1548, 531, 199, 1274, 14, 515, 14, 740, 8, 48, 3311, 58, 63, 5617, 63, 11720, 9, 199, 199, 504, 299, 2700, 90, 1073, 14, 10241, 492, 473, 16091, 14508, 4267, 199, 199, 1000, 275, 488, 421, 199, 533, 473, 16091, 18, 29605, 3120, 837, 272, 347, 636, 826, 721, 277, 12, 16967, 1102, 12, 295, 328, 3275, 12, 3376, 29, 797, 304, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 3266, 275, 473, 16091, 14508, 4267, 480, 41, 16091, 18, 29605, 531, 267, 291, 14, 3266, 14, 10108, 8, 277, 14, 1188, 63, 7637, 9, 267, 291, 14, 82, 275, 16967, 14, 18625, 29605, 8, 1102, 29, 15369, 1102, 12, 1844, 29, 264, 328, 3275, 12, 1592, 29, 16, 9, 267, 291, 14, 3250, 63, 5720, 275, 715, 267, 870, 480, 16382, 370, 16967, 1654, 450, 83, 641, 1844, 450, 73, 2, 450, 334, 15369, 1102, 12, 295, 328, 3275, 430, 339, 347, 1245, 63, 7637, 8, 277, 12, 1066, 63, 344, 12, 1499, 304, 267, 327, 340, 1066, 63, 344, 365, 440, 378, 334, 73, 14, 69, 14, 17298, 687, 376, 282, 5958, 4800, 9, 2387, 652, 315, 314, 790, 267, 327, 2793, 1133, 1050, 652, 370, 314, 790, 367, 19252, 3788, 267, 340, 1066, 63, 344, 26, 288, 790, 275, 5310, 16, 26944, 17, 26944, 18, 5469, 908, 8, 1328, 14, 1328, 63, 533, 12, 1499, 14, 354, 12, 1066, 63, 344, 9, 267, 587, 26, 288, 790, 275, 5310, 16, 26944, 17, 5469, 908, 8, 1328, 14, 1328, 63, 533, 12, 1499, 14, 354, 9, 267, 340, 291, 14, 3832, 26, 288, 870, 480, 9226, 1245, 12, 790, 2458, 83, 12, 1499, 2458, 83, 2, 450, 334, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 1724, 288, 984, 14, 2703, 14, 4939, 342, 267, 291, 14, 82, 14, 4763, 8, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 430, 267, 291, 14, 82, 14, 409, 8, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 430, 339, 347, 1255, 8, 277, 304, 267, 1830, 291, 14, 3250, 63, 5720, 26, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 339, 347, 3631, 8, 277, 304, 267, 291, 14, 3250, 63, 5720, 275, 756, 267, 291, 14, 3266, 14, 8831, 342, 421, 199, 318, 4673, 63, 2232, 8, 4653, 12, 2787, 304, 272, 2288, 1654, 272, 1654, 14, 2379, 342, 421, 199, 318, 2446, 837, 272, 2288, 1654, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 6096, 83, 401, 4320, 1000, 401, 1720, 628, 4269, 2348, 16967, 7858, 401, 849, 628, 5967, 531, 272, 1798, 14, 525, 63, 2094, 6096, 80, 401, 4320, 719, 401, 1720, 628, 719, 1202, 701, 16967, 401, 730, 29, 442, 12, 849, 29, 22, 12015, 9, 272, 1798, 14, 525, 63, 2094, 6096, 86, 401, 4320, 3832, 401, 2053, 628, 3832, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 1654, 275, 473, 16091, 18, 29605, 3120, 8, 589, 14, 1000, 12, 1249, 14, 719, 12, 1249, 14, 3832, 9, 272, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 63, 2232, 9, 272, 1654, 14, 1065, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 16967, 199, 646, 900, 199, 646, 4673, 199, 646, 7534, 199, 646, 984, 199, 646, 747, 199, 199, 3, 340, 510, 1282, 689, 33, 9909, 41, 63, 12447, 440, 663, 12, 2066, 5534, 314, 3123, 3035, 642, 199, 3, 570, 365, 282, 23255, 23080, 199, 48, 3311, 58, 63, 12447, 275, 747, 14, 12959, 480, 48, 1282, 689, 33, 9909, 41, 63, 12447, 401, 747, 14, 515, 14, 9267, 8, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 4832, 3460, 493, 22159, 25405, 283, 9707, 9707, 7058, 199, 48, 3311, 58, 63, 5617, 63, 11720, 275, 747, 14, 515, 14, 904, 8, 48, 3311, 58, 63, 12447, 12, 298, 3519, 15, 773, 15, 1548, 531, 199, 1274, 14, 515, 14, 740, 8, 48, 3311, 58, 63, 5617, 63, 11720, 9, 199, 199, 504, 299, 2700, 90, 1073, 14, 10241, 492, 473, 16091, 14508, 4267, 199, 199, 1000, 275, 488, 421, 199, 533, 473, 16091, 18, 29605, 3120, 837, 272, 347, 636, 826, 721, 277, 12, 16967, 1102, 12, 295, 328, 3275, 12, 3376, 29, 797, 304, 267, 291, 14, 3832, 275, 3376, 267, 291, 14, 3266, 275, 473, 16091, 14508, 4267, 480, 41, 16091, 18, 29605, 531, 267, 291, 14, 3266, 14, 10108, 8, 277, 14, 1188, 63, 7637, 9, 267, 291, 14, 82, 275, 16967, 14, 18625, 29605, 8, 1102, 29, 15369, 1102, 12, 1844, 29, 264, 328, 3275, 12, 1592, 29, 16, 9, 267, 291, 14, 3250, 63, 5720, 275, 715, 267, 870, 480, 16382, 370, 16967, 1654, 450, 83, 641, 1844, 450, 73, 2, 450, 334, 15369, 1102, 12, 295, 328, 3275, 430, 339, 347, 1245, 63, 7637, 8, 277, 12, 1066, 63, 344, 12, 1499, 304, 267, 327, 340, 1066, 63, 344, 365, 440, 378, 334, 73, 14, 69, 14, 17298, 687, 376, 282, 5958, 4800, 9, 2387, 652, 315, 314, 790, 267, 327, 2793, 1133, 1050, 652, 370, 314, 790, 367, 19252, 3788, 267, 340, 1066, 63, 344, 26, 288, 790, 275, 5310, 16, 26944, 17, 26944, 18, 5469, 908, 8, 1328, 14, 1328, 63, 533, 12, 1499, 14, 354, 12, 1066, 63, 344, 9, 267, 587, 26, 288, 790, 275, 5310, 16, 26944, 17, 5469, 908, 8, 1328, 14, 1328, 63, 533, 12, 1499, 14, 354, 9, 267, 340, 291, 14, 3832, 26, 288, 870, 480, 9226, 1245, 12, 790, 2458, 83, 12, 1499, 2458, 83, 2, 450, 334, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 1724, 288, 984, 14, 2703, 14, 4939, 342, 267, 291, 14, 82, 14, 4763, 8, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 430, 267, 291, 14, 82, 14, 409, 8, 498, 12, 1499, 14, 475, 63, 1001, 8, 4749, 63, 2118, 29, 549, 430, 339, 347, 1255, 8, 277, 304, 267, 1830, 291, 14, 3250, 63, 5720, 26, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 339, 347, 3631, 8, 277, 304, 267, 291, 14, 3250, 63, 5720, 275, 756, 267, 291, 14, 3266, 14, 8831, 342, 421, 199, 318, 4673, 63, 2232, 8, 4653, 12, 2787, 304, 272, 2288, 1654, 272, 1654, 14, 2379, 342, 421, 199, 318, 2446, 837, 272, 2288, 1654, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 6096, 83, 401, 4320, 1000, 401, 1720, 628, 4269, 2348, 16967, 7858, 401, 849, 628, 5967, 531, 272, 1798, 14, 525, 63, 2094, 6096, 80, 401, 4320, 719, 401, 1720, 628, 719, 1202, 701, 16967, 401, 730, 29, 442, 12, 849, 29, 22, 12015, 9, 272, 1798, 14, 525, 63, 2094, 6096, 86, 401, 4320, 3832, 401, 2053, 628, 3832, 401, 1595, 628, 1617, 63, 2052, 531, 272, 1249, 275, 1798, 14, 1122, 63, 589, 342, 272, 1654, 275, 473, 16091, 18, 29605, 3120, 8, 589, 14, 1000, 12, 1249, 14, 719, 12, 1249, 14, 3832, 9, 272, 4673, 14, 4653, 8, 4653, 14, 21223, 12, 4673, 63, 2232, 9, 272, 1654, 14, 1065, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
fizyk/matchbox
src/matchbox/matchbox.py
1
3244
# Copyright (C) 2015 by Clearcode <http://clearcode.cc> # and associates (see AUTHORS). # This file is part of matchbox. # matchbox 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 3 of the License, or # (at your option) any later version. # matchbox 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 matchbox. If not, see <http://www.gnu.org/licenses/>. """Single value MatchBox idea implementation.""" from __future__ import absolute_import from matchbox.basebox import BaseBox class MatchBox(BaseBox): """ MatchBox for classifying objects by single-value characteristic. Example: +--------+-------+-------------------------+ | Object | Match | Characteristic's values | +========+=======+=========================+ | Ob1 | False | 1 | +--------+-------+-------------------------+ | Ob2 | True | 3 | +--------+-------+-------------------------+ | Ob3 | False | 5 | +--------+-------+-------------------------+ | Ob4 | False | | +--------+-------+-------------------------+ | Ob5 | True | 1 | +--------+-------+-------------------------+ Will result in matchbox'es index: +-----------+-----------------+ | Attribute | Matched Objects | +===========+=================+ | 1 | Ob1, Ob2 | +-----------+-----------------+ | 3 | Ob5 | +-----------+-----------------+ | 5 | Ob2, Ob3, Ob5 | +-----------+-----------------+ | Any new | Ob2, Ob5 | +-----------+-----------------+ """ def add(self, indexed_object): """ Add object to index. :param object indexed_object: single object to add to box's index """ characteristic_value = getattr(indexed_object, self._characteristic) if characteristic_value is None: return is_matching = getattr(indexed_object, self._characteristic + '_match', True) # if object is not matching given characteristic, we should add it directly to index. if not is_matching: self.index[characteristic_value].add(indexed_object) else: # access key to trigger copy of excluded. # Since now the value becomes known. self.index[characteristic_value] # we add object to each value in index that's not it's characteristic's value for existing_value in self.index: if existing_value == characteristic_value: continue self.index[existing_value].add(indexed_object) # and make sure for every new value it'll be excluded as well self.exclude_unknown.add(indexed_object)
lgpl-3.0
[ 3, 1898, 334, 35, 9, 6900, 701, 14836, 600, 665, 1014, 921, 3584, 600, 14, 2055, 30, 199, 3, 436, 4035, 2335, 334, 3239, 10610, 680, 199, 199, 3, 961, 570, 365, 1777, 402, 1336, 1977, 14, 199, 199, 3, 1336, 1977, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 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, 199, 3, 1336, 1977, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 1336, 1977, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 7200, 574, 9814, 3532, 16819, 4514, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1336, 1977, 14, 1095, 1977, 492, 3523, 3532, 421, 199, 533, 9814, 3532, 8, 1563, 3532, 304, 339, 408, 272, 9814, 3532, 367, 28837, 316, 2251, 701, 2849, 13, 585, 2735, 6236, 11108, 14, 339, 5679, 26, 339, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 6935, 1204, 9814, 1204, 6659, 14299, 11108, 1159, 1338, 1204, 272, 435, 763, 11, 18673, 11, 1280, 15495, 11, 272, 1204, 17985, 17, 259, 1204, 756, 1204, 413, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 18, 259, 1204, 715, 221, 1204, 650, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 19, 259, 1204, 756, 1204, 959, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 20, 259, 1204, 756, 1204, 12793, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 21, 259, 1204, 715, 221, 1204, 413, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 339, 12823, 754, 315, 1336, 1977, 7, 397, 1478, 26, 339, 435, 27592, 777, 6793, 272, 1204, 3882, 1204, 9814, 379, 26794, 1204, 272, 435, 21326, 11, 1280, 29744, 272, 1204, 413, 260, 1204, 17985, 17, 12, 17985, 18, 263, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 650, 260, 1204, 17985, 21, 3777, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 959, 260, 1204, 17985, 18, 12, 17985, 19, 12, 17985, 21, 257, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 6184, 892, 257, 1204, 17985, 18, 12, 17985, 21, 263, 1204, 272, 435, 27592, 777, 6793, 272, 408, 339, 347, 1050, 8, 277, 12, 15235, 63, 785, 304, 267, 408, 267, 2654, 909, 370, 1478, 14, 398, 520, 635, 909, 15235, 63, 785, 26, 2849, 909, 370, 1050, 370, 5689, 1159, 1478, 267, 408, 267, 2735, 6236, 11108, 63, 585, 275, 2519, 8, 16821, 63, 785, 12, 291, 423, 1560, 14299, 11108, 9, 267, 340, 2735, 6236, 11108, 63, 585, 365, 488, 26, 288, 372, 398, 365, 63, 9467, 275, 2519, 8, 16821, 63, 785, 12, 291, 423, 1560, 14299, 11108, 435, 2513, 1431, 297, 715, 9, 398, 327, 340, 909, 365, 440, 4877, 1627, 2735, 6236, 11108, 12, 781, 1077, 1050, 652, 5370, 370, 1478, 14, 267, 340, 440, 365, 63, 9467, 26, 288, 291, 14, 1080, 59, 1560, 14299, 11108, 63, 585, 1055, 525, 8, 16821, 63, 785, 9, 267, 587, 26, 288, 327, 2879, 790, 370, 6804, 1331, 402, 8789, 14, 288, 327, 9336, 3063, 314, 574, 15410, 6040, 14, 288, 291, 14, 1080, 59, 1560, 14299, 11108, 63, 585, 61, 288, 327, 781, 1050, 909, 370, 1924, 574, 315, 1478, 626, 1159, 440, 652, 1159, 2735, 6236, 11108, 1159, 574, 288, 367, 3411, 63, 585, 315, 291, 14, 1080, 26, 355, 340, 3411, 63, 585, 508, 2735, 6236, 11108, 63, 585, 26, 490, 1980, 355, 291, 14, 1080, 59, 5952, 63, 585, 1055, 525, 8, 16821, 63, 785, 9, 288, 327, 436, 1852, 3238, 367, 4036, 892, 574, 652, 7171, 506, 8789, 465, 5521, 288, 291, 14, 5473, 63, 5187, 14, 525, 8, 16821, 63, 785, 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 ]
[ 1898, 334, 35, 9, 6900, 701, 14836, 600, 665, 1014, 921, 3584, 600, 14, 2055, 30, 199, 3, 436, 4035, 2335, 334, 3239, 10610, 680, 199, 199, 3, 961, 570, 365, 1777, 402, 1336, 1977, 14, 199, 199, 3, 1336, 1977, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 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, 199, 3, 1336, 1977, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 1336, 1977, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 624, 7200, 574, 9814, 3532, 16819, 4514, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 504, 1336, 1977, 14, 1095, 1977, 492, 3523, 3532, 421, 199, 533, 9814, 3532, 8, 1563, 3532, 304, 339, 408, 272, 9814, 3532, 367, 28837, 316, 2251, 701, 2849, 13, 585, 2735, 6236, 11108, 14, 339, 5679, 26, 339, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 6935, 1204, 9814, 1204, 6659, 14299, 11108, 1159, 1338, 1204, 272, 435, 763, 11, 18673, 11, 1280, 15495, 11, 272, 1204, 17985, 17, 259, 1204, 756, 1204, 413, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 18, 259, 1204, 715, 221, 1204, 650, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 19, 259, 1204, 756, 1204, 959, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 20, 259, 1204, 756, 1204, 12793, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 272, 1204, 17985, 21, 259, 1204, 715, 221, 1204, 413, 9668, 1204, 272, 435, 518, 11, 375, 9018, 777, 26533, 339, 12823, 754, 315, 1336, 1977, 7, 397, 1478, 26, 339, 435, 27592, 777, 6793, 272, 1204, 3882, 1204, 9814, 379, 26794, 1204, 272, 435, 21326, 11, 1280, 29744, 272, 1204, 413, 260, 1204, 17985, 17, 12, 17985, 18, 263, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 650, 260, 1204, 17985, 21, 3777, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 959, 260, 1204, 17985, 18, 12, 17985, 19, 12, 17985, 21, 257, 1204, 272, 435, 27592, 777, 6793, 272, 1204, 6184, 892, 257, 1204, 17985, 18, 12, 17985, 21, 263, 1204, 272, 435, 27592, 777, 6793, 272, 408, 339, 347, 1050, 8, 277, 12, 15235, 63, 785, 304, 267, 408, 267, 2654, 909, 370, 1478, 14, 398, 520, 635, 909, 15235, 63, 785, 26, 2849, 909, 370, 1050, 370, 5689, 1159, 1478, 267, 408, 267, 2735, 6236, 11108, 63, 585, 275, 2519, 8, 16821, 63, 785, 12, 291, 423, 1560, 14299, 11108, 9, 267, 340, 2735, 6236, 11108, 63, 585, 365, 488, 26, 288, 372, 398, 365, 63, 9467, 275, 2519, 8, 16821, 63, 785, 12, 291, 423, 1560, 14299, 11108, 435, 2513, 1431, 297, 715, 9, 398, 327, 340, 909, 365, 440, 4877, 1627, 2735, 6236, 11108, 12, 781, 1077, 1050, 652, 5370, 370, 1478, 14, 267, 340, 440, 365, 63, 9467, 26, 288, 291, 14, 1080, 59, 1560, 14299, 11108, 63, 585, 1055, 525, 8, 16821, 63, 785, 9, 267, 587, 26, 288, 327, 2879, 790, 370, 6804, 1331, 402, 8789, 14, 288, 327, 9336, 3063, 314, 574, 15410, 6040, 14, 288, 291, 14, 1080, 59, 1560, 14299, 11108, 63, 585, 61, 288, 327, 781, 1050, 909, 370, 1924, 574, 315, 1478, 626, 1159, 440, 652, 1159, 2735, 6236, 11108, 1159, 574, 288, 367, 3411, 63, 585, 315, 291, 14, 1080, 26, 355, 340, 3411, 63, 585, 508, 2735, 6236, 11108, 63, 585, 26, 490, 1980, 355, 291, 14, 1080, 59, 5952, 63, 585, 1055, 525, 8, 16821, 63, 785, 9, 288, 327, 436, 1852, 3238, 367, 4036, 892, 574, 652, 7171, 506, 8789, 465, 5521, 288, 291, 14, 5473, 63, 5187, 14, 525, 8, 16821, 63, 785, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jmarsik/mopidy
mopidy/core/actor.py
1
9428
from __future__ import absolute_import, unicode_literals import collections import itertools import logging import pykka from mopidy import audio, backend, mixer, service from mopidy.audio import PlaybackState from mopidy.core.service import ServiceController from mopidy.core.history import HistoryController from mopidy.core.library import LibraryController from mopidy.core.listener import CoreListener from mopidy.core.mixer import MixerController from mopidy.core.playback import PlaybackController from mopidy.core.playlists import PlaylistsController from mopidy.core.tracklist import TracklistController from mopidy.internal import versioning from mopidy.internal.deprecation import deprecated_property actor_name = lambda a: a.actor_ref.actor_class.__name__ logger = logging.getLogger(__name__) class Core( pykka.ThreadingActor, audio.AudioListener, backend.BackendListener, mixer.MixerListener): library = None """An instance of :class:`~mopidy.core.LibraryController`""" history = None """An instance of :class:`~mopidy.core.HistoryController`""" mixer = None """An instance of :class:`~mopidy.core.MixerController`""" playback = None """An instance of :class:`~mopidy.core.PlaybackController`""" playlists = None """An instance of :class:`~mopidy.core.PlaylistsController`""" tracklist = None """An instance of :class:`~mopidy.core.TracklistController`""" service = None """The service controller. An instance of :class:`mopidy.core.ServiceController`.""" def __init__(self, audio=None, config=None, mixer=None, backends=None, backend_classes=[]): super(Core, self).__init__() self.audio = audio self._config = config self.backends = Backends(backends) # A backend may also be a service, so we check if the backend # inherits the service class and append it to the service # class list if it does services = [] service_classes = [] idx = 0 for b in backends: if (idx < len(backend_classes) and issubclass(backend_classes[idx], service.Service)): services.append(b) service_classes.append(backend_classes[idx]) idx += 1 self.services = Services(services, service_classes) self.service = ServiceController(services=self.services, core=self) self.library = LibraryController(backends=self.backends, core=self) self.history = HistoryController() self.mixer = MixerController(mixer=mixer) self.playback = PlaybackController(backends=self.backends, core=self) self.playlists = PlaylistsController(backends=self.backends, core=self) self.tracklist = TracklistController(core=self) def get_uri_schemes(self): """Get list of URI schemes we can handle""" futures = [b.uri_schemes for b in self.backends] results = pykka.get_all(futures) uri_schemes = itertools.chain(*results) return sorted(uri_schemes) uri_schemes = deprecated_property(get_uri_schemes) """ .. deprecated:: 1.0 Use :meth:`get_uri_schemes` instead. """ def get_version(self): """Get version of the Mopidy core API""" return versioning.get_version() version = deprecated_property(get_version) """ .. deprecated:: 1.0 Use :meth:`get_version` instead. """ def reached_end_of_stream(self): self.playback._on_end_of_track() def stream_changed(self, uri): self.playback._on_stream_changed(uri) def state_changed(self, old_state, new_state, target_state): # XXX: This is a temporary fix for issue #232 while we wait for a more # permanent solution with the implementation of issue #234. When the # Spotify play token is lost, the Spotify backend pauses audio # playback, but mopidy.core doesn't know this, so we need to update # mopidy.core's state to match the actual state in mopidy.audio. If we # don't do this, clients will think that we're still playing. # We ignore cases when target state is set as this is buffering # updates (at least for now) and we need to get #234 fixed... if (new_state == PlaybackState.PAUSED and not target_state and self.playback.state != PlaybackState.PAUSED): self.playback.state = new_state self.playback._trigger_track_playback_paused() def playlists_loaded(self): # Forward event from backend to frontends CoreListener.send('playlists_loaded') def volume_changed(self, volume): # Forward event from mixer to frontends CoreListener.send('volume_changed', volume=volume) def mute_changed(self, mute): # Forward event from mixer to frontends CoreListener.send('mute_changed', mute=mute) def notify_startup_complete(self): """Notifier to inform listeners that start-up is now complete - it should only be called once as part of the start-up code""" CoreListener.send('startup_complete') def tags_changed(self, tags): if not self.audio or 'title' not in tags: return tags = self.audio.get_current_tags().get() if not tags: return # TODO: this limits us to only streams that set organization, this is # a hack to make sure we don't emit stream title changes for plain # tracks. We need a better way to decide if something is a stream. if 'title' in tags and tags['title'] and 'organization' in tags: title = tags['title'][0] self.playback._stream_title = title CoreListener.send('stream_title_changed', title=title) def register_service(self, service_obj, service_class): """Register a new service after core has started e.g., a frontend""" self.services.add_service(service_obj, service_class) CoreListener.send('service_registered', service=service_obj.name.get()) def get_public_services(self): """Obtain a list of service actors whose API is publicly exported""" return self.services.public_services_by_name def get_public_service_classes(self): """Obtain a list of service classes whose API is publicly exported""" return self.services.public_classes_by_name def add_audio_sink(self, ident, sink_obj): """Add an audio sink object dynamically to the running audio pipeline""" self.audio.add_sink(ident, sink_obj) def remove_audio_sink(self, ident): self.audio.remove_sink(ident) class Backends(list): def __init__(self, backends): super(Backends, self).__init__(backends) self.with_library = collections.OrderedDict() self.with_library_browse = collections.OrderedDict() self.with_playback = collections.OrderedDict() self.with_playlists = collections.OrderedDict() backends_by_scheme = {} def name(b): return b.actor_ref.actor_class.__name__ for b in backends: try: has_library = b.has_library().get() has_library_browse = b.has_library_browse().get() has_playback = b.has_playback().get() has_playlists = b.has_playlists().get() except Exception: self.remove(b) logger.exception('Fetching backend info for %s failed', b.actor_ref.actor_class.__name__) for scheme in b.uri_schemes.get(): assert scheme not in backends_by_scheme, ( 'Cannot add URI scheme "%s" for %s, ' 'it is already handled by %s' ) % (scheme, actor_name(b), actor_name(backends_by_scheme[scheme])) backends_by_scheme[scheme] = b if has_library: self.with_library[scheme] = b if has_library_browse: self.with_library_browse[scheme] = b if has_playback: self.with_playback[scheme] = b if has_playlists: self.with_playlists[scheme] = b class Services(list): def __init__(self, services, service_classes): super(Services, self).__init__(services) self.services_by_name = {} self.classes_by_name = {} # Public services will have their full APIs exported to HTTP/JSON RPC - # this will be a subset of the above dictionaries self.public_services_by_name = {} self.public_classes_by_name = {} idx = 0 for s in services: self.add_service(s, service_classes[idx]) idx += 1 def add_service(self, s, service_class): logger.info('Adding service %s-%s', s, service_class) assert s.name.get() not in self.services_by_name, ( 'Cannot add service name %s for %s, ' 'it is already taken by %s' ) % (s.name.get(), actor_name(s), actor_name(self.services_by_name[s.name.get()])) self.services_by_name[s.name.get()] = s self.classes_by_name[s.name.get()] = service_class if (s.public.get()): self.public_services_by_name[s.name.get()] = s self.public_classes_by_name[s.name.get()] = service_class
apache-2.0
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 7975, 199, 646, 2050, 199, 199, 646, 1134, 75, 7351, 199, 199, 504, 333, 411, 344, 89, 492, 10491, 12, 4865, 12, 13667, 281, 12, 2435, 199, 504, 333, 411, 344, 89, 14, 8130, 492, 16527, 894, 2223, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 1364, 492, 7591, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 5570, 492, 27829, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 4342, 492, 11243, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 9799, 492, 11672, 10464, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 13979, 281, 492, 603, 1148, 281, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 2802, 894, 492, 16527, 894, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 2802, 6717, 492, 16527, 6717, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 3885, 513, 492, 17507, 513, 7506, 199, 504, 333, 411, 344, 89, 14, 4672, 492, 1015, 316, 199, 504, 333, 411, 344, 89, 14, 4672, 14, 15383, 492, 5906, 63, 1829, 421, 199, 5021, 63, 354, 275, 2400, 282, 26, 282, 14, 5021, 63, 1121, 14, 5021, 63, 533, 855, 354, 363, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11672, 8, 267, 1134, 75, 7351, 14, 4436, 316, 12258, 12, 10491, 14, 15484, 10464, 12, 4865, 14, 8447, 10464, 12, 267, 13667, 281, 14, 18854, 281, 10464, 304, 339, 3555, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 7424, 7506, 64, 624, 339, 7994, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 12114, 7506, 64, 624, 339, 13667, 281, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 18854, 281, 7506, 64, 624, 339, 5232, 894, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 9651, 894, 7506, 64, 624, 339, 5232, 6717, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 9651, 6717, 7506, 64, 624, 339, 4426, 513, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 7927, 513, 7506, 64, 624, 339, 2435, 275, 488, 272, 408, 1918, 2435, 7614, 14, 1626, 1256, 402, 272, 520, 533, 1705, 77, 411, 344, 89, 14, 1018, 14, 3167, 7506, 17105, 339, 347, 636, 826, 721, 277, 12, 10491, 29, 403, 12, 1101, 29, 403, 12, 13667, 281, 29, 403, 12, 14745, 29, 403, 12, 4865, 63, 2888, 17894, 398, 1613, 8, 5402, 12, 291, 2843, 826, 4533, 398, 291, 14, 8130, 275, 10491, 267, 291, 423, 888, 275, 1101, 398, 291, 14, 7765, 275, 10257, 3198, 8, 7765, 9, 398, 327, 437, 4865, 1443, 2597, 506, 282, 2435, 12, 880, 781, 1104, 340, 314, 4865, 267, 327, 21592, 314, 2435, 1021, 436, 5666, 652, 370, 314, 2435, 267, 327, 1021, 769, 340, 652, 1630, 267, 8500, 275, 942, 267, 2435, 63, 2888, 275, 942, 267, 4280, 275, 378, 267, 367, 330, 315, 14745, 26, 288, 340, 334, 2996, 665, 822, 8, 4620, 63, 2888, 9, 436, 11602, 8, 4620, 63, 2888, 59, 2996, 467, 2435, 14, 3167, 2298, 355, 8500, 14, 740, 8, 66, 9, 355, 2435, 63, 2888, 14, 740, 8, 4620, 63, 2888, 59, 2996, 566, 288, 4280, 847, 413, 398, 291, 14, 5950, 275, 21813, 8, 5950, 12, 2435, 63, 2888, 9, 398, 291, 14, 1364, 275, 7591, 7506, 8, 5950, 29, 277, 14, 5950, 12, 6170, 29, 277, 9, 398, 291, 14, 4342, 275, 11243, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 5570, 275, 27829, 7506, 342, 267, 291, 14, 13979, 281, 275, 603, 1148, 281, 7506, 8, 13979, 281, 29, 13979, 281, 9, 267, 291, 14, 2802, 894, 275, 16527, 894, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 2802, 6717, 275, 16527, 6717, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 3885, 513, 275, 17507, 513, 7506, 8, 1018, 29, 277, 9, 2378, 347, 664, 63, 2302, 63, 26818, 8, 277, 304, 267, 408, 1002, 769, 402, 9022, 21149, 781, 883, 2429, 624, 267, 27471, 275, 359, 66, 14, 2302, 63, 26818, 367, 330, 315, 291, 14, 7765, 61, 267, 2058, 275, 1134, 75, 7351, 14, 362, 63, 452, 8, 25513, 9, 267, 5108, 63, 26818, 275, 7975, 14, 4429, 2031, 2604, 9, 267, 372, 3355, 8, 2302, 63, 26818, 9, 339, 5108, 63, 26818, 275, 5906, 63, 1829, 8, 362, 63, 2302, 63, 26818, 9, 272, 408, 272, 2508, 5906, 447, 413, 14, 16, 267, 3645, 520, 5247, 1705, 362, 63, 2302, 63, 26818, 64, 3140, 14, 272, 408, 339, 347, 664, 63, 1023, 8, 277, 304, 267, 408, 1002, 1015, 402, 314, 603, 411, 344, 89, 6170, 3261, 624, 267, 372, 1015, 316, 14, 362, 63, 1023, 342, 339, 1015, 275, 5906, 63, 1829, 8, 362, 63, 1023, 9, 272, 408, 272, 2508, 5906, 447, 413, 14, 16, 267, 3645, 520, 5247, 1705, 362, 63, 1023, 64, 3140, 14, 272, 408, 339, 347, 13075, 63, 500, 63, 1618, 63, 1745, 8, 277, 304, 267, 291, 14, 2802, 894, 423, 265, 63, 500, 63, 1618, 63, 3885, 342, 339, 347, 2547, 63, 2489, 8, 277, 12, 5108, 304, 267, 291, 14, 2802, 894, 423, 265, 63, 1745, 63, 2489, 8, 2302, 9, 339, 347, 1174, 63, 2489, 8, 277, 12, 2269, 63, 929, 12, 892, 63, 929, 12, 1347, 63, 929, 304, 267, 327, 5787, 26, 961, 365, 282, 7937, 5325, 367, 4976, 327, 8001, 1830, 781, 3618, 367, 282, 1655, 267, 327, 19860, 8744, 543, 314, 4514, 402, 4976, 327, 5533, 14, 3979, 314, 267, 327, 428, 555, 3338, 5232, 1526, 365, 14669, 12, 314, 428, 555, 3338, 4865, 691, 5589, 10491, 267, 327, 5232, 894, 12, 1325, 333, 411, 344, 89, 14, 1018 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 12, 2649, 63, 5955, 199, 199, 646, 5055, 199, 646, 7975, 199, 646, 2050, 199, 199, 646, 1134, 75, 7351, 199, 199, 504, 333, 411, 344, 89, 492, 10491, 12, 4865, 12, 13667, 281, 12, 2435, 199, 504, 333, 411, 344, 89, 14, 8130, 492, 16527, 894, 2223, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 1364, 492, 7591, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 5570, 492, 27829, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 4342, 492, 11243, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 9799, 492, 11672, 10464, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 13979, 281, 492, 603, 1148, 281, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 2802, 894, 492, 16527, 894, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 2802, 6717, 492, 16527, 6717, 7506, 199, 504, 333, 411, 344, 89, 14, 1018, 14, 3885, 513, 492, 17507, 513, 7506, 199, 504, 333, 411, 344, 89, 14, 4672, 492, 1015, 316, 199, 504, 333, 411, 344, 89, 14, 4672, 14, 15383, 492, 5906, 63, 1829, 421, 199, 5021, 63, 354, 275, 2400, 282, 26, 282, 14, 5021, 63, 1121, 14, 5021, 63, 533, 855, 354, 363, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 11672, 8, 267, 1134, 75, 7351, 14, 4436, 316, 12258, 12, 10491, 14, 15484, 10464, 12, 4865, 14, 8447, 10464, 12, 267, 13667, 281, 14, 18854, 281, 10464, 304, 339, 3555, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 7424, 7506, 64, 624, 339, 7994, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 12114, 7506, 64, 624, 339, 13667, 281, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 18854, 281, 7506, 64, 624, 339, 5232, 894, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 9651, 894, 7506, 64, 624, 339, 5232, 6717, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 9651, 6717, 7506, 64, 624, 339, 4426, 513, 275, 488, 272, 408, 2493, 1256, 402, 520, 533, 6054, 77, 411, 344, 89, 14, 1018, 14, 7927, 513, 7506, 64, 624, 339, 2435, 275, 488, 272, 408, 1918, 2435, 7614, 14, 1626, 1256, 402, 272, 520, 533, 1705, 77, 411, 344, 89, 14, 1018, 14, 3167, 7506, 17105, 339, 347, 636, 826, 721, 277, 12, 10491, 29, 403, 12, 1101, 29, 403, 12, 13667, 281, 29, 403, 12, 14745, 29, 403, 12, 4865, 63, 2888, 17894, 398, 1613, 8, 5402, 12, 291, 2843, 826, 4533, 398, 291, 14, 8130, 275, 10491, 267, 291, 423, 888, 275, 1101, 398, 291, 14, 7765, 275, 10257, 3198, 8, 7765, 9, 398, 327, 437, 4865, 1443, 2597, 506, 282, 2435, 12, 880, 781, 1104, 340, 314, 4865, 267, 327, 21592, 314, 2435, 1021, 436, 5666, 652, 370, 314, 2435, 267, 327, 1021, 769, 340, 652, 1630, 267, 8500, 275, 942, 267, 2435, 63, 2888, 275, 942, 267, 4280, 275, 378, 267, 367, 330, 315, 14745, 26, 288, 340, 334, 2996, 665, 822, 8, 4620, 63, 2888, 9, 436, 11602, 8, 4620, 63, 2888, 59, 2996, 467, 2435, 14, 3167, 2298, 355, 8500, 14, 740, 8, 66, 9, 355, 2435, 63, 2888, 14, 740, 8, 4620, 63, 2888, 59, 2996, 566, 288, 4280, 847, 413, 398, 291, 14, 5950, 275, 21813, 8, 5950, 12, 2435, 63, 2888, 9, 398, 291, 14, 1364, 275, 7591, 7506, 8, 5950, 29, 277, 14, 5950, 12, 6170, 29, 277, 9, 398, 291, 14, 4342, 275, 11243, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 5570, 275, 27829, 7506, 342, 267, 291, 14, 13979, 281, 275, 603, 1148, 281, 7506, 8, 13979, 281, 29, 13979, 281, 9, 267, 291, 14, 2802, 894, 275, 16527, 894, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 2802, 6717, 275, 16527, 6717, 7506, 8, 7765, 29, 277, 14, 7765, 12, 6170, 29, 277, 9, 267, 291, 14, 3885, 513, 275, 17507, 513, 7506, 8, 1018, 29, 277, 9, 2378, 347, 664, 63, 2302, 63, 26818, 8, 277, 304, 267, 408, 1002, 769, 402, 9022, 21149, 781, 883, 2429, 624, 267, 27471, 275, 359, 66, 14, 2302, 63, 26818, 367, 330, 315, 291, 14, 7765, 61, 267, 2058, 275, 1134, 75, 7351, 14, 362, 63, 452, 8, 25513, 9, 267, 5108, 63, 26818, 275, 7975, 14, 4429, 2031, 2604, 9, 267, 372, 3355, 8, 2302, 63, 26818, 9, 339, 5108, 63, 26818, 275, 5906, 63, 1829, 8, 362, 63, 2302, 63, 26818, 9, 272, 408, 272, 2508, 5906, 447, 413, 14, 16, 267, 3645, 520, 5247, 1705, 362, 63, 2302, 63, 26818, 64, 3140, 14, 272, 408, 339, 347, 664, 63, 1023, 8, 277, 304, 267, 408, 1002, 1015, 402, 314, 603, 411, 344, 89, 6170, 3261, 624, 267, 372, 1015, 316, 14, 362, 63, 1023, 342, 339, 1015, 275, 5906, 63, 1829, 8, 362, 63, 1023, 9, 272, 408, 272, 2508, 5906, 447, 413, 14, 16, 267, 3645, 520, 5247, 1705, 362, 63, 1023, 64, 3140, 14, 272, 408, 339, 347, 13075, 63, 500, 63, 1618, 63, 1745, 8, 277, 304, 267, 291, 14, 2802, 894, 423, 265, 63, 500, 63, 1618, 63, 3885, 342, 339, 347, 2547, 63, 2489, 8, 277, 12, 5108, 304, 267, 291, 14, 2802, 894, 423, 265, 63, 1745, 63, 2489, 8, 2302, 9, 339, 347, 1174, 63, 2489, 8, 277, 12, 2269, 63, 929, 12, 892, 63, 929, 12, 1347, 63, 929, 304, 267, 327, 5787, 26, 961, 365, 282, 7937, 5325, 367, 4976, 327, 8001, 1830, 781, 3618, 367, 282, 1655, 267, 327, 19860, 8744, 543, 314, 4514, 402, 4976, 327, 5533, 14, 3979, 314, 267, 327, 428, 555, 3338, 5232, 1526, 365, 14669, 12, 314, 428, 555, 3338, 4865, 691, 5589, 10491, 267, 327, 5232, 894, 12, 1325, 333, 411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, 1, 1, 1, 1, 1, 1, 1 ]
mvo5/snapcraft
snapcraft/internal/steps.py
3
3949
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- # # Copyright (C) 2018 Canonical Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from typing import List from snapcraft.internal import errors class Step: def __init__(self, name: str, clean_if_dirty: bool) -> None: self.name = name self.clean_if_dirty = clean_if_dirty self.__order = None # type: int @property def _order(self) -> int: if self.__order is None: try: self.__order = STEPS.index(self) except ValueError: raise errors.InvalidStepError(self.name) return self.__order def previous_step(self) -> "Step": if self._order > 0: return STEPS[self._order - 1] else: return None def next_step(self) -> "Step": try: return STEPS[self._order + 1] except IndexError: return None def previous_steps(self) -> List["Step"]: return STEPS[: self._order] def next_steps(self) -> List["Step"]: return STEPS[self._order + 1 :] def __lt__(self, other) -> bool: if type(other) is type(self): return self._order < other._order return NotImplemented def __le__(self, other) -> bool: if type(other) is type(self): return self._order <= other._order return NotImplemented def __eq__(self, other) -> bool: if type(other) is type(self): return self.name == other.name return NotImplemented def __gt__(self, other) -> bool: if type(other) is type(self): return self._order > other._order return NotImplemented def __ge__(self, other) -> bool: if type(other) is type(self): return self._order >= other._order return NotImplemented def __hash__(self): return hash(self.name) def __repr__(self): return "Step({!r})".format(self.name) # Step names and order are now maintained in a single place: right here. If # another step is needed, add it here, and insert it into STEPS in the proper # order. PULL = Step("pull", False) BUILD = Step("build", False) STAGE = Step("stage", True) PRIME = Step("prime", True) STEPS = [PULL, BUILD, STAGE, PRIME] def next_step(step): """Get the next step of the lifecycle :param Step step: The current step. If None, the next step is the first step in the lifecycle. :return: The next step in the lifecycle :rtype: Step """ if step: return step.next_step() else: return STEPS[0] def get_step_by_name(step_name): """Get the lifecycle step that has the given name. :param str step_name: Name of the step in question. :return: The Step in the lifecycle that has the given name. :rtype: Step :raises: errors.InvalidStepError if there is no step with the given name. """ if step_name: for step in STEPS: if step.name == step_name: return step raise errors.InvalidStepError(step_name) else: return STEPS[0] def get_dependency_prerequisite_step(step): if step <= STAGE: return STAGE else: return step def dirty_step_if_dependency_changes(changed_step): if changed_step <= STAGE: return STEPS[0] else: return changed_step
gpl-3.0
[ 3, 1882, 4900, 26, 4718, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 5174, 13, 2063, 26, 20, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 6855, 7174, 12126, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 504, 14090, 492, 3820, 199, 199, 504, 13639, 32342, 14, 4672, 492, 2552, 421, 199, 533, 13382, 26, 272, 347, 636, 826, 721, 277, 12, 536, 26, 620, 12, 3633, 63, 692, 63, 8799, 26, 2155, 9, 1035, 488, 26, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3118, 63, 692, 63, 8799, 275, 3633, 63, 692, 63, 8799, 267, 291, 855, 1648, 275, 488, 221, 327, 730, 26, 1109, 339, 768, 1829, 272, 347, 485, 1648, 8, 277, 9, 1035, 1109, 26, 267, 340, 291, 855, 1648, 365, 488, 26, 288, 862, 26, 355, 291, 855, 1648, 275, 428, 3727, 5067, 14, 1080, 8, 277, 9, 288, 871, 1722, 26, 355, 746, 2552, 14, 3364, 7801, 547, 8, 277, 14, 354, 9, 267, 372, 291, 855, 1648, 339, 347, 4136, 63, 2926, 8, 277, 9, 1035, 298, 7801, 582, 267, 340, 291, 423, 1648, 690, 378, 26, 288, 372, 428, 3727, 5067, 59, 277, 423, 1648, 446, 413, 61, 267, 587, 26, 288, 372, 488, 339, 347, 2163, 63, 2926, 8, 277, 9, 1035, 298, 7801, 582, 267, 862, 26, 288, 372, 428, 3727, 5067, 59, 277, 423, 1648, 435, 413, 61, 267, 871, 7888, 26, 288, 372, 488, 339, 347, 4136, 63, 5895, 8, 277, 9, 1035, 3820, 905, 7801, 6229, 267, 372, 428, 3727, 5067, 1491, 291, 423, 1648, 61, 339, 347, 2163, 63, 5895, 8, 277, 9, 1035, 3820, 905, 7801, 6229, 267, 372, 428, 3727, 5067, 59, 277, 423, 1648, 435, 413, 12228, 339, 347, 636, 4116, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 665, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 274, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 2695, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 4077, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 14, 354, 508, 1163, 14, 354, 398, 372, 3784, 339, 347, 636, 3308, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 690, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 303, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 2356, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 14, 354, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 7801, 2561, 1, 82, 25974, 908, 8, 277, 14, 354, 9, 421, 199, 3, 13382, 1561, 436, 1865, 787, 3063, 26391, 315, 282, 2849, 4192, 26, 2451, 2348, 14, 982, 199, 3, 4573, 3650, 365, 4346, 12, 1050, 652, 2348, 12, 436, 5518, 652, 1901, 428, 3727, 5067, 315, 314, 5576, 199, 3, 1865, 14, 199, 48, 3785, 275, 13382, 480, 9302, 401, 756, 9, 199, 8248, 275, 13382, 480, 1506, 401, 756, 9, 199, 840, 2962, 275, 13382, 480, 8614, 401, 715, 9, 199, 3311, 3465, 275, 13382, 480, 12446, 401, 715, 9, 199, 199, 840, 25711, 275, 359, 48, 3785, 12, 22974, 12, 4384, 2962, 12, 12218, 3465, 61, 421, 199, 318, 2163, 63, 2926, 8, 2926, 304, 272, 408, 1002, 314, 2163, 3650, 402, 314, 15451, 7612, 339, 520, 635, 13382, 3650, 26, 710, 1453, 3650, 14, 982, 488, 12, 314, 2163, 3650, 365, 314, 1642, 1993, 3650, 315, 314, 15451, 7612, 14, 272, 520, 1107, 26, 710, 2163, 3650, 315, 314, 15451, 7612, 272, 520, 4500, 26, 13382, 272, 408, 272, 340, 3650, 26, 267, 372, 3650, 14, 2184, 63, 2926, 342, 272, 587, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 421, 199, 318, 664, 63, 2926, 63, 991, 63, 354, 8, 2926, 63, 354, 304, 272, 408, 1002, 314, 15451, 7612, 3650, 626, 965, 314, 1627, 536, 14, 339, 520, 635, 620, 3650, 63, 354, 26, 2812, 402, 314, 3650, 315, 7894, 14, 272, 520, 1107, 26, 710, 13382, 315, 314, 15451, 7612, 626, 965, 314, 1627, 536, 14, 272, 520, 4500, 26, 13382, 272, 520, 3536, 26, 2552, 14, 3364, 7801, 547, 340, 2337, 365, 949, 3650, 543, 314, 1627, 536, 14, 272, 408, 272, 340, 3650, 63, 354, 26, 267, 367, 3650, 315, 428, 3727, 5067, 26, 288, 340, 3650, 14, 354, 508, 3650, 63, 354, 26, 355, 372, 3650, 267, 746, 2552, 14, 3364, 7801, 547, 8, 2926, 63, 354, 9, 272, 587, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 421, 199, 318, 664, 63, 8575, 63, 657, 21763, 63, 2926, 8, 2926, 304, 272, 340, 3650, 2695, 4384, 2962, 26, 267, 372, 4384, 2962, 272, 587, 26, 267, 372, 3650, 421, 199, 318, 14650, 63, 2926, 63, 692, 63, 8575, 63, 6627, 8, 2489, 63, 2926, 304, 272, 340, 2896, 63, 2926, 2695, 4384, 2962, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 272, 587, 26, 267, 372, 2896, 63, 2926, 199, 32768 ]
[ 1882, 4900, 26, 4718, 27, 4363, 13, 8741, 13, 632, 26, 20613, 27, 5174, 13, 2063, 26, 20, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 14894, 6855, 7174, 12126, 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, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 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, 504, 14090, 492, 3820, 199, 199, 504, 13639, 32342, 14, 4672, 492, 2552, 421, 199, 533, 13382, 26, 272, 347, 636, 826, 721, 277, 12, 536, 26, 620, 12, 3633, 63, 692, 63, 8799, 26, 2155, 9, 1035, 488, 26, 267, 291, 14, 354, 275, 536, 267, 291, 14, 3118, 63, 692, 63, 8799, 275, 3633, 63, 692, 63, 8799, 267, 291, 855, 1648, 275, 488, 221, 327, 730, 26, 1109, 339, 768, 1829, 272, 347, 485, 1648, 8, 277, 9, 1035, 1109, 26, 267, 340, 291, 855, 1648, 365, 488, 26, 288, 862, 26, 355, 291, 855, 1648, 275, 428, 3727, 5067, 14, 1080, 8, 277, 9, 288, 871, 1722, 26, 355, 746, 2552, 14, 3364, 7801, 547, 8, 277, 14, 354, 9, 267, 372, 291, 855, 1648, 339, 347, 4136, 63, 2926, 8, 277, 9, 1035, 298, 7801, 582, 267, 340, 291, 423, 1648, 690, 378, 26, 288, 372, 428, 3727, 5067, 59, 277, 423, 1648, 446, 413, 61, 267, 587, 26, 288, 372, 488, 339, 347, 2163, 63, 2926, 8, 277, 9, 1035, 298, 7801, 582, 267, 862, 26, 288, 372, 428, 3727, 5067, 59, 277, 423, 1648, 435, 413, 61, 267, 871, 7888, 26, 288, 372, 488, 339, 347, 4136, 63, 5895, 8, 277, 9, 1035, 3820, 905, 7801, 6229, 267, 372, 428, 3727, 5067, 1491, 291, 423, 1648, 61, 339, 347, 2163, 63, 5895, 8, 277, 9, 1035, 3820, 905, 7801, 6229, 267, 372, 428, 3727, 5067, 59, 277, 423, 1648, 435, 413, 12228, 339, 347, 636, 4116, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 665, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 274, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 2695, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 4077, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 14, 354, 508, 1163, 14, 354, 398, 372, 3784, 339, 347, 636, 3308, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 690, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 303, 721, 277, 12, 1163, 9, 1035, 2155, 26, 267, 340, 730, 8, 1848, 9, 365, 730, 8, 277, 304, 288, 372, 291, 423, 1648, 2356, 1163, 423, 1648, 398, 372, 3784, 339, 347, 636, 2227, 721, 277, 304, 267, 372, 2631, 8, 277, 14, 354, 9, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 298, 7801, 2561, 1, 82, 25974, 908, 8, 277, 14, 354, 9, 421, 199, 3, 13382, 1561, 436, 1865, 787, 3063, 26391, 315, 282, 2849, 4192, 26, 2451, 2348, 14, 982, 199, 3, 4573, 3650, 365, 4346, 12, 1050, 652, 2348, 12, 436, 5518, 652, 1901, 428, 3727, 5067, 315, 314, 5576, 199, 3, 1865, 14, 199, 48, 3785, 275, 13382, 480, 9302, 401, 756, 9, 199, 8248, 275, 13382, 480, 1506, 401, 756, 9, 199, 840, 2962, 275, 13382, 480, 8614, 401, 715, 9, 199, 3311, 3465, 275, 13382, 480, 12446, 401, 715, 9, 199, 199, 840, 25711, 275, 359, 48, 3785, 12, 22974, 12, 4384, 2962, 12, 12218, 3465, 61, 421, 199, 318, 2163, 63, 2926, 8, 2926, 304, 272, 408, 1002, 314, 2163, 3650, 402, 314, 15451, 7612, 339, 520, 635, 13382, 3650, 26, 710, 1453, 3650, 14, 982, 488, 12, 314, 2163, 3650, 365, 314, 1642, 1993, 3650, 315, 314, 15451, 7612, 14, 272, 520, 1107, 26, 710, 2163, 3650, 315, 314, 15451, 7612, 272, 520, 4500, 26, 13382, 272, 408, 272, 340, 3650, 26, 267, 372, 3650, 14, 2184, 63, 2926, 342, 272, 587, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 421, 199, 318, 664, 63, 2926, 63, 991, 63, 354, 8, 2926, 63, 354, 304, 272, 408, 1002, 314, 15451, 7612, 3650, 626, 965, 314, 1627, 536, 14, 339, 520, 635, 620, 3650, 63, 354, 26, 2812, 402, 314, 3650, 315, 7894, 14, 272, 520, 1107, 26, 710, 13382, 315, 314, 15451, 7612, 626, 965, 314, 1627, 536, 14, 272, 520, 4500, 26, 13382, 272, 520, 3536, 26, 2552, 14, 3364, 7801, 547, 340, 2337, 365, 949, 3650, 543, 314, 1627, 536, 14, 272, 408, 272, 340, 3650, 63, 354, 26, 267, 367, 3650, 315, 428, 3727, 5067, 26, 288, 340, 3650, 14, 354, 508, 3650, 63, 354, 26, 355, 372, 3650, 267, 746, 2552, 14, 3364, 7801, 547, 8, 2926, 63, 354, 9, 272, 587, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 421, 199, 318, 664, 63, 8575, 63, 657, 21763, 63, 2926, 8, 2926, 304, 272, 340, 3650, 2695, 4384, 2962, 26, 267, 372, 4384, 2962, 272, 587, 26, 267, 372, 3650, 421, 199, 318, 14650, 63, 2926, 63, 692, 63, 8575, 63, 6627, 8, 2489, 63, 2926, 304, 272, 340, 2896, 63, 2926, 2695, 4384, 2962, 26, 267, 372, 428, 3727, 5067, 59, 16, 61, 272, 587, 26, 267, 372, 2896, 63, 2926, 199, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
mmechelke/bayesian_xfel
bxfel/core/structure_factor.py
1
18608
import numpy as np import scipy import re import os import hashlib import csb from csb.bio.io.wwpdb import StructureParser def chunks(l, n): """ Yield successive n-sized chunks from l. """ for i in xrange(0, len(l), n): yield l[i:i+n] class ScatteringFactor(object): """ Cacluates the density in reciprocal space as F(s) = sum_m f_m(s) exp(-B_m s**2 / 4) exp(i*2pi*s*r) where f_m(s) is approximated by four Gaussian distributions and exp(-B_m s**2 / 4) are the thermal fluctuations g_m(s) = f_m(s) * exp(-B_m s**2 / 4) are precomputed """ def __init__(self, structure=None): if structure is None: self._atoms = list() self._bfactor = list() self._seq = list() self._elements = list() else: self._structure = structure # For now only non hydrogen atoms # TODO use hydrogens as well self._atoms = [] for chain in structure: for residue in structure[chain]: for atom in residue: a = residue[atom] if not a.name.startswith("H"): self._atoms.append(residue[atom]) self._seq = [] self._bfactor = [] self._elements = [] for atom in self._atoms: self._seq.append(atom.element.name) self._elements.append(atom.element.name) if atom._bfactor is None: self._bfactor.append(1.) else: self._bfactor.append(atom._bfactor) self._seq = np.array(self._seq) self._elements = set(self._elements) self._bfactor = np.clip(self._bfactor, 1., 100.) self._atom_type_params = {} self._read_sf(fn=os.path.expanduser("~/projects/xfel/py/xfel/core/atomsf.lib")) @classmethod def from_isd(cls, universe): obj = cls() atoms = universe.atoms for atom in atoms: element = str(atom.properties['element'].name) obj._elements.append(element) obj._atoms.append(atom) obj._seq.append(element) try: obj._bfactor.append(max(1.,atom.properties['bfactor'])) except KeyError: obj._bfactor.append(1.) obj._seq = np.array(obj._seq) obj._bfactor = np.array(obj._bfactor) obj._elements = set(obj._elements) obj._bfactor = np.clip(obj._bfactor, 1., 100.) return obj def _read_sf(self, fn): """ Reads the coefficients for the analystical approximation to scattering factors from ccp4 database """ float_pattern = '[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?' atom_pattern = '[A-Za-z]' atom_pattern = '[A-Za-z0-9-+]+' line_pattern = ("({0})\s+({1})" "\s+({1})\s+({1})" "\s+({1})\s+({1})" "\s+({1})\s+({1})" "\s+({1})\s+({1})").format(atom_pattern,float_pattern) regex = re.compile(line_pattern) with open(fn) as file_handle: for line in file_handle: if line.startswith("#"): continue m = regex.match(line) atom_name = m.groups()[0] a1, a2, a3, a4 = m.groups()[1], m.groups()[3], m.groups()[5], m.groups()[7] b1, b2, b3, b4 = m.groups()[2], m.groups()[4], m.groups()[6], m.groups()[8] c = m.groups()[9] a = np.array([a1,a2,a3,a4],np.double) b = np.array([b1,b2,b3,b4],np.double) self._atom_type_params[atom_name] = (a,b,float(c)) def _calculate_gm(self, hkl): """ calculates the the product of scattering factor and debye-waller factors """ f = np.zeros((len(self._atoms), hkl.shape[0])) seq = self._seq bfactor = self._bfactor s_tols = 0.25 * (hkl**2).sum(-1) for atom_type in self._elements: a,b,c = self._atom_type_params[atom_type] indices = np.where(seq==atom_type)[0] fx = c + np.dot(np.exp(np.outer(-s_tols,b)),a) f[indices,:] = fx[:] f *= np.exp(np.outer(-bfactor,s_tols)) return f def _calculate_gm_grad(self, hkl): """ calculate the gradien of the scattering factor and debye-waller factor """ seq = np.array([a.element.name for a in self._atoms]) f = np.zeros((len(self._atoms), hkl.shape[0])) dfg = np.zeros((len(self._atoms), hkl.shape[0], 3)) bfactors = np.array([a.bfactor for a in self._atoms]) bfactors = np.clip(bfactors, 1., 100.) s_tols = 0.25 * (hkl**2).sum(-1) for atom_type in self._elements: a,b,c = self._atom_type_params[atom_type] indices = np.where(seq==atom_type)[0] bfactor = bfactors[indices] g = np.exp(np.outer(-s_tols,b)) sf = np.dot(g, a) + c gsf = np.sum(g * a[np.newaxis,:] * b[np.newaxis,:] * -0.5, -1) dwf = np.exp(-np.outer(bfactor, s_tols)) gdwf = dwf * (bfactor * - 0.5)[:,np.newaxis] grad = sf * gdwf + gsf * dwf f[indices,:] = dwf * sf dfg[indices,:,:] = grad[:,:,np.newaxis] * hkl return dfg, f def _calculate_scattering_factors(self, hkl): """ creates an approximation of the density in reciprocal space by four gaussians returns the scattering vectors """ seq = self._seq bfactor = self._bfactor f = np.zeros((len(self._atoms), hkl.shape[0])) s_tols = 0.25 * (hkl**2).sum(-1) for atom_type in self._elements: a,b,c = self._atom_type_params[atom_type] indices = np.where(seq==atom_type)[0] fx = c + np.dot(np.exp(np.outer(-s_tols,b)),a) f[indices,:] = fx[:] return f def _calculate_debyewaller_factors(self, hkl): """ """ b = np.array(self._bfactor) s_tols = 0.25 * (hkl**2).sum(-1) t = np.exp(np.outer(-b,s_tols)) return t def grad_s(self, X, hkl): """ Gradient with respect to the reciprocal space coordinates @param X: atomic positions @param hkl: reciprocal space positions """ seq = np.array([atom.element.name for atom in self._atoms]) bfactor = np.array([atom.bfactor for atom in self._atoms]) bfactor = np.clip(bfactor, 1., 100.) s_tols = 0.25 * (hkl**2).sum(-1) dw_factors = np.exp(np.outer(-bfactor, s_tols)) def grad_hkl(self, X, hkl): seq = self._seq bfactor = self._bfactor bfactor = np.clip(bfactor, 1., 100.) dg = np.zeros((len(self._atoms), hkl.shape[0], hkl.shape[1])) g = np.zeros((len(self._atoms), hkl.shape[0])) s_tols = 0.25 * (hkl**2).sum(-1) dw_factors = np.exp(np.outer(-bfactor, s_tols)) ddw_factors = bfactor[:,np.newaxis] * dw_factors for atom_type in self._elements: a,b,c = self._atom_type_params[atom_type] indices = np.where(seq==atom_type)[0] inner_exp = np.exp(np.outer(-s_tols,b)) sf = np.dot(inner_exp, a) + c dsf = np.dot(inner_exp, a*b) gx = dsf * dw_factors[indices] + sf * ddw_factors[indices] g[indices,:] = sf[:] * dw_factors[indices] a = np.einsum('ab,bc->abc',gx, -0.5*hkl) dg[indices,:,:] = a phase = np.dot((2 * np.pi * X),hkl.T) fx= np.sum(g * np.exp(1j * phase),0) g2 = np.einsum('ba,bc->bac',g , 2 * np.pi * 1j *X) dfx = np.einsum("abc,ab->bc",dg + g2,np.exp(1j * phase)) return dfx, fx def calculate_structure_factors(self, X, hkl): """ TODO do this calculation in chunks to save space """ F = np.zeros(hkl.shape[0], dtype=np.complex128) lim = hkl.shape[0] step = 512 for i in range(0,lim,step): _hkl = hkl[i:i+step] f = self._calculate_scattering_factors(_hkl) f *= self._calculate_debyewaller_factors(_hkl) phase = np.dot((2 * np.pi * X),_hkl.T) F[i:i+step] = np.sum(f * np.exp(1j * phase),0) return F def calculate_structure_factor_gradient(self, X, hkl): """ calculates the gradient of the fourier density with respect to the atomic coordinates """ G = np.zeros(hkl.shape, dtype=np.complex128) lim = hkl.shape[0] F = np.zeros(hkl.shape[0], dtype=np.complex128) step = 512 for i in range(0, lim, step): _hkl = hkl[i:i+step] dfg, f = self._calculate_gm_grad(_hkl) phase = np.exp(1j * np.dot((2 * np.pi * X), _hkl.T)) gphase = phase[:, :, np.newaxis] *\ 1j * 2 * np.pi * X[:, np.newaxis, :] grad = dfg * phase[:, :, np.newaxis] grad += f[:, :, np.newaxis] * gphase F[i: i+step] = np.sum(f * phase, 0) G[i: i+step, :] = np.sum(grad, 0) return G, F def calculate_structure_factor_gradient2(self, X): """ calculates the gradient of the fourier density with respect to the atomic coordinates """ g_m = self._calculate_scattering_factors(hkl) g_m *= self._calculate_debyewaller_factors(hkl) phase = np.dot((2 * np.pi * X),self._hkl.T) fx = (g_m *1j * 2 * np.pi * np.exp(1j * phase)) dF_dx = np.array([np.multiply.outer(s,fx_s) for s,fx_s in zip(fx.T,self._hkl)]) return dF_dx def calculate_intensity_gradient(self, X): """ calculates the gradient of the intensity with respect to the atomic coordinates dI/dx """ g_m = self._calculate_scattering_factors(self._hkl) g_m *= self._calculate_debyewaller_factors(self._hkl) phase = np.dot((2 * np.pi * X),self._hkl.T) F = np.sum(g_m * np.exp(1j * phase),0) fx = (g_m *1j * 2 * np.pi * np.exp(1j * phase)) dF_dx = np.array([np.multiply.outer(s,fx_s) for s,fx_s in zip(fx.T,self._hkl)]) dI_dx = np.conj(F[:,np.newaxis,np.newaxis]) * dF_dx + F[:,np.newaxis,np.newaxis] * np.conj(dF_dx) return dI_dx class Correlations(object): def __init__(self, angles, nbins): self._bin_angles(angles, nbins) def _bin_angles(self, angles, nbins): pass def calculate_from_density(self, rho): pass class OnePhotonCorrelations(Correlations): def _bin_angles(self, angles, nbins): d = np.sqrt(np.sum(angles**2,-1)) lower = d.min() upper = d.max() axes = np.linspace(lower, upper, nbins) indices = np.argsort(d) bins = [[] for x in xrange(nbins)] j = 0 for i in range(0,axes.shape[0]): right_edge = axes[i] print right_edge, i while d[indices[j]] < right_edge: bins[i-1].append(indices[j]) j += 1 bins[-1] = indices[j:].tolist() self._axes = axes self._bins = bins def calculate_from_density(self, rho): I = np.asarray([np.sum(rho.take(bin)) for bin in self._bins]) return I class CachedScatteringFactor(ScatteringFactor): def __init__(self, structure): super(CachedScatteringFactor,self).__init__(structure) self._f = None def calculate_structure_factors(self, X, hkl): if self._f is None: print "calc f" self._f = self._calculate_scattering_factors(hkl) self._f *= self._calculate_debyewaller_factors(hkl) else: print "using cached f" phase = np.dot((-2 * np.pi * X),hkl.T) F = np.sum(self._f * np.exp(1j * phase),0) return F class SphericalSection(object): def get(self, n_points=20, radius=1.0, polar_min=0., polar_max=np.pi, azimut_min=0., azimut_max=2*np.pi): theta = np.linspace(polar_min,polar_max, n_points) phi = np.linspace(azimut_min, azimut_max, n_points) x = np.outer(radius*np.sin(theta), np.cos(phi)) y = np.outer(radius*np.sin(theta), np.sin(phi)) z = np.outer(radius*np.cos(theta), np.ones(n_points)) return [x,y,z] class EwaldSphereProjection(object): def get_indices(self, wavelength, x,y,z): """ projects dectector points onto an Ewald Sphere x, y, z are the pixel coordinates x, y, z are all M x N matrices, where M x N is the detector size. It is assumed that the detector is perpendicular to the Z-axis """ d = np.sqrt(x**2 + y**2 + z**2) h = 1/wavelength * (x/d) k = 1/wavelength * (y/d) l = 1/wavelength * (z/d) return h,k,l def project(self, structure_factor, angle): pass if __name__ == "__main__": import matplotlib matplotlib.interactive(True) import time import os import seaborn as sns from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import pylab from pylab import * from csb.bio.io.wwpdb import StructureParser from csb.bio.io.wwpdb import get from xfel.core.density import Density #structure = get("1L2Y") #structure = StructureParser(os.path.expanduser("~/data/pdb/caffeine2.pdb")).parse() #fn = os.path.expanduser("~/gsh.pdb") structure = StructureParser(os.path.expanduser("~/projects/xfel/data/GTT_short.pdb")).parse() x = np.linspace(-1.,1.,11) h, k, l = np.meshgrid(x,x,x) hkl = np.vstack([item.ravel() for item in [h,k,l]]).T hkl = np.ascontiguousarray(hkl) bf = np.random.random() def bfactors(hkl, bf): return np.exp(-0.25 * bf * (hkl**2).sum(-1)) def bfactor_grad(hkl): return np.exp(-0.25 * bf * (hkl**2).sum(-1))[:,np.newaxis] * -0.5 * hkl * bf a = np.random.random(4,) b = np.random.random(4,) c = 0.3 def sf(hkl,a,b,c): s_tols = -0.25 * (hkl**2).sum(-1) inner_exp = np.exp(np.outer(-s_tols,b)) sf = np.dot(inner_exp, a) + c return sf def sf_grad(hkl, a, b, c): s_tols = -0.25 * (hkl**2).sum(-1) sf = np.exp(np.outer(-s_tols,b)) * a[np.newaxis,:] * b[np.newaxis,:] * 0.5 return sf.sum(-1)[:,np.newaxis] * hkl def gm(hkl, a, b, c, bf): s_tols = -0.25 * (hkl**2).sum(-1) inner_exp = np.exp(np.outer(-s_tols,b)) sf = np.dot(inner_exp, a) + c bf = np.exp(bf * s_tols) return sf * bf def gm_grad(hkl, a, b, c, bf): s_tols = -0.25 * (hkl**2).sum(-1) g = np.exp(np.outer(-s_tols,b)) sf = np.dot(g, a) + c gsf = np.sum(g * a[np.newaxis,:] * b[np.newaxis,:] * 0.5, -1) bb = np.exp(bf * s_tols) gb = bb * bf * - 0.5 grad = sf * gb + gsf * bb return grad[:,np.newaxis] * hkl sf = ScatteringFactor(structure) X = np.array([a.vector for a in sf._atoms]) X -= X.mean(0) if False: n = 10 X = X[:n] sf._seq = sf._seq[:n] sf._elements = ['N', 'C'] sf._atoms = sf._atoms[:n] sf._bfactor = sf._bfactor[:n] dgm, f1 = sf._calculate_gm_grad(hkl) f = sf._calculate_scattering_factors(hkl) f *= sf._calculate_debyewaller_factors(hkl) scatter(f.real.ravel(), f1.real.ravel()) dgm2 = dgm * 0.0 eps = 1e-7 for i in range(3): hkl[:, i] += eps fprime = sf._calculate_scattering_factors(hkl) fprime *= sf._calculate_debyewaller_factors(hkl) dgm2[:, :, i] = (fprime - f)/eps hkl[:, i] -= eps figure() scatter(dgm.real.ravel(), dgm2.real.ravel()) G, FF = sf.calculate_structure_factor_gradient(X, hkl) G2 = G * 0.0 F = sf.calculate_structure_factors(X, hkl) eps = 1e-7 for i in range(3): hkl[:,i] += eps G2[:,i] = (sf.calculate_structure_factors(X, hkl) - F)/eps hkl[:,i] -= eps figure() scatter(G.real.ravel(), G2.real.ravel()) scatter(G.imag.ravel(), G2.imag.ravel()) figure() scatter(F.real.ravel(), FF.real.ravel()) show() t0 = time.time() G, FF = sf.calculate_structure_factor_gradient(X, hkl) print "hkl gradient: {} \n".format(time.time() - t0) t0 = time.time() g = sf.grad_hkl(X, hkl) print "X gradient: {} \n".format(time.time() - t0) raise sf = ScatteringFactor(structure) sf._hkl = hkl X = np.array([a.vector for a in sf._atoms]) X -= X.mean(0) g,g2 = sf.grad_hkl(X, hkl) F = sf.calculate_structure_factors(X,hkl) gi= sf.calculate_intensity_gradient(X) raise F = F.reshape(h.shape) rho = np.fft.fftshift(np.abs(np.fft.ifftn(F,[250,250,250]))) grid = Density.from_voxels(np.abs(F)**2,1.) grid.write_gaussian(os.path.expanduser("~/mr.cube")) raise grid = Density.from_voxels(rho,1.) grid.write_gaussian(os.path.expanduser("~/mr2.cube")) raise if True: fig = pylab.figure() ax = fig.add_subplot(131) xi, yi= np.mgrid[0:500:1,0:500:1] ax.contour(xi,yi, rho.sum(0), 30) pylab.show() ax = fig.add_subplot(132) xi, yi= np.mgrid[0:500:1,0:500:1] ax.contour(xi,yi, rho.sum(1), 30) pylab.show() ax = fig.add_subplot(133) xi, yi= np.mgrid[0:500:1,0:500:1] ax.contour(xi,yi, rho.sum(2), 30) pylab.show() raise from mayavi import mlab xi, yi, zi = np.mgrid[0:500:1,0:500:1,0:500:1] obj = mlab.contour3d(rho, contours=10, transparent=True) mlab.show() from mayavi import mlab obj = mlab.contour3d(np.abs(F), contours=10, transparent=True) mlab.show() raise for ii in range(0,F.shape[0],25): fig = pylab.figure() ax = fig.add_subplot(111) xi, yi= np.mgrid[0:500:1,0:500:1] ax.contour(xi,yi,rho[ii,:,:], 30) pylab.show() I = np.abs(F)**2 fig = pylab.figure() ax = fig.add_subplot(111) nx, ny, nz = I.shape xi, yi= np.mgrid[0:nx:1,0:ny:1] ax.contour(xi,yi, I.sum(2), 15)
mit
[ 199, 646, 2680, 465, 980, 199, 646, 7026, 199, 646, 295, 199, 646, 747, 199, 199, 646, 8337, 199, 646, 7117, 66, 199, 199, 504, 7117, 66, 14, 17614, 14, 2308, 14, 978, 10511, 492, 21730, 2842, 421, 199, 318, 8291, 8, 76, 12, 302, 304, 272, 408, 23771, 27028, 3398, 302, 13, 15308, 8291, 687, 634, 14, 272, 408, 272, 367, 284, 315, 4945, 8, 16, 12, 822, 8, 76, 395, 302, 304, 267, 1995, 634, 59, 73, 26, 73, 11, 78, 61, 421, 199, 533, 428, 20569, 316, 12666, 8, 785, 304, 272, 408, 272, 8790, 1016, 2335, 314, 13650, 315, 295, 31846, 4601, 465, 339, 481, 8, 83, 9, 275, 3089, 63, 77, 289, 63, 77, 8, 83, 9, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 1437, 8, 73, 10, 18, 1038, 10, 83, 10, 82, 9, 339, 2382, 289, 63, 77, 8, 83, 9, 365, 14106, 12754, 701, 11648, 17131, 10208, 272, 436, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 787, 314, 23418, 2174, 2717, 918, 18012, 339, 486, 63, 77, 8, 83, 9, 275, 289, 63, 77, 8, 83, 9, 627, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 787, 876, 14378, 2378, 408, 339, 347, 636, 826, 721, 277, 12, 5523, 29, 403, 304, 267, 340, 5523, 365, 488, 26, 288, 291, 423, 11521, 275, 769, 342, 288, 291, 423, 66, 4778, 275, 769, 342, 288, 291, 423, 3610, 275, 769, 342, 288, 291, 423, 5527, 275, 769, 342, 267, 587, 26, 288, 291, 423, 6976, 275, 5523, 288, 327, 2104, 3063, 1454, 2222, 7188, 17264, 2268, 14503, 288, 327, 3254, 675, 7188, 17264, 18278, 465, 5521, 288, 291, 423, 11521, 275, 942, 288, 367, 6036, 315, 5523, 26, 355, 367, 23185, 310, 315, 5523, 59, 4429, 2189, 490, 367, 6222, 315, 23185, 310, 26, 717, 282, 275, 23185, 310, 59, 4188, 61, 717, 340, 440, 282, 14, 354, 14, 2460, 480, 40, 2349, 1169, 291, 423, 11521, 14, 740, 8, 19581, 310, 59, 4188, 566, 288, 291, 423, 3610, 275, 942, 288, 291, 423, 66, 4778, 275, 942, 288, 291, 423, 5527, 275, 942, 7846, 367, 6222, 315, 291, 423, 11521, 26, 355, 291, 423, 3610, 14, 740, 8, 4188, 14, 2108, 14, 354, 9, 355, 291, 423, 5527, 14, 740, 8, 4188, 14, 2108, 14, 354, 9, 2234, 340, 6222, 423, 66, 4778, 365, 488, 26, 490, 291, 423, 66, 4778, 14, 740, 8, 17, 4959, 355, 587, 26, 490, 291, 423, 66, 4778, 14, 740, 8, 4188, 423, 66, 4778, 9, 2151, 288, 291, 423, 3610, 275, 980, 14, 1144, 8, 277, 423, 3610, 9, 288, 291, 423, 5527, 275, 663, 8, 277, 423, 5527, 9, 288, 291, 423, 66, 4778, 275, 980, 14, 7548, 8, 277, 423, 66, 4778, 12, 413, 2020, 2948, 4959, 10631, 291, 423, 4188, 63, 466, 63, 1162, 221, 275, 1052, 267, 291, 423, 739, 63, 7646, 8, 2324, 29, 736, 14, 515, 14, 12131, 20793, 15, 6776, 15, 1949, 352, 15, 647, 15, 1949, 352, 15, 1018, 15, 4188, 7646, 14, 773, 2237, 339, 768, 3744, 272, 347, 687, 63, 374, 68, 8, 1886, 12, 15439, 2077, 304, 267, 1559, 275, 843, 342, 267, 14503, 275, 15439, 2077, 14, 11521, 398, 367, 6222, 315, 14503, 26, 288, 1819, 275, 620, 8, 4188, 14, 3282, 459, 2108, 2278, 354, 9, 288, 1559, 423, 5527, 14, 740, 8, 2108, 9, 288, 1559, 423, 11521, 14, 740, 8, 4188, 9, 288, 1559, 423, 3610, 14, 740, 8, 2108, 9, 288, 862, 26, 355, 1559, 423, 66, 4778, 14, 740, 8, 988, 8, 17, 2020, 4188, 14, 3282, 459, 66, 4778, 5156, 288, 871, 4067, 26, 355, 1559, 423, 66, 4778, 14, 740, 8, 17, 4959, 267, 1559, 423, 3610, 275, 980, 14, 1144, 8, 1113, 423, 3610, 9, 267, 1559, 423, 66, 4778, 275, 980, 14, 1144, 8, 1113, 423, 66, 4778, 9, 267, 1559, 423, 5527, 275, 663, 8, 1113, 423, 5527, 9, 267, 1559, 423, 66, 4778, 275, 980, 14, 7548, 8, 1113, 423, 66, 4778, 12, 413, 2020, 2948, 4959, 267, 372, 1559, 5493, 347, 485, 739, 63, 7646, 8, 277, 12, 4325, 304, 267, 408, 267, 26129, 314, 12343, 367, 314, 5909, 270, 2652, 22772, 267, 370, 28618, 316, 17704, 687, 286, 1850, 20, 3050, 267, 408, 267, 2069, 63, 3401, 275, 283, 27371, 21852, 16, 13, 25, 3672, 4537, 26736, 16, 13, 25, 2807, 25060, 20565, 1527, 6793, 21852, 16, 13, 25, 23763, 7, 267, 6222, 63, 3401, 275, 6730, 33, 13, 13163, 13, 90, 6616, 267, 6222, 63, 3401, 275, 6730, 33, 13, 13163, 13, 90, 16, 13, 25, 6793, 28012, 267, 1004, 63, 3401, 275, 1689, 2561, 16, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 3471, 908, 8, 4188, 63, 3401, 12, 1609, 63, 3401, 9, 398, 5163, 275, 295, 14, 2014, 8, 604, 63, 3401, 9, 7318, 543, 1551, 8, 2324, 9, 465, 570, 63, 2479, 26, 288, 367, 1004, 315, 570, 63, 2479, 26, 355, 340, 1004, 14, 2460, 10064, 2349, 490, 1980, 2234, 333, 275, 5163, 14, 1431, 8, 604, 9, 355, 6222, 63, 354, 275, 333, 14, 2634, 3430, 16, 61, 355, 282, 17, 12, 282, 18, 12, 282, 19, 12, 282, 20, 275, 333, 14, 2634, 3430, 17, 467, 333, 14, 2634, 3430, 19, 467, 333, 14, 2634, 3430, 21, 467, 333, 14, 2634, 3430, 23, 61, 355, 330, 17, 12, 330, 18, 12, 330, 19, 12, 330, 20, 275, 333, 14, 2634, 3430, 18, 467, 333, 14, 2634, 3430, 20, 467, 333, 14, 2634, 3430, 22, 467, 333, 14, 2634, 3430, 24, 61, 355, 286, 275, 333, 14, 2634, 3430, 25, 61, 2234, 282, 275, 980, 14, 1144, 779, 65, 17, 12, 65, 18, 12, 65, 19, 12, 65, 20, 467, 1590, 14, 3157, 9, 355, 330 ]
[ 646, 2680, 465, 980, 199, 646, 7026, 199, 646, 295, 199, 646, 747, 199, 199, 646, 8337, 199, 646, 7117, 66, 199, 199, 504, 7117, 66, 14, 17614, 14, 2308, 14, 978, 10511, 492, 21730, 2842, 421, 199, 318, 8291, 8, 76, 12, 302, 304, 272, 408, 23771, 27028, 3398, 302, 13, 15308, 8291, 687, 634, 14, 272, 408, 272, 367, 284, 315, 4945, 8, 16, 12, 822, 8, 76, 395, 302, 304, 267, 1995, 634, 59, 73, 26, 73, 11, 78, 61, 421, 199, 533, 428, 20569, 316, 12666, 8, 785, 304, 272, 408, 272, 8790, 1016, 2335, 314, 13650, 315, 295, 31846, 4601, 465, 339, 481, 8, 83, 9, 275, 3089, 63, 77, 289, 63, 77, 8, 83, 9, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 1437, 8, 73, 10, 18, 1038, 10, 83, 10, 82, 9, 339, 2382, 289, 63, 77, 8, 83, 9, 365, 14106, 12754, 701, 11648, 17131, 10208, 272, 436, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 787, 314, 23418, 2174, 2717, 918, 18012, 339, 486, 63, 77, 8, 83, 9, 275, 289, 63, 77, 8, 83, 9, 627, 1437, 2801, 34, 63, 77, 308, 538, 18, 1182, 841, 9, 787, 876, 14378, 2378, 408, 339, 347, 636, 826, 721, 277, 12, 5523, 29, 403, 304, 267, 340, 5523, 365, 488, 26, 288, 291, 423, 11521, 275, 769, 342, 288, 291, 423, 66, 4778, 275, 769, 342, 288, 291, 423, 3610, 275, 769, 342, 288, 291, 423, 5527, 275, 769, 342, 267, 587, 26, 288, 291, 423, 6976, 275, 5523, 288, 327, 2104, 3063, 1454, 2222, 7188, 17264, 2268, 14503, 288, 327, 3254, 675, 7188, 17264, 18278, 465, 5521, 288, 291, 423, 11521, 275, 942, 288, 367, 6036, 315, 5523, 26, 355, 367, 23185, 310, 315, 5523, 59, 4429, 2189, 490, 367, 6222, 315, 23185, 310, 26, 717, 282, 275, 23185, 310, 59, 4188, 61, 717, 340, 440, 282, 14, 354, 14, 2460, 480, 40, 2349, 1169, 291, 423, 11521, 14, 740, 8, 19581, 310, 59, 4188, 566, 288, 291, 423, 3610, 275, 942, 288, 291, 423, 66, 4778, 275, 942, 288, 291, 423, 5527, 275, 942, 7846, 367, 6222, 315, 291, 423, 11521, 26, 355, 291, 423, 3610, 14, 740, 8, 4188, 14, 2108, 14, 354, 9, 355, 291, 423, 5527, 14, 740, 8, 4188, 14, 2108, 14, 354, 9, 2234, 340, 6222, 423, 66, 4778, 365, 488, 26, 490, 291, 423, 66, 4778, 14, 740, 8, 17, 4959, 355, 587, 26, 490, 291, 423, 66, 4778, 14, 740, 8, 4188, 423, 66, 4778, 9, 2151, 288, 291, 423, 3610, 275, 980, 14, 1144, 8, 277, 423, 3610, 9, 288, 291, 423, 5527, 275, 663, 8, 277, 423, 5527, 9, 288, 291, 423, 66, 4778, 275, 980, 14, 7548, 8, 277, 423, 66, 4778, 12, 413, 2020, 2948, 4959, 10631, 291, 423, 4188, 63, 466, 63, 1162, 221, 275, 1052, 267, 291, 423, 739, 63, 7646, 8, 2324, 29, 736, 14, 515, 14, 12131, 20793, 15, 6776, 15, 1949, 352, 15, 647, 15, 1949, 352, 15, 1018, 15, 4188, 7646, 14, 773, 2237, 339, 768, 3744, 272, 347, 687, 63, 374, 68, 8, 1886, 12, 15439, 2077, 304, 267, 1559, 275, 843, 342, 267, 14503, 275, 15439, 2077, 14, 11521, 398, 367, 6222, 315, 14503, 26, 288, 1819, 275, 620, 8, 4188, 14, 3282, 459, 2108, 2278, 354, 9, 288, 1559, 423, 5527, 14, 740, 8, 2108, 9, 288, 1559, 423, 11521, 14, 740, 8, 4188, 9, 288, 1559, 423, 3610, 14, 740, 8, 2108, 9, 288, 862, 26, 355, 1559, 423, 66, 4778, 14, 740, 8, 988, 8, 17, 2020, 4188, 14, 3282, 459, 66, 4778, 5156, 288, 871, 4067, 26, 355, 1559, 423, 66, 4778, 14, 740, 8, 17, 4959, 267, 1559, 423, 3610, 275, 980, 14, 1144, 8, 1113, 423, 3610, 9, 267, 1559, 423, 66, 4778, 275, 980, 14, 1144, 8, 1113, 423, 66, 4778, 9, 267, 1559, 423, 5527, 275, 663, 8, 1113, 423, 5527, 9, 267, 1559, 423, 66, 4778, 275, 980, 14, 7548, 8, 1113, 423, 66, 4778, 12, 413, 2020, 2948, 4959, 267, 372, 1559, 5493, 347, 485, 739, 63, 7646, 8, 277, 12, 4325, 304, 267, 408, 267, 26129, 314, 12343, 367, 314, 5909, 270, 2652, 22772, 267, 370, 28618, 316, 17704, 687, 286, 1850, 20, 3050, 267, 408, 267, 2069, 63, 3401, 275, 283, 27371, 21852, 16, 13, 25, 3672, 4537, 26736, 16, 13, 25, 2807, 25060, 20565, 1527, 6793, 21852, 16, 13, 25, 23763, 7, 267, 6222, 63, 3401, 275, 6730, 33, 13, 13163, 13, 90, 6616, 267, 6222, 63, 3401, 275, 6730, 33, 13, 13163, 13, 90, 16, 13, 25, 6793, 28012, 267, 1004, 63, 3401, 275, 1689, 2561, 16, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 2, 717, 1867, 83, 11, 2561, 17, 30446, 83, 11, 2561, 17, 1552, 3471, 908, 8, 4188, 63, 3401, 12, 1609, 63, 3401, 9, 398, 5163, 275, 295, 14, 2014, 8, 604, 63, 3401, 9, 7318, 543, 1551, 8, 2324, 9, 465, 570, 63, 2479, 26, 288, 367, 1004, 315, 570, 63, 2479, 26, 355, 340, 1004, 14, 2460, 10064, 2349, 490, 1980, 2234, 333, 275, 5163, 14, 1431, 8, 604, 9, 355, 6222, 63, 354, 275, 333, 14, 2634, 3430, 16, 61, 355, 282, 17, 12, 282, 18, 12, 282, 19, 12, 282, 20, 275, 333, 14, 2634, 3430, 17, 467, 333, 14, 2634, 3430, 19, 467, 333, 14, 2634, 3430, 21, 467, 333, 14, 2634, 3430, 23, 61, 355, 330, 17, 12, 330, 18, 12, 330, 19, 12, 330, 20, 275, 333, 14, 2634, 3430, 18, 467, 333, 14, 2634, 3430, 20, 467, 333, 14, 2634, 3430, 22, 467, 333, 14, 2634, 3430, 24, 61, 355, 286, 275, 333, 14, 2634, 3430, 25, 61, 2234, 282, 275, 980, 14, 1144, 779, 65, 17, 12, 65, 18, 12, 65, 19, 12, 65, 20, 467, 1590, 14, 3157, 9, 355, 330, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
spawnedc/MeCanBlog
django/utils/unittest/util.py
751
2821
"""Various utility functions.""" __unittest = True _MAX_LENGTH = 80 def safe_repr(obj, short=False): try: result = repr(obj) except Exception: result = object.__repr__(obj) if not short or len(result) < _MAX_LENGTH: return result return result[:_MAX_LENGTH] + ' [truncated]...' def safe_str(obj): try: return str(obj) except Exception: return object.__str__(obj) def strclass(cls): return "%s.%s" % (cls.__module__, cls.__name__) def sorted_list_difference(expected, actual): """Finds elements in only one or the other of two, sorted input lists. Returns a two-element tuple of lists. The first list contains those elements in the "expected" list but not in the "actual" list, and the second contains those elements in the "actual" list but not in the "expected" list. Duplicate elements in either input list are ignored. """ i = j = 0 missing = [] unexpected = [] while True: try: e = expected[i] a = actual[j] if e < a: missing.append(e) i += 1 while expected[i] == e: i += 1 elif e > a: unexpected.append(a) j += 1 while actual[j] == a: j += 1 else: i += 1 try: while expected[i] == e: i += 1 finally: j += 1 while actual[j] == a: j += 1 except IndexError: missing.extend(expected[i:]) unexpected.extend(actual[j:]) break return missing, unexpected def unorderable_list_difference(expected, actual, ignore_duplicate=False): """Same behavior as sorted_list_difference but for lists of unorderable items (like dicts). As it does a linear search per item (remove) it has O(n*n) performance. """ missing = [] unexpected = [] while expected: item = expected.pop() try: actual.remove(item) except ValueError: missing.append(item) if ignore_duplicate: for lst in expected, actual: try: while True: lst.remove(item) except ValueError: pass if ignore_duplicate: while actual: item = actual.pop() unexpected.append(item) try: while True: actual.remove(item) except ValueError: pass return missing, unexpected # anything left in actual is unexpected return missing, actual
bsd-3-clause
[ 624, 9958, 1785, 11420, 3423, 1041, 199, 199, 363, 2796, 275, 715, 421, 199, 63, 4283, 63, 9127, 275, 5939, 199, 318, 5048, 63, 2722, 8, 1113, 12, 3974, 29, 797, 304, 272, 862, 26, 267, 754, 275, 4700, 8, 1113, 9, 272, 871, 2186, 26, 267, 754, 275, 909, 855, 2722, 721, 1113, 9, 272, 340, 440, 3974, 503, 822, 8, 1099, 9, 665, 485, 4283, 63, 9127, 26, 267, 372, 754, 272, 372, 754, 1491, 63, 4283, 63, 9127, 61, 435, 283, 359, 19347, 61, 13698, 199, 199, 318, 5048, 63, 495, 8, 1113, 304, 272, 862, 26, 267, 372, 620, 8, 1113, 9, 272, 871, 2186, 26, 267, 372, 909, 855, 495, 721, 1113, 9, 199, 199, 318, 620, 533, 8, 1886, 304, 272, 372, 2071, 83, 4111, 83, 2, 450, 334, 1886, 855, 578, 3108, 843, 855, 354, 3368, 199, 199, 318, 3355, 63, 513, 63, 9196, 8, 2062, 12, 3503, 304, 272, 408, 30344, 4008, 315, 1454, 1373, 503, 314, 1163, 402, 2877, 12, 3355, 1324, 5548, 14, 339, 1803, 282, 2877, 13, 2108, 2008, 402, 5548, 14, 259, 710, 1642, 769, 3509, 5204, 272, 4008, 315, 314, 298, 2062, 2, 769, 1325, 440, 315, 314, 298, 6514, 2, 769, 12, 436, 314, 272, 3499, 3509, 5204, 4008, 315, 314, 298, 6514, 2, 769, 1325, 440, 315, 314, 272, 298, 2062, 2, 769, 14, 259, 23942, 4008, 315, 1902, 1324, 769, 787, 5525, 14, 272, 408, 272, 284, 275, 1335, 275, 378, 272, 4124, 275, 942, 272, 10537, 275, 942, 272, 1830, 715, 26, 267, 862, 26, 288, 325, 275, 1420, 59, 73, 61, 288, 282, 275, 3503, 59, 74, 61, 288, 340, 325, 665, 282, 26, 355, 4124, 14, 740, 8, 69, 9, 355, 284, 847, 413, 355, 1830, 1420, 59, 73, 61, 508, 325, 26, 490, 284, 847, 413, 288, 916, 325, 690, 282, 26, 355, 10537, 14, 740, 8, 65, 9, 355, 1335, 847, 413, 355, 1830, 3503, 59, 74, 61, 508, 282, 26, 490, 1335, 847, 413, 288, 587, 26, 355, 284, 847, 413, 355, 862, 26, 490, 1830, 1420, 59, 73, 61, 508, 325, 26, 717, 284, 847, 413, 355, 3753, 26, 490, 1335, 847, 413, 490, 1830, 3503, 59, 74, 61, 508, 282, 26, 717, 1335, 847, 413, 267, 871, 7888, 26, 288, 4124, 14, 2880, 8, 2062, 59, 73, 5728, 288, 10537, 14, 2880, 8, 6514, 59, 74, 5728, 288, 2059, 272, 372, 4124, 12, 10537, 199, 199, 318, 625, 27788, 6842, 63, 513, 63, 9196, 8, 2062, 12, 3503, 12, 3686, 63, 11081, 29, 797, 304, 272, 408, 8479, 5953, 465, 3355, 63, 513, 63, 9196, 1325, 272, 367, 5548, 402, 625, 27788, 6842, 2974, 334, 2930, 10809, 680, 339, 3709, 652, 1630, 282, 7798, 2754, 1126, 1242, 334, 2168, 9, 652, 272, 965, 593, 8, 78, 10, 78, 9, 10238, 14, 272, 408, 272, 4124, 275, 942, 272, 10537, 275, 942, 272, 1830, 1420, 26, 267, 1242, 275, 1420, 14, 1935, 342, 267, 862, 26, 288, 3503, 14, 2168, 8, 1053, 9, 267, 871, 1722, 26, 288, 4124, 14, 740, 8, 1053, 9, 267, 340, 3686, 63, 11081, 26, 288, 367, 9877, 315, 1420, 12, 3503, 26, 355, 862, 26, 490, 1830, 715, 26, 717, 9877, 14, 2168, 8, 1053, 9, 355, 871, 1722, 26, 490, 986, 272, 340, 3686, 63, 11081, 26, 267, 1830, 3503, 26, 288, 1242, 275, 3503, 14, 1935, 342, 288, 10537, 14, 740, 8, 1053, 9, 288, 862, 26, 355, 1830, 715, 26, 490, 3503, 14, 2168, 8, 1053, 9, 288, 871, 1722, 26, 355, 986, 267, 372, 4124, 12, 10537, 339, 327, 7003, 3602, 315, 3503, 365, 10537, 272, 372, 4124, 12, 3503, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 9958, 1785, 11420, 3423, 1041, 199, 199, 363, 2796, 275, 715, 421, 199, 63, 4283, 63, 9127, 275, 5939, 199, 318, 5048, 63, 2722, 8, 1113, 12, 3974, 29, 797, 304, 272, 862, 26, 267, 754, 275, 4700, 8, 1113, 9, 272, 871, 2186, 26, 267, 754, 275, 909, 855, 2722, 721, 1113, 9, 272, 340, 440, 3974, 503, 822, 8, 1099, 9, 665, 485, 4283, 63, 9127, 26, 267, 372, 754, 272, 372, 754, 1491, 63, 4283, 63, 9127, 61, 435, 283, 359, 19347, 61, 13698, 199, 199, 318, 5048, 63, 495, 8, 1113, 304, 272, 862, 26, 267, 372, 620, 8, 1113, 9, 272, 871, 2186, 26, 267, 372, 909, 855, 495, 721, 1113, 9, 199, 199, 318, 620, 533, 8, 1886, 304, 272, 372, 2071, 83, 4111, 83, 2, 450, 334, 1886, 855, 578, 3108, 843, 855, 354, 3368, 199, 199, 318, 3355, 63, 513, 63, 9196, 8, 2062, 12, 3503, 304, 272, 408, 30344, 4008, 315, 1454, 1373, 503, 314, 1163, 402, 2877, 12, 3355, 1324, 5548, 14, 339, 1803, 282, 2877, 13, 2108, 2008, 402, 5548, 14, 259, 710, 1642, 769, 3509, 5204, 272, 4008, 315, 314, 298, 2062, 2, 769, 1325, 440, 315, 314, 298, 6514, 2, 769, 12, 436, 314, 272, 3499, 3509, 5204, 4008, 315, 314, 298, 6514, 2, 769, 1325, 440, 315, 314, 272, 298, 2062, 2, 769, 14, 259, 23942, 4008, 315, 1902, 1324, 769, 787, 5525, 14, 272, 408, 272, 284, 275, 1335, 275, 378, 272, 4124, 275, 942, 272, 10537, 275, 942, 272, 1830, 715, 26, 267, 862, 26, 288, 325, 275, 1420, 59, 73, 61, 288, 282, 275, 3503, 59, 74, 61, 288, 340, 325, 665, 282, 26, 355, 4124, 14, 740, 8, 69, 9, 355, 284, 847, 413, 355, 1830, 1420, 59, 73, 61, 508, 325, 26, 490, 284, 847, 413, 288, 916, 325, 690, 282, 26, 355, 10537, 14, 740, 8, 65, 9, 355, 1335, 847, 413, 355, 1830, 3503, 59, 74, 61, 508, 282, 26, 490, 1335, 847, 413, 288, 587, 26, 355, 284, 847, 413, 355, 862, 26, 490, 1830, 1420, 59, 73, 61, 508, 325, 26, 717, 284, 847, 413, 355, 3753, 26, 490, 1335, 847, 413, 490, 1830, 3503, 59, 74, 61, 508, 282, 26, 717, 1335, 847, 413, 267, 871, 7888, 26, 288, 4124, 14, 2880, 8, 2062, 59, 73, 5728, 288, 10537, 14, 2880, 8, 6514, 59, 74, 5728, 288, 2059, 272, 372, 4124, 12, 10537, 199, 199, 318, 625, 27788, 6842, 63, 513, 63, 9196, 8, 2062, 12, 3503, 12, 3686, 63, 11081, 29, 797, 304, 272, 408, 8479, 5953, 465, 3355, 63, 513, 63, 9196, 1325, 272, 367, 5548, 402, 625, 27788, 6842, 2974, 334, 2930, 10809, 680, 339, 3709, 652, 1630, 282, 7798, 2754, 1126, 1242, 334, 2168, 9, 652, 272, 965, 593, 8, 78, 10, 78, 9, 10238, 14, 272, 408, 272, 4124, 275, 942, 272, 10537, 275, 942, 272, 1830, 1420, 26, 267, 1242, 275, 1420, 14, 1935, 342, 267, 862, 26, 288, 3503, 14, 2168, 8, 1053, 9, 267, 871, 1722, 26, 288, 4124, 14, 740, 8, 1053, 9, 267, 340, 3686, 63, 11081, 26, 288, 367, 9877, 315, 1420, 12, 3503, 26, 355, 862, 26, 490, 1830, 715, 26, 717, 9877, 14, 2168, 8, 1053, 9, 355, 871, 1722, 26, 490, 986, 272, 340, 3686, 63, 11081, 26, 267, 1830, 3503, 26, 288, 1242, 275, 3503, 14, 1935, 342, 288, 10537, 14, 740, 8, 1053, 9, 288, 862, 26, 355, 1830, 715, 26, 490, 3503, 14, 2168, 8, 1053, 9, 288, 871, 1722, 26, 355, 986, 267, 372, 4124, 12, 10537, 339, 327, 7003, 3602, 315, 3503, 365, 10537, 272, 372, 4124, 12, 3503, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
getsentry/zeus
zeus/factories/build.py
1
3176
import factory from datetime import timedelta from faker import Factory from random import randint from zeus import models from zeus.config import db from zeus.constants import Result, Status from zeus.utils import timezone from .base import ModelFactory from .repository import RepositoryFactory from .types import GUIDFactory faker = Factory.create() # TODO(dcramer): this should reflect attributes of its Jobs (and # then needs updated when children are added) class BuildFactory(ModelFactory): id = GUIDFactory() label = factory.faker.Faker("sentence") repository = factory.LazyAttribute( lambda o: o.revision.repository if getattr(o, "revision", None) else RepositoryFactory() ) repository_id = factory.SelfAttribute("repository.id") result = factory.Iterator([Result.failed, Result.passed]) status = factory.Iterator([Status.queued, Status.in_progress, Status.finished]) ref = factory.LazyAttribute( lambda o: o.revision.sha if getattr(o, "revision", None) else faker.sha1() ) revision_sha = factory.LazyAttribute( lambda o: o.revision.sha if getattr(o, "revision", None) else None ) date_created = factory.LazyAttribute( lambda o: timezone.now() - timedelta(minutes=30) ) date_started = factory.LazyAttribute( lambda o: ( faker.date_time_between( o.date_created, o.date_created + timedelta(minutes=1) ) if o.status in [Status.finished, Status.in_progress] else None ) ) date_finished = factory.LazyAttribute( lambda o: faker.date_time_between( o.date_started, o.date_started + timedelta(minutes=10) ) if o.status == Status.finished else None ) @factory.post_generation def authors(self, create, extracted, **kwargs): if not create: return if extracted: self.authors = extracted db.session.flush() class Meta: model = models.Build class Params: queued = factory.Trait( result=Result.unknown, status=Status.queued, date_started=None, date_finished=None, ) in_progress = factory.Trait( result=Result.unknown, status=Status.in_progress, date_finished=None ) finished = factory.Trait(status=Status.finished) failed = factory.Trait(result=Result.failed, status=Status.finished) passed = factory.Trait(result=Result.passed, status=Status.finished) aborted = factory.Trait(result=Result.aborted, status=Status.finished) errored = factory.Trait(result=Result.errored, status=Status.finished) anonymous = factory.Trait(authors=[]) travis = factory.Trait( provider="travis", external_id=factory.LazyAttribute(lambda o: str(randint(10000, 999999))), url=factory.LazyAttribute( lambda o: "https://travis-ci.org/{}/{}/builds/{}".format( o.repository.owner_name, o.repository.name, o.external_id ) ), )
apache-2.0
[ 646, 6434, 199, 199, 504, 2197, 492, 6871, 199, 504, 289, 12630, 492, 23616, 199, 504, 2196, 492, 29722, 199, 199, 504, 29986, 527, 492, 1709, 199, 504, 29986, 527, 14, 888, 492, 1592, 199, 504, 29986, 527, 14, 5559, 492, 10695, 12, 9795, 199, 504, 29986, 527, 14, 1208, 492, 7137, 199, 199, 504, 1275, 1095, 492, 5822, 2927, 199, 504, 1275, 8421, 492, 24426, 2927, 199, 504, 1275, 1313, 492, 21645, 2927, 199, 199, 667, 2570, 275, 23616, 14, 981, 342, 421, 199, 3, 3254, 8, 3833, 1186, 82, 304, 642, 1077, 16806, 3004, 402, 2399, 7135, 1533, 334, 460, 199, 3, 2066, 4839, 4588, 1380, 4978, 787, 3483, 9, 421, 199, 533, 6516, 2927, 8, 1685, 2927, 304, 272, 1305, 275, 21645, 2927, 342, 272, 1768, 275, 6434, 14, 667, 2570, 14, 38, 12630, 480, 17727, 531, 272, 7611, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 8421, 267, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 267, 587, 24426, 2927, 342, 272, 776, 272, 7611, 63, 344, 275, 6434, 14, 12887, 1646, 480, 8421, 14, 344, 531, 272, 754, 275, 6434, 14, 3585, 779, 2889, 14, 4892, 12, 10695, 14, 12070, 566, 272, 2004, 275, 6434, 14, 3585, 779, 3694, 14, 14268, 12, 9795, 14, 262, 63, 5734, 12, 9795, 14, 8669, 566, 272, 2984, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 4835, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 587, 289, 12630, 14, 4835, 17, 342, 272, 776, 272, 6974, 63, 4835, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 4835, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 587, 488, 272, 776, 272, 1434, 63, 3966, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 7137, 14, 2131, 342, 446, 6871, 8, 10430, 29, 1216, 9, 272, 776, 272, 1434, 63, 8924, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 334, 288, 289, 12630, 14, 602, 63, 521, 63, 13007, 8, 355, 312, 14, 602, 63, 3966, 12, 312, 14, 602, 63, 3966, 435, 6871, 8, 10430, 29, 17, 9, 288, 776, 288, 340, 312, 14, 1205, 315, 359, 3694, 14, 8669, 12, 9795, 14, 262, 63, 5734, 61, 288, 587, 488, 267, 776, 272, 776, 272, 1434, 63, 8669, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 289, 12630, 14, 602, 63, 521, 63, 13007, 8, 288, 312, 14, 602, 63, 8924, 12, 312, 14, 602, 63, 8924, 435, 6871, 8, 10430, 29, 709, 9, 267, 776, 267, 340, 312, 14, 1205, 508, 9795, 14, 8669, 267, 587, 488, 272, 776, 339, 768, 3702, 14, 1932, 63, 15043, 272, 347, 11462, 8, 277, 12, 1218, 12, 12509, 12, 1011, 958, 304, 267, 340, 440, 1218, 26, 288, 372, 398, 340, 12509, 26, 288, 291, 14, 8149, 275, 12509, 398, 1592, 14, 1730, 14, 4939, 342, 339, 1021, 6288, 26, 267, 1402, 275, 1709, 14, 3425, 339, 1021, 30370, 26, 267, 26102, 275, 6434, 14, 27655, 8, 288, 754, 29, 2889, 14, 5187, 12, 288, 2004, 29, 3694, 14, 14268, 12, 288, 1434, 63, 8924, 29, 403, 12, 288, 1434, 63, 8669, 29, 403, 12, 267, 776, 267, 315, 63, 5734, 275, 6434, 14, 27655, 8, 288, 754, 29, 2889, 14, 5187, 12, 2004, 29, 3694, 14, 262, 63, 5734, 12, 1434, 63, 8669, 29, 403, 267, 776, 267, 9158, 275, 6434, 14, 27655, 8, 1205, 29, 3694, 14, 8669, 9, 267, 3405, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 4892, 12, 2004, 29, 3694, 14, 8669, 9, 267, 3032, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 12070, 12, 2004, 29, 3694, 14, 8669, 9, 267, 26815, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 371, 1376, 12, 2004, 29, 3694, 14, 8669, 9, 267, 9266, 20878, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 281, 20878, 12, 2004, 29, 3694, 14, 8669, 9, 267, 16535, 275, 6434, 14, 27655, 8, 8149, 14285, 267, 1468, 5068, 275, 6434, 14, 27655, 8, 288, 5022, 628, 1239, 5068, 401, 288, 5957, 63, 344, 29, 3702, 14, 14269, 1646, 8, 2734, 312, 26, 620, 8, 8393, 8, 9943, 12, 221, 20036, 11508, 288, 1166, 29, 3702, 14, 14269, 1646, 8, 355, 2400, 312, 26, 298, 2859, 921, 1239, 5068, 13, 559, 14, 1308, 14698, 19655, 10838, 15, 13536, 908, 8, 490, 312, 14, 8421, 14, 4597, 63, 354, 12, 312, 14, 8421, 14, 354, 12, 312, 14, 5159, 63, 344, 355, 776, 288, 2318, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6434, 199, 199, 504, 2197, 492, 6871, 199, 504, 289, 12630, 492, 23616, 199, 504, 2196, 492, 29722, 199, 199, 504, 29986, 527, 492, 1709, 199, 504, 29986, 527, 14, 888, 492, 1592, 199, 504, 29986, 527, 14, 5559, 492, 10695, 12, 9795, 199, 504, 29986, 527, 14, 1208, 492, 7137, 199, 199, 504, 1275, 1095, 492, 5822, 2927, 199, 504, 1275, 8421, 492, 24426, 2927, 199, 504, 1275, 1313, 492, 21645, 2927, 199, 199, 667, 2570, 275, 23616, 14, 981, 342, 421, 199, 3, 3254, 8, 3833, 1186, 82, 304, 642, 1077, 16806, 3004, 402, 2399, 7135, 1533, 334, 460, 199, 3, 2066, 4839, 4588, 1380, 4978, 787, 3483, 9, 421, 199, 533, 6516, 2927, 8, 1685, 2927, 304, 272, 1305, 275, 21645, 2927, 342, 272, 1768, 275, 6434, 14, 667, 2570, 14, 38, 12630, 480, 17727, 531, 272, 7611, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 8421, 267, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 267, 587, 24426, 2927, 342, 272, 776, 272, 7611, 63, 344, 275, 6434, 14, 12887, 1646, 480, 8421, 14, 344, 531, 272, 754, 275, 6434, 14, 3585, 779, 2889, 14, 4892, 12, 10695, 14, 12070, 566, 272, 2004, 275, 6434, 14, 3585, 779, 3694, 14, 14268, 12, 9795, 14, 262, 63, 5734, 12, 9795, 14, 8669, 566, 272, 2984, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 4835, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 587, 289, 12630, 14, 4835, 17, 342, 272, 776, 272, 6974, 63, 4835, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 312, 14, 5792, 14, 4835, 340, 2519, 8, 79, 12, 298, 5792, 401, 488, 9, 587, 488, 272, 776, 272, 1434, 63, 3966, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 7137, 14, 2131, 342, 446, 6871, 8, 10430, 29, 1216, 9, 272, 776, 272, 1434, 63, 8924, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 334, 288, 289, 12630, 14, 602, 63, 521, 63, 13007, 8, 355, 312, 14, 602, 63, 3966, 12, 312, 14, 602, 63, 3966, 435, 6871, 8, 10430, 29, 17, 9, 288, 776, 288, 340, 312, 14, 1205, 315, 359, 3694, 14, 8669, 12, 9795, 14, 262, 63, 5734, 61, 288, 587, 488, 267, 776, 272, 776, 272, 1434, 63, 8669, 275, 6434, 14, 14269, 1646, 8, 267, 2400, 312, 26, 289, 12630, 14, 602, 63, 521, 63, 13007, 8, 288, 312, 14, 602, 63, 8924, 12, 312, 14, 602, 63, 8924, 435, 6871, 8, 10430, 29, 709, 9, 267, 776, 267, 340, 312, 14, 1205, 508, 9795, 14, 8669, 267, 587, 488, 272, 776, 339, 768, 3702, 14, 1932, 63, 15043, 272, 347, 11462, 8, 277, 12, 1218, 12, 12509, 12, 1011, 958, 304, 267, 340, 440, 1218, 26, 288, 372, 398, 340, 12509, 26, 288, 291, 14, 8149, 275, 12509, 398, 1592, 14, 1730, 14, 4939, 342, 339, 1021, 6288, 26, 267, 1402, 275, 1709, 14, 3425, 339, 1021, 30370, 26, 267, 26102, 275, 6434, 14, 27655, 8, 288, 754, 29, 2889, 14, 5187, 12, 288, 2004, 29, 3694, 14, 14268, 12, 288, 1434, 63, 8924, 29, 403, 12, 288, 1434, 63, 8669, 29, 403, 12, 267, 776, 267, 315, 63, 5734, 275, 6434, 14, 27655, 8, 288, 754, 29, 2889, 14, 5187, 12, 2004, 29, 3694, 14, 262, 63, 5734, 12, 1434, 63, 8669, 29, 403, 267, 776, 267, 9158, 275, 6434, 14, 27655, 8, 1205, 29, 3694, 14, 8669, 9, 267, 3405, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 4892, 12, 2004, 29, 3694, 14, 8669, 9, 267, 3032, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 12070, 12, 2004, 29, 3694, 14, 8669, 9, 267, 26815, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 371, 1376, 12, 2004, 29, 3694, 14, 8669, 9, 267, 9266, 20878, 275, 6434, 14, 27655, 8, 1099, 29, 2889, 14, 281, 20878, 12, 2004, 29, 3694, 14, 8669, 9, 267, 16535, 275, 6434, 14, 27655, 8, 8149, 14285, 267, 1468, 5068, 275, 6434, 14, 27655, 8, 288, 5022, 628, 1239, 5068, 401, 288, 5957, 63, 344, 29, 3702, 14, 14269, 1646, 8, 2734, 312, 26, 620, 8, 8393, 8, 9943, 12, 221, 20036, 11508, 288, 1166, 29, 3702, 14, 14269, 1646, 8, 355, 2400, 312, 26, 298, 2859, 921, 1239, 5068, 13, 559, 14, 1308, 14698, 19655, 10838, 15, 13536, 908, 8, 490, 312, 14, 8421, 14, 4597, 63, 354, 12, 312, 14, 8421, 14, 354, 12, 312, 14, 5159, 63, 344, 355, 776, 288, 2318, 267, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
orgito/ansible
lib/ansible/modules/network/cloudengine/ce_vrf.py
25
10789
#!/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.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ce_vrf version_added: "2.4" short_description: Manages VPN instance on HUAWEI CloudEngine switches. description: - Manages VPN instance of HUAWEI CloudEngine switches. author: Yang yang (@QijunPan) notes: - If I(state=absent), the route will be removed, regardless of the non-required options. options: vrf: description: - VPN instance, the length of vrf name is 1 - 31, i.e. "test", but can not be C(_public_). required: true description: description: - Description of the vrf, the string length is 1 - 242 . state: description: - Manage the state of the resource. choices: ['present','absent'] default: present ''' EXAMPLES = ''' - name: vrf 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: Config a vpn install named vpna, description is test ce_vrf: vrf: vpna description: test state: present provider: "{{ cli }}" - name: Delete a vpn install named vpna ce_vrf: vrf: vpna state: absent provider: "{{ cli }}" ''' RETURN = ''' proposed: description: k/v pairs of parameters passed into module returned: always type: dict sample: {"vrf": "vpna", "description": "test", "state": "present"} existing: description: k/v pairs of existing switchport returned: always type: dict sample: {} end_state: description: k/v pairs of switchport after module execution returned: always type: dict sample: {"vrf": "vpna", "description": "test", "present": "present"} updates: description: command list sent to the device returned: always type: list sample: ["ip vpn-instance vpna", "description test"] changed: description: check to see if a change was made on the device returned: always type: bool sample: true ''' from xml.etree import ElementTree from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.cloudengine.ce import get_nc_config, set_nc_config, ce_argument_spec CE_NC_GET_VRF = """ <filter type="subtree"> <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance> <vrfName></vrfName> <vrfDescription></vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> </filter> """ CE_NC_CREATE_VRF = """ <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance operation="merge"> <vrfName>%s</vrfName> <vrfDescription>%s</vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> """ CE_NC_DELETE_VRF = """ <l3vpn xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0"> <l3vpncomm> <l3vpnInstances> <l3vpnInstance operation="delete"> <vrfName>%s</vrfName> <vrfDescription>%s</vrfDescription> </l3vpnInstance> </l3vpnInstances> </l3vpncomm> </l3vpn> """ def build_config_xml(xmlstr): """build_config_xml""" return '<config> ' + xmlstr + ' </config>' class Vrf(object): """Manange vpn instance""" def __init__(self, argument_spec, ): self.spec = argument_spec self.module = None self.init_module() # vpn instance info self.vrf = self.module.params['vrf'] self.description = self.module.params['description'] self.state = self.module.params['state'] # state self.changed = False self.updates_cmd = 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 check_response(self, xml_str, xml_name): """Check if response message is already succeed.""" if "<ok/>" not in xml_str: self.module.fail_json(msg='Error: %s failed.' % xml_name) def set_update_cmd(self): """ set update command""" if not self.changed: return if self.state == "present": self.updates_cmd.append('ip vpn-instance %s' % (self.vrf)) if self.description: self.updates_cmd.append('description %s' % (self.description)) else: self.updates_cmd.append('undo ip vpn-instance %s' % (self.vrf)) def get_vrf(self): """ check if vrf is need to change""" getxmlstr = CE_NC_GET_VRF xml_str = get_nc_config(self.module, getxmlstr) 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) vpn_instances = root.findall( "data/l3vpn/l3vpncomm/l3vpnInstances/l3vpnInstance") if vpn_instances: for vpn_instance in vpn_instances: if vpn_instance.find('vrfName').text == self.vrf: if vpn_instance.find('vrfDescription').text == self.description: if self.state == "present": return False else: return True else: return True return self.state == "present" else: return self.state == "present" def check_params(self): """Check all input params""" # vrf and description check if self.vrf == '_public_': self.module.fail_json( msg='Error: The vrf name _public_ is reserved.') if len(self.vrf) < 1 or len(self.vrf) > 31: self.module.fail_json( msg='Error: The vrf name length must between 1 and 242.') if self.description: if len(self.description) < 1 or len(self.description) > 242: self.module.fail_json( msg='Error: The vrf description length must between 1 and 242.') def operate_vrf(self): """config/delete vrf""" if not self.changed: return if self.state == "present": if self.description is None: configxmlstr = CE_NC_CREATE_VRF % (self.vrf, '') else: configxmlstr = CE_NC_CREATE_VRF % (self.vrf, self.description) else: configxmlstr = CE_NC_DELETE_VRF % (self.vrf, self.description) conf_str = build_config_xml(configxmlstr) recv_xml = set_nc_config(self.module, conf_str) self.check_response(recv_xml, "OPERATE_VRF") def get_proposed(self): """get_proposed""" if self.state == 'present': self.proposed['vrf'] = self.vrf if self.description: self.proposed['description'] = self.description else: self.proposed = dict() self.proposed['state'] = self.state def get_existing(self): """get_existing""" change = self.get_vrf() if change: if self.state == 'present': self.existing = dict() else: self.existing['vrf'] = self.vrf if self.description: self.existing['description'] = self.description self.changed = True else: if self.state == 'absent': self.existing = dict() else: self.existing['vrf'] = self.vrf if self.description: self.existing['description'] = self.description self.changed = False def get_end_state(self): """get_end_state""" change = self.get_vrf() if not change: if self.state == 'present': self.end_state['vrf'] = self.vrf if self.description: self.end_state['description'] = self.description else: self.end_state = dict() else: if self.state == 'present': self.end_state = dict() else: self.end_state['vrf'] = self.vrf if self.description: self.end_state['description'] = self.description def work(self): """worker""" self.check_params() self.get_existing() self.get_proposed() self.operate_vrf() self.set_update_cmd() 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(): """main""" argument_spec = dict( vrf=dict(required=True, type='str'), description=dict(required=False, type='str'), state=dict(choices=['absent', 'present'], default='present', required=False), ) argument_spec.update(ce_argument_spec) interface = Vrf(argument_spec) interface.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, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 10142, 63, 11863, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 29057, 1256, 641, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 1802, 26, 272, 446, 21612, 29057, 1256, 402, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 2502, 26, 1488, 621, 31193, 8593, 49, 7879, 324, 19266, 9, 199, 5983, 26, 272, 446, 982, 473, 8, 929, 29, 5575, 395, 314, 7475, 911, 506, 4829, 12, 15270, 402, 314, 489, 2222, 13, 2427, 1511, 14, 199, 1419, 26, 272, 15209, 26, 267, 1369, 26, 288, 446, 29057, 1256, 12, 314, 2582, 402, 15209, 536, 365, 413, 446, 7105, 12, 284, 14, 69, 14, 298, 396, 401, 1325, 883, 440, 506, 445, 1547, 3455, 63, 680, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 314, 15209, 12, 314, 1059, 2582, 365, 413, 446, 499, 2260, 1275, 272, 1174, 26, 267, 1369, 26, 288, 446, 14944, 314, 1174, 402, 314, 2073, 14, 267, 3415, 26, 788, 1881, 1673, 5575, 418, 267, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 15209, 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, 819, 446, 536, 26, 4094, 282, 15978, 3907, 4310, 373, 80, 3540, 12, 1369, 365, 511, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1369, 26, 511, 489, 1174, 26, 3451, 489, 5022, 26, 7370, 5053, 7820, 523, 446, 536, 26, 8496, 282, 15978, 3907, 4310, 373, 80, 3540, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1174, 26, 9552, 489, 5022, 26, 7370, 5053, 7820, 199, 2344, 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, 2420, 11863, 582, 298, 11702, 3540, 401, 1467, 298, 1802, 582, 298, 396, 401, 1467, 298, 929, 582, 298, 1881, 3570, 199, 5952, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 3411, 6258, 719, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 1052, 199, 500, 63, 929, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 6258, 719, 2410, 859, 6451, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 2420, 11863, 582, 298, 11702, 3540, 401, 1598, 298, 1802, 582, 298, 396, 401, 1598, 298, 1881, 582, 298, 1881, 3570, 199, 7618, 26, 272, 1369, 26, 1414, 769, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 711, 15978, 13, 842, 373, 80, 3540, 401, 1467, 298, 1802, 511, 937, 199, 2489, 26, 272, 1369, 26, 1104, 370, 1937, 340, 282, 1570, 1990, 6326, 641, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 2155, 272, 2690, 26, 2549, 199, 2344, 199, 199, 504, 2748, 14, 9464, 492, 13139, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 1251, 85, 848, 2598, 14, 301, 492, 664, 63, 7966, 63, 888, 12, 663, 63, 7966, 63, 888, 12, 10142, 63, 2094, 63, 1650, 421, 199, 2089, 63, 6389, 63, 2970, 63, 54, 11778, 275, 408, 199, 28, 1541, 730, 628, 26043, 1743, 489, 665, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 30, 1598, 665, 11863, 985, 2957, 11863, 985, 30, 1598, 665, 11863, 5831, 2957, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404, 30, 489, 3068, 76, 19, 9702, 30, 272, 3068, 1541, 30, 199, 624, 199, 199, 2089, 63, 6389, 63, 8366, 63, 54, 11778, 275, 408, 199, 28, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 3439, 628, 5628, 1743, 1598, 665, 11863, 985, 6598, 83, 1108, 11863, 985, 30, 1598, 665, 11863, 5831, 6598, 83, 1108, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404 ]
[ 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, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 10142, 63, 11863, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 21612, 29057, 1256, 641, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 1802, 26, 272, 446, 21612, 29057, 1256, 402, 869, 21659, 5408, 41, 8142, 8524, 24563, 14, 199, 2502, 26, 1488, 621, 31193, 8593, 49, 7879, 324, 19266, 9, 199, 5983, 26, 272, 446, 982, 473, 8, 929, 29, 5575, 395, 314, 7475, 911, 506, 4829, 12, 15270, 402, 314, 489, 2222, 13, 2427, 1511, 14, 199, 1419, 26, 272, 15209, 26, 267, 1369, 26, 288, 446, 29057, 1256, 12, 314, 2582, 402, 15209, 536, 365, 413, 446, 7105, 12, 284, 14, 69, 14, 298, 396, 401, 1325, 883, 440, 506, 445, 1547, 3455, 63, 680, 267, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 314, 15209, 12, 314, 1059, 2582, 365, 413, 446, 499, 2260, 1275, 272, 1174, 26, 267, 1369, 26, 288, 446, 14944, 314, 1174, 402, 314, 2073, 14, 267, 3415, 26, 788, 1881, 1673, 5575, 418, 267, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 15209, 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, 819, 446, 536, 26, 4094, 282, 15978, 3907, 4310, 373, 80, 3540, 12, 1369, 365, 511, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1369, 26, 511, 489, 1174, 26, 3451, 489, 5022, 26, 7370, 5053, 7820, 523, 446, 536, 26, 8496, 282, 15978, 3907, 4310, 373, 80, 3540, 272, 10142, 63, 11863, 26, 489, 15209, 26, 373, 80, 3540, 489, 1174, 26, 9552, 489, 5022, 26, 7370, 5053, 7820, 199, 2344, 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, 2420, 11863, 582, 298, 11702, 3540, 401, 1467, 298, 1802, 582, 298, 396, 401, 1467, 298, 929, 582, 298, 1881, 3570, 199, 5952, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 3411, 6258, 719, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 1052, 199, 500, 63, 929, 26, 272, 1369, 26, 1022, 15, 86, 6342, 402, 6258, 719, 2410, 859, 6451, 272, 2138, 26, 3544, 272, 730, 26, 1211, 272, 2690, 26, 221, 2420, 11863, 582, 298, 11702, 3540, 401, 1598, 298, 1802, 582, 298, 396, 401, 1598, 298, 1881, 582, 298, 1881, 3570, 199, 7618, 26, 272, 1369, 26, 1414, 769, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 711, 15978, 13, 842, 373, 80, 3540, 401, 1467, 298, 1802, 511, 937, 199, 2489, 26, 272, 1369, 26, 1104, 370, 1937, 340, 282, 1570, 1990, 6326, 641, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 2155, 272, 2690, 26, 2549, 199, 2344, 199, 199, 504, 2748, 14, 9464, 492, 13139, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 1200, 14, 1251, 85, 848, 2598, 14, 301, 492, 664, 63, 7966, 63, 888, 12, 663, 63, 7966, 63, 888, 12, 10142, 63, 2094, 63, 1650, 421, 199, 2089, 63, 6389, 63, 2970, 63, 54, 11778, 275, 408, 199, 28, 1541, 730, 628, 26043, 1743, 489, 665, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 30, 1598, 665, 11863, 985, 2957, 11863, 985, 30, 1598, 665, 11863, 5831, 2957, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404, 30, 489, 3068, 76, 19, 9702, 30, 272, 3068, 1541, 30, 199, 624, 199, 199, 2089, 63, 6389, 63, 8366, 63, 54, 11778, 275, 408, 199, 28, 76, 19, 9702, 9604, 628, 1014, 921, 1544, 14, 31665, 14, 957, 15, 18242, 15, 86, 4599, 2, 1564, 13, 1023, 628, 17, 14, 16, 2, 1475, 13, 1023, 628, 17, 14, 16, 1743, 267, 665, 76, 19, 9702, 1404, 30, 881, 665, 76, 19, 9702, 18194, 30, 288, 665, 76, 19, 9702, 3244, 3439, 628, 5628, 1743, 1598, 665, 11863, 985, 6598, 83, 1108, 11863, 985, 30, 1598, 665, 11863, 5831, 6598, 83, 1108, 11863, 5831, 30, 288, 3068, 76, 19, 9702, 3244, 30, 881, 3068, 76, 19, 9702, 18194, 30, 267, 3068, 76, 19, 9702, 1404, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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/forms.py
61
3574
# -*- coding: utf-8 -*- from django import forms from django.contrib.auth import get_user_model from django.contrib.auth.forms import ReadOnlyPasswordHashField from .models import EmailUser class UserCreationForm(forms.ModelForm): """ A form for creating a new user, including the required email and password fields. """ error_messages = { 'duplicate_email': "A user with that email already exists.", 'password_mismatch': "The two password fields didn't match.", } email = forms.EmailField( label='Email', help_text="Required. Standard format email address.", ) password1 = forms.CharField( label='Password', widget=forms.PasswordInput ) password2 = forms.CharField( label='Password confirmation', widget=forms.PasswordInput, help_text="Enter the same password as above, for verification." ) class Meta: model = EmailUser fields = ('email',) def clean_email(self): # Since User.username is unique, this check is redundant, # but it sets a nicer error message than the ORM. See #13147. email = self.cleaned_data["email"] User = get_user_model() try: User._default_manager.get(email=email) except User.DoesNotExist: return email raise forms.ValidationError( self.error_messages['duplicate_email'], code='duplicate_email', ) def clean_password2(self): # check that the two passwords match password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError( self.error_messages['password_mismatch'], code='password_mismatch', ) return password2 def save(self, commit=True): # Save the provided password in hashed format user = super(UserCreationForm, self).save(commit=False) user.set_password(self.cleaned_data["password1"]) if commit: user.save() return user class UserChangeForm(forms.ModelForm): """ A form for updating users, including all fields on the user, but replaces the password field with admin's password hash display field. """ email = forms.EmailField( label='Email', help_text = "Required. Standard format email address.", ) password = ReadOnlyPasswordHashField(label="Password", help_text="Raw passwords are not stored, so there is no way to see " "this user's password, but you can change the password " "using <a href=\"password/\">this form</a>.") class Meta: model = EmailUser fields = ('email', 'password', 'first_name', 'last_name', 'is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions', 'last_login', 'date_joined') def __init__(self, *args, **kwargs): super(UserChangeForm, self).__init__(*args, **kwargs) f = self.fields.get('user_permissions', None) if f is not None: f.queryset = f.queryset.select_related('content_type') def clean_password(self): """ Regardless of what the user provides, return the initial value. This is done here, rather than on the field, because the field does not have access to the inital value. """ return self.initial["password"]
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 5574, 5903, 6139, 3476, 792, 199, 199, 504, 1275, 992, 492, 11426, 1899, 421, 199, 533, 2876, 13921, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 437, 1824, 367, 6425, 282, 892, 922, 12, 5893, 314, 1415, 272, 3031, 436, 2505, 1504, 14, 272, 408, 339, 1125, 63, 3431, 275, 469, 267, 283, 11081, 63, 2123, 356, 298, 33, 922, 543, 626, 3031, 2575, 3495, 4765, 267, 283, 2060, 63, 20759, 356, 298, 1918, 2877, 2505, 1504, 9980, 1133, 1336, 4765, 272, 789, 339, 3031, 275, 4513, 14, 16577, 8, 267, 1768, 534, 7035, 297, 267, 1720, 63, 505, 628, 8030, 14, 221, 9739, 1475, 3031, 2287, 4765, 272, 776, 339, 2505, 17, 275, 4513, 14, 2183, 8, 267, 1768, 534, 6139, 297, 267, 3938, 29, 3351, 14, 31804, 272, 776, 339, 2505, 18, 275, 4513, 14, 2183, 8, 267, 1768, 534, 6139, 18791, 297, 267, 3938, 29, 3351, 14, 31804, 12, 267, 1720, 63, 505, 628, 8468, 314, 2011, 2505, 465, 3432, 12, 367, 14786, 2122, 272, 776, 339, 1021, 6288, 26, 267, 1402, 275, 11426, 1899, 267, 1504, 275, 661, 2123, 9538, 339, 347, 3633, 63, 2123, 8, 277, 304, 267, 327, 9336, 2876, 14, 2473, 365, 3747, 12, 642, 1104, 365, 22649, 12, 267, 327, 1325, 652, 5951, 282, 30023, 1125, 1245, 2419, 314, 23383, 14, 1666, 327, 969, 11160, 14, 267, 3031, 275, 291, 14, 8275, 63, 576, 905, 2123, 937, 398, 2876, 275, 664, 63, 751, 63, 1238, 342, 398, 862, 26, 288, 2876, 423, 885, 63, 2609, 14, 362, 8, 2123, 29, 2123, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 3031, 267, 746, 4513, 14, 8172, 8, 288, 291, 14, 705, 63, 3431, 459, 11081, 63, 2123, 995, 288, 1233, 534, 11081, 63, 2123, 297, 267, 776, 339, 347, 3633, 63, 2060, 18, 8, 277, 304, 267, 327, 1104, 626, 314, 2877, 19572, 1336, 267, 2505, 17, 275, 291, 14, 8275, 63, 576, 14, 362, 480, 2060, 17, 531, 267, 2505, 18, 275, 291, 14, 8275, 63, 576, 14, 362, 480, 2060, 18, 531, 267, 340, 2505, 17, 436, 2505, 18, 436, 2505, 17, 1137, 2505, 18, 26, 288, 746, 4513, 14, 8172, 8, 355, 291, 14, 705, 63, 3431, 459, 2060, 63, 20759, 995, 355, 1233, 534, 2060, 63, 20759, 297, 288, 776, 267, 372, 2505, 18, 339, 347, 3354, 8, 277, 12, 5532, 29, 549, 304, 267, 327, 11063, 314, 2741, 2505, 315, 19871, 1475, 267, 922, 275, 1613, 8, 1899, 13921, 2821, 12, 291, 680, 2117, 8, 3543, 29, 797, 9, 267, 922, 14, 409, 63, 2060, 8, 277, 14, 8275, 63, 576, 905, 2060, 17, 3135, 267, 340, 5532, 26, 288, 922, 14, 2117, 342, 398, 372, 922, 421, 199, 533, 2876, 32523, 8, 3351, 14, 15937, 304, 272, 408, 272, 437, 1824, 367, 12928, 4390, 12, 5893, 1006, 1504, 641, 314, 922, 12, 272, 1325, 19058, 314, 2505, 901, 543, 4628, 1159, 2505, 2631, 2929, 272, 901, 14, 272, 408, 272, 3031, 275, 4513, 14, 16577, 8, 267, 1768, 534, 7035, 297, 267, 1720, 63, 505, 275, 298, 8030, 14, 221, 9739, 1475, 3031, 2287, 4765, 272, 776, 339, 2505, 275, 5574, 5903, 6139, 3476, 792, 8, 1302, 628, 6139, 401, 267, 1720, 63, 505, 628, 7963, 19572, 787, 440, 5489, 12, 880, 2337, 365, 949, 4340, 370, 1937, 298, 490, 298, 3749, 922, 1159, 2505, 12, 1325, 1265, 883, 1570, 314, 2505, 298, 490, 298, 4941, 665, 65, 4369, 8178, 2060, 6307, 1743, 3749, 1824, 1108, 65, 30, 2685, 339, 1021, 6288, 26, 267, 1402, 275, 11426, 1899, 267, 1504, 275, 661, 2123, 297, 283, 2060, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 374, 63, 2682, 297, 288, 283, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 283, 2634, 297, 283, 751, 63, 6060, 297, 283, 2019, 63, 2886, 297, 288, 283, 602, 63, 11806, 358, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 1899, 32523, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 289, 275, 291, 14, 955, 14, 362, 360, 751, 63, 6060, 297, 488, 9, 267, 340, 289, 365, 440, 488, 26, 288, 289, 14, 7924, 275, 289, 14, 7924, 14, 2416, 63, 2407, 360, 1317, 63, 466, 358, 339, 347, 3633, 63, 2060, 8, 277, 304, 267, 408, 267, 5044, 1005, 2003, 402, 4052, 314, 922, 6571, 12, 372, 314, 2536, 574, 14, 267, 961, 365, 4224, 2348, 12, 7830, 2419, 641, 314, 901, 12, 2952, 314, 267, 901, 1630, 440, 1172, 2879, 370, 314, 4205, 279, 574, 14, 267, 408, 267, 372, 291, 14, 2747, 905, 2060, 937, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 492, 4513, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3351, 492, 5574, 5903, 6139, 3476, 792, 199, 199, 504, 1275, 992, 492, 11426, 1899, 421, 199, 533, 2876, 13921, 2821, 8, 3351, 14, 15937, 304, 272, 408, 272, 437, 1824, 367, 6425, 282, 892, 922, 12, 5893, 314, 1415, 272, 3031, 436, 2505, 1504, 14, 272, 408, 339, 1125, 63, 3431, 275, 469, 267, 283, 11081, 63, 2123, 356, 298, 33, 922, 543, 626, 3031, 2575, 3495, 4765, 267, 283, 2060, 63, 20759, 356, 298, 1918, 2877, 2505, 1504, 9980, 1133, 1336, 4765, 272, 789, 339, 3031, 275, 4513, 14, 16577, 8, 267, 1768, 534, 7035, 297, 267, 1720, 63, 505, 628, 8030, 14, 221, 9739, 1475, 3031, 2287, 4765, 272, 776, 339, 2505, 17, 275, 4513, 14, 2183, 8, 267, 1768, 534, 6139, 297, 267, 3938, 29, 3351, 14, 31804, 272, 776, 339, 2505, 18, 275, 4513, 14, 2183, 8, 267, 1768, 534, 6139, 18791, 297, 267, 3938, 29, 3351, 14, 31804, 12, 267, 1720, 63, 505, 628, 8468, 314, 2011, 2505, 465, 3432, 12, 367, 14786, 2122, 272, 776, 339, 1021, 6288, 26, 267, 1402, 275, 11426, 1899, 267, 1504, 275, 661, 2123, 9538, 339, 347, 3633, 63, 2123, 8, 277, 304, 267, 327, 9336, 2876, 14, 2473, 365, 3747, 12, 642, 1104, 365, 22649, 12, 267, 327, 1325, 652, 5951, 282, 30023, 1125, 1245, 2419, 314, 23383, 14, 1666, 327, 969, 11160, 14, 267, 3031, 275, 291, 14, 8275, 63, 576, 905, 2123, 937, 398, 2876, 275, 664, 63, 751, 63, 1238, 342, 398, 862, 26, 288, 2876, 423, 885, 63, 2609, 14, 362, 8, 2123, 29, 2123, 9, 267, 871, 2876, 14, 7400, 26, 288, 372, 3031, 267, 746, 4513, 14, 8172, 8, 288, 291, 14, 705, 63, 3431, 459, 11081, 63, 2123, 995, 288, 1233, 534, 11081, 63, 2123, 297, 267, 776, 339, 347, 3633, 63, 2060, 18, 8, 277, 304, 267, 327, 1104, 626, 314, 2877, 19572, 1336, 267, 2505, 17, 275, 291, 14, 8275, 63, 576, 14, 362, 480, 2060, 17, 531, 267, 2505, 18, 275, 291, 14, 8275, 63, 576, 14, 362, 480, 2060, 18, 531, 267, 340, 2505, 17, 436, 2505, 18, 436, 2505, 17, 1137, 2505, 18, 26, 288, 746, 4513, 14, 8172, 8, 355, 291, 14, 705, 63, 3431, 459, 2060, 63, 20759, 995, 355, 1233, 534, 2060, 63, 20759, 297, 288, 776, 267, 372, 2505, 18, 339, 347, 3354, 8, 277, 12, 5532, 29, 549, 304, 267, 327, 11063, 314, 2741, 2505, 315, 19871, 1475, 267, 922, 275, 1613, 8, 1899, 13921, 2821, 12, 291, 680, 2117, 8, 3543, 29, 797, 9, 267, 922, 14, 409, 63, 2060, 8, 277, 14, 8275, 63, 576, 905, 2060, 17, 3135, 267, 340, 5532, 26, 288, 922, 14, 2117, 342, 398, 372, 922, 421, 199, 533, 2876, 32523, 8, 3351, 14, 15937, 304, 272, 408, 272, 437, 1824, 367, 12928, 4390, 12, 5893, 1006, 1504, 641, 314, 922, 12, 272, 1325, 19058, 314, 2505, 901, 543, 4628, 1159, 2505, 2631, 2929, 272, 901, 14, 272, 408, 272, 3031, 275, 4513, 14, 16577, 8, 267, 1768, 534, 7035, 297, 267, 1720, 63, 505, 275, 298, 8030, 14, 221, 9739, 1475, 3031, 2287, 4765, 272, 776, 339, 2505, 275, 5574, 5903, 6139, 3476, 792, 8, 1302, 628, 6139, 401, 267, 1720, 63, 505, 628, 7963, 19572, 787, 440, 5489, 12, 880, 2337, 365, 949, 4340, 370, 1937, 298, 490, 298, 3749, 922, 1159, 2505, 12, 1325, 1265, 883, 1570, 314, 2505, 298, 490, 298, 4941, 665, 65, 4369, 8178, 2060, 6307, 1743, 3749, 1824, 1108, 65, 30, 2685, 339, 1021, 6288, 26, 267, 1402, 275, 11426, 1899, 267, 1504, 275, 661, 2123, 297, 283, 2060, 297, 283, 2246, 63, 354, 297, 283, 2019, 63, 354, 297, 283, 374, 63, 2682, 297, 288, 283, 374, 63, 7018, 297, 283, 374, 63, 11434, 297, 283, 2634, 297, 283, 751, 63, 6060, 297, 283, 2019, 63, 2886, 297, 288, 283, 602, 63, 11806, 358, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 1899, 32523, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 289, 275, 291, 14, 955, 14, 362, 360, 751, 63, 6060, 297, 488, 9, 267, 340, 289, 365, 440, 488, 26, 288, 289, 14, 7924, 275, 289, 14, 7924, 14, 2416, 63, 2407, 360, 1317, 63, 466, 358, 339, 347, 3633, 63, 2060, 8, 277, 304, 267, 408, 267, 5044, 1005, 2003, 402, 4052, 314, 922, 6571, 12, 372, 314, 2536, 574, 14, 267, 961, 365, 4224, 2348, 12, 7830, 2419, 641, 314, 901, 12, 2952, 314, 267, 901, 1630, 440, 1172, 2879, 370, 314, 4205, 279, 574, 14, 267, 408, 267, 372, 291, 14, 2747, 905, 2060, 937, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1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OpenStack/scheduler
nova/api/openstack/compute/legacy_v2/contrib/shelve.py
69
3988
# Copyright 2013 Rackspace Hosting # # 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. """The shelved mode extension.""" import webob from webob import exc from nova.api.openstack import common from nova.api.openstack import extensions as exts from nova.api.openstack import wsgi from nova import compute from nova import exception auth_shelve = exts.extension_authorizer('compute', 'shelve') auth_shelve_offload = exts.extension_authorizer('compute', 'shelveOffload') auth_unshelve = exts.extension_authorizer('compute', 'unshelve') class ShelveController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ShelveController, self).__init__(*args, **kwargs) self.compute_api = compute.API() @wsgi.action('shelve') def _shelve(self, req, id, body): """Move an instance into shelved mode.""" context = req.environ["nova.context"] auth_shelve(context) instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.shelve(context, instance) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'shelve', id) return webob.Response(status_int=202) @wsgi.action('shelveOffload') def _shelve_offload(self, req, id, body): """Force removal of a shelved instance from the compute node.""" context = req.environ["nova.context"] auth_shelve_offload(context) instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.shelve_offload(context, instance) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'shelveOffload', id) return webob.Response(status_int=202) @wsgi.action('unshelve') def _unshelve(self, req, id, body): """Restore an instance from shelved mode.""" context = req.environ["nova.context"] auth_unshelve(context) instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.unshelve(context, instance) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'unshelve', id) return webob.Response(status_int=202) class Shelve(exts.ExtensionDescriptor): """Instance shelve mode.""" name = "Shelve" alias = "os-shelve" namespace = "http://docs.openstack.org/compute/ext/shelve/api/v1.1" updated = "2013-04-06T00:00:00Z" def get_controller_extensions(self): controller = ShelveController() extension = exts.ControllerExtension(self, 'servers', controller) return [extension]
apache-2.0
[ 3, 257, 1898, 6171, 32679, 10891, 316, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 257, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 257, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 199, 624, 1918, 1033, 352, 1354, 818, 3329, 1041, 199, 199, 646, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 465, 27688, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 4526, 199, 504, 5913, 492, 1919, 421, 199, 1178, 63, 609, 15320, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 609, 15320, 358, 199, 1178, 63, 609, 15320, 63, 1997, 912, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 609, 15320, 5195, 912, 358, 199, 1178, 63, 324, 609, 15320, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 324, 609, 15320, 358, 421, 199, 533, 5244, 15320, 7506, 8, 6508, 14, 7506, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2662, 15320, 7506, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3357, 63, 1246, 275, 4526, 14, 3735, 342, 339, 768, 6508, 14, 1287, 360, 609, 15320, 358, 272, 347, 485, 609, 15320, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 10370, 376, 1256, 1901, 1033, 352, 1354, 818, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 609, 15320, 8, 1100, 9, 398, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 609, 15320, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 25404, 283, 609, 15320, 297, 1305, 9, 398, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 339, 768, 6508, 14, 1287, 360, 609, 15320, 5195, 912, 358, 272, 347, 485, 609, 15320, 63, 1997, 912, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 13606, 20055, 402, 282, 1033, 352, 1354, 1256, 687, 314, 4526, 1031, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 609, 15320, 63, 1997, 912, 8, 1100, 9, 398, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 609, 15320, 63, 1997, 912, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 16854, 283, 609, 15320, 5195, 912, 297, 16854, 1305, 9, 398, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 339, 768, 6508, 14, 1287, 360, 324, 609, 15320, 358, 272, 347, 485, 324, 609, 15320, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 21012, 376, 1256, 687, 1033, 352, 1354, 818, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 324, 609, 15320, 8, 1100, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 324, 609, 15320, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 25404, 283, 324, 609, 15320, 297, 25404, 1305, 9, 267, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 421, 199, 533, 5244, 15320, 8, 25752, 14, 6382, 4311, 304, 272, 408, 3244, 1033, 15320, 818, 1041, 339, 536, 275, 298, 2662, 15320, 2, 272, 5162, 275, 298, 736, 13, 609, 15320, 2, 272, 3231, 275, 298, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 15, 609, 15320, 15, 1246, 15, 86, 17, 14, 17, 2, 272, 4588, 275, 298, 6965, 13, 966, 13, 1690, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 5538, 63, 5359, 8, 277, 304, 267, 7614, 275, 5244, 15320, 7506, 342, 267, 3329, 275, 27688, 14, 7506, 6382, 8, 277, 12, 283, 5871, 297, 7614, 9, 267, 372, 359, 3435, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 257, 1898, 6171, 32679, 10891, 316, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 257, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 257, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 257, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 257, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 257, 1334, 314, 844, 14, 199, 199, 624, 1918, 1033, 352, 1354, 818, 3329, 1041, 199, 199, 646, 14568, 199, 504, 14568, 492, 3178, 199, 199, 504, 5913, 14, 1246, 14, 8512, 492, 2863, 199, 504, 5913, 14, 1246, 14, 8512, 492, 5478, 465, 27688, 199, 504, 5913, 14, 1246, 14, 8512, 492, 12464, 199, 504, 5913, 492, 4526, 199, 504, 5913, 492, 1919, 421, 199, 1178, 63, 609, 15320, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 609, 15320, 358, 199, 1178, 63, 609, 15320, 63, 1997, 912, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 609, 15320, 5195, 912, 358, 199, 1178, 63, 324, 609, 15320, 275, 27688, 14, 3435, 63, 2502, 1793, 360, 3357, 297, 283, 324, 609, 15320, 358, 421, 199, 533, 5244, 15320, 7506, 8, 6508, 14, 7506, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 2662, 15320, 7506, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 3357, 63, 1246, 275, 4526, 14, 3735, 342, 339, 768, 6508, 14, 1287, 360, 609, 15320, 358, 272, 347, 485, 609, 15320, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 10370, 376, 1256, 1901, 1033, 352, 1354, 818, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 609, 15320, 8, 1100, 9, 398, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 609, 15320, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 25404, 283, 609, 15320, 297, 1305, 9, 398, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 339, 768, 6508, 14, 1287, 360, 609, 15320, 5195, 912, 358, 272, 347, 485, 609, 15320, 63, 1997, 912, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 13606, 20055, 402, 282, 1033, 352, 1354, 1256, 687, 314, 4526, 1031, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 609, 15320, 63, 1997, 912, 8, 1100, 9, 398, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 609, 15320, 63, 1997, 912, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 16854, 283, 609, 15320, 5195, 912, 297, 16854, 1305, 9, 398, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 339, 768, 6508, 14, 1287, 360, 324, 609, 15320, 358, 272, 347, 485, 324, 609, 15320, 8, 277, 12, 2648, 12, 1305, 12, 2396, 304, 267, 408, 21012, 376, 1256, 687, 1033, 352, 1354, 818, 1041, 267, 1067, 275, 2648, 14, 2314, 905, 6765, 14, 1100, 937, 267, 1790, 63, 324, 609, 15320, 8, 1100, 9, 267, 1256, 275, 2863, 14, 362, 63, 842, 8, 277, 14, 3357, 63, 1246, 12, 1067, 12, 1305, 9, 267, 862, 26, 288, 291, 14, 3357, 63, 1246, 14, 324, 609, 15320, 8, 1100, 12, 1256, 9, 267, 871, 1919, 14, 3244, 1831, 22408, 465, 325, 26, 288, 746, 3178, 14, 2856, 15919, 8, 15228, 29, 69, 14, 908, 63, 1188, 1012, 267, 871, 1919, 14, 3244, 3364, 2223, 465, 1174, 63, 705, 26, 288, 2863, 14, 3730, 63, 1014, 63, 15207, 63, 509, 63, 842, 63, 3197, 63, 929, 8, 929, 63, 705, 12, 25404, 283, 324, 609, 15320, 297, 25404, 1305, 9, 267, 372, 14568, 14, 2364, 8, 1205, 63, 442, 29, 4999, 9, 421, 199, 533, 5244, 15320, 8, 25752, 14, 6382, 4311, 304, 272, 408, 3244, 1033, 15320, 818, 1041, 339, 536, 275, 298, 2662, 15320, 2, 272, 5162, 275, 298, 736, 13, 609, 15320, 2, 272, 3231, 275, 298, 1014, 921, 4757, 14, 8512, 14, 1308, 15, 3357, 15, 832, 15, 609, 15320, 15, 1246, 15, 86, 17, 14, 17, 2, 272, 4588, 275, 298, 6965, 13, 966, 13, 1690, 52, 383, 26, 383, 26, 383, 58, 2, 339, 347, 664, 63, 5538, 63, 5359, 8, 277, 304, 267, 7614, 275, 5244, 15320, 7506, 342, 267, 3329, 275, 27688, 14, 7506, 6382, 8, 277, 12, 283, 5871, 297, 7614, 9, 267, 372, 359, 3435, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gusDuarte/software-center-5.2
test/test_ppa_iconfilename.py
3
1677
#!/usr/bin/python import unittest from testutils import setup_test_env setup_test_env() from softwarecenter.distro.Ubuntu import Ubuntu class MockCache(object): def __init__(self, mock_base_url): self._baseurl = mock_base_url self._cache = [] self.ready = True def __getitem__(self, k): return MockPackage(self, k) def __contains__(self, k): return True class MockPackage(object): def __init__(self, parent, pkgname): self._parentcache = parent self.name = pkgname @property def candidate(self): return MockVersion(self) class MockVersion(object): def __init__(self, parent, version="1.0"): self._parentpkg = parent self._version = version @property def uri(self): pkgname = self._parentpkg.name baseurl = self._parentpkg._parentcache._baseurl return "%s/pool/main/%s/%s/%s_%s_all.deb" % ( baseurl, pkgname[0], pkgname, pkgname, self._version) class TestDistroUbuntu(unittest.TestCase): def setUp(self): self.distro = Ubuntu() def test_icon_download_url(self): mock_cache = MockCache("http://ppa.launchpad.net/mvo/ppa/ubuntu") pkgname = "pkg" iconname = "iconfilename" pkg_uri = mock_cache[pkgname].candidate.uri icon_url = self.distro.get_downloadable_icon_url(pkg_uri, iconname) self.assertEqual(icon_url, "http://ppa.launchpad.net/mvo/meta/ppa/iconfilename") if __name__ == "__main__": import logging logging.basicConfig(level=logging.DEBUG) unittest.main()
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 2882, 199, 199, 504, 511, 1208, 492, 3272, 63, 396, 63, 1813, 199, 2758, 63, 396, 63, 1813, 342, 199, 504, 2032, 4218, 14, 18371, 14, 53, 19313, 492, 31631, 199, 199, 533, 4420, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1683, 63, 1095, 63, 633, 304, 267, 291, 423, 28937, 275, 1683, 63, 1095, 63, 633, 267, 291, 423, 1637, 275, 942, 267, 291, 14, 2179, 275, 715, 272, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 372, 4420, 8599, 8, 277, 12, 1022, 9, 272, 347, 636, 6134, 721, 277, 12, 1022, 304, 267, 372, 715, 199, 199, 533, 4420, 8599, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 5496, 354, 304, 267, 291, 423, 1708, 1637, 275, 1676, 267, 291, 14, 354, 275, 5496, 354, 272, 768, 1829, 272, 347, 7627, 8, 277, 304, 267, 372, 4420, 3353, 8, 277, 9, 199, 199, 533, 4420, 3353, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 1015, 628, 17, 14, 16, 2349, 267, 291, 423, 1708, 4600, 275, 1676, 267, 291, 423, 1023, 275, 1015, 272, 768, 1829, 272, 347, 5108, 8, 277, 304, 267, 5496, 354, 275, 291, 423, 1708, 4600, 14, 354, 267, 1300, 633, 275, 291, 423, 1708, 4600, 423, 1708, 1637, 423, 28937, 267, 372, 2071, 83, 15, 2293, 15, 973, 3149, 83, 3149, 83, 3149, 83, 4970, 83, 63, 452, 14, 16762, 2, 450, 334, 288, 1300, 633, 12, 5496, 354, 59, 16, 467, 5496, 354, 12, 5496, 354, 12, 291, 423, 1023, 9, 10028, 199, 199, 533, 1379, 12012, 293, 53, 19313, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 18371, 275, 31631, 342, 339, 347, 511, 63, 4677, 63, 4249, 63, 633, 8, 277, 304, 267, 1683, 63, 1637, 275, 4420, 4437, 480, 1014, 921, 80, 387, 14, 9850, 6226, 14, 846, 15, 77, 2392, 15, 80, 387, 15, 21151, 531, 267, 5496, 354, 275, 298, 4600, 2, 267, 7016, 354, 275, 298, 4677, 1501, 2, 267, 5496, 63, 2302, 275, 1683, 63, 1637, 59, 4600, 354, 1055, 9007, 14, 2302, 267, 7016, 63, 633, 275, 291, 14, 18371, 14, 362, 63, 4249, 461, 63, 4677, 63, 633, 8, 4600, 63, 2302, 12, 7016, 354, 9, 267, 291, 14, 629, 8, 4677, 63, 633, 12, 586, 298, 1014, 921, 80, 387, 14, 9850, 6226, 14, 846, 15, 77, 2392, 15, 2024, 15, 80, 387, 15, 4677, 1501, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2050, 272, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 2882, 199, 199, 504, 511, 1208, 492, 3272, 63, 396, 63, 1813, 199, 2758, 63, 396, 63, 1813, 342, 199, 504, 2032, 4218, 14, 18371, 14, 53, 19313, 492, 31631, 199, 199, 533, 4420, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1683, 63, 1095, 63, 633, 304, 267, 291, 423, 28937, 275, 1683, 63, 1095, 63, 633, 267, 291, 423, 1637, 275, 942, 267, 291, 14, 2179, 275, 715, 272, 347, 636, 6095, 721, 277, 12, 1022, 304, 267, 372, 4420, 8599, 8, 277, 12, 1022, 9, 272, 347, 636, 6134, 721, 277, 12, 1022, 304, 267, 372, 715, 199, 199, 533, 4420, 8599, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 5496, 354, 304, 267, 291, 423, 1708, 1637, 275, 1676, 267, 291, 14, 354, 275, 5496, 354, 272, 768, 1829, 272, 347, 7627, 8, 277, 304, 267, 372, 4420, 3353, 8, 277, 9, 199, 199, 533, 4420, 3353, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 1015, 628, 17, 14, 16, 2349, 267, 291, 423, 1708, 4600, 275, 1676, 267, 291, 423, 1023, 275, 1015, 272, 768, 1829, 272, 347, 5108, 8, 277, 304, 267, 5496, 354, 275, 291, 423, 1708, 4600, 14, 354, 267, 1300, 633, 275, 291, 423, 1708, 4600, 423, 1708, 1637, 423, 28937, 267, 372, 2071, 83, 15, 2293, 15, 973, 3149, 83, 3149, 83, 3149, 83, 4970, 83, 63, 452, 14, 16762, 2, 450, 334, 288, 1300, 633, 12, 5496, 354, 59, 16, 467, 5496, 354, 12, 5496, 354, 12, 291, 423, 1023, 9, 10028, 199, 199, 533, 1379, 12012, 293, 53, 19313, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 18371, 275, 31631, 342, 339, 347, 511, 63, 4677, 63, 4249, 63, 633, 8, 277, 304, 267, 1683, 63, 1637, 275, 4420, 4437, 480, 1014, 921, 80, 387, 14, 9850, 6226, 14, 846, 15, 77, 2392, 15, 80, 387, 15, 21151, 531, 267, 5496, 354, 275, 298, 4600, 2, 267, 7016, 354, 275, 298, 4677, 1501, 2, 267, 5496, 63, 2302, 275, 1683, 63, 1637, 59, 4600, 354, 1055, 9007, 14, 2302, 267, 7016, 63, 633, 275, 291, 14, 18371, 14, 362, 63, 4249, 461, 63, 4677, 63, 633, 8, 4600, 63, 2302, 12, 7016, 354, 9, 267, 291, 14, 629, 8, 4677, 63, 633, 12, 586, 298, 1014, 921, 80, 387, 14, 9850, 6226, 14, 846, 15, 77, 2392, 15, 2024, 15, 80, 387, 15, 4677, 1501, 531, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 492, 2050, 272, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 9, 272, 2882, 14, 973, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zhenzhai/edx-platform
common/djangoapps/auth_exchange/forms.py
29
4033
""" Forms to support third-party to first-party OAuth 2.0 access token exchange """ from django.contrib.auth.models import User from django.forms import CharField from edx_oauth2_provider.constants import SCOPE_NAMES import provider.constants from provider.forms import OAuthForm, OAuthValidationError from provider.oauth2.forms import ScopeChoiceField, ScopeMixin from provider.oauth2.models import Client from oauth2_provider.models import Application from requests import HTTPError from social.backends import oauth as social_oauth from social.exceptions import AuthException from third_party_auth import pipeline class AccessTokenExchangeForm(ScopeMixin, OAuthForm): """Form for access token exchange endpoint""" access_token = CharField(required=False) scope = ScopeChoiceField(choices=SCOPE_NAMES, required=False) client_id = CharField(required=False) def __init__(self, request, oauth2_adapter, *args, **kwargs): super(AccessTokenExchangeForm, self).__init__(*args, **kwargs) self.request = request self.oauth2_adapter = oauth2_adapter def _require_oauth_field(self, field_name): """ Raise an appropriate OAuthValidationError error if the field is missing """ field_val = self.cleaned_data.get(field_name) if not field_val: raise OAuthValidationError( { "error": "invalid_request", "error_description": "{} is required".format(field_name), } ) return field_val def clean_access_token(self): """ Validates and returns the "access_token" field. """ return self._require_oauth_field("access_token") def clean_client_id(self): """ Validates and returns the "client_id" field. """ return self._require_oauth_field("client_id") def clean(self): if self._errors: return {} backend = self.request.backend if not isinstance(backend, social_oauth.BaseOAuth2): raise OAuthValidationError( { "error": "invalid_request", "error_description": "{} is not a supported provider".format(backend.name), } ) self.request.session[pipeline.AUTH_ENTRY_KEY] = pipeline.AUTH_ENTRY_LOGIN_API client_id = self.cleaned_data["client_id"] try: client = self.oauth2_adapter.get_client(client_id=client_id) except (Client.DoesNotExist, Application.DoesNotExist): raise OAuthValidationError( { "error": "invalid_client", "error_description": "{} is not a valid client_id".format(client_id), } ) if client.client_type not in [provider.constants.PUBLIC, Application.CLIENT_PUBLIC]: raise OAuthValidationError( { # invalid_client isn't really the right code, but this mirrors # https://github.com/edx/django-oauth2-provider/blob/edx/provider/oauth2/forms.py#L331 "error": "invalid_client", "error_description": "{} is not a public client".format(client_id), } ) self.cleaned_data["client"] = client user = None try: user = backend.do_auth(self.cleaned_data.get("access_token"), allow_inactive_user=True) except (HTTPError, AuthException): pass if user and isinstance(user, User): self.cleaned_data["user"] = user else: # Ensure user does not re-enter the pipeline self.request.social_strategy.clean_partial_pipeline() raise OAuthValidationError( { "error": "invalid_grant", "error_description": "access_token is not valid", } ) return self.cleaned_data
agpl-3.0
[ 624, 199, 26028, 370, 2291, 10919, 13, 7522, 370, 1642, 13, 7522, 11715, 499, 14, 16, 2879, 1526, 15343, 199, 624, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 3351, 492, 12064, 199, 504, 22435, 63, 6126, 18, 63, 3780, 14, 5559, 492, 428, 1439, 1510, 63, 14546, 199, 646, 5022, 14, 5559, 199, 504, 5022, 14, 3351, 492, 11715, 2821, 12, 11715, 8172, 199, 504, 5022, 14, 6126, 18, 14, 3351, 492, 20488, 15792, 12, 20488, 4256, 199, 504, 5022, 14, 6126, 18, 14, 992, 492, 6810, 199, 504, 9725, 18, 63, 3780, 14, 992, 492, 13515, 199, 504, 4145, 492, 15050, 199, 504, 20295, 14, 7765, 492, 9725, 465, 20295, 63, 6126, 199, 504, 20295, 14, 3924, 492, 3590, 1726, 199, 199, 504, 10919, 63, 7522, 63, 1178, 492, 7679, 421, 199, 533, 11003, 3264, 13188, 2821, 8, 7812, 4256, 12, 11715, 2821, 304, 272, 408, 2821, 367, 2879, 1526, 15343, 6037, 624, 272, 2879, 63, 1418, 275, 12064, 8, 2427, 29, 797, 9, 272, 4194, 275, 20488, 15792, 8, 4577, 29, 17998, 63, 14546, 12, 1415, 29, 797, 9, 272, 1890, 63, 344, 275, 12064, 8, 2427, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 9725, 18, 63, 10394, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3946, 3264, 13188, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 6126, 18, 63, 10394, 275, 9725, 18, 63, 10394, 339, 347, 485, 4365, 63, 6126, 63, 698, 8, 277, 12, 901, 63, 354, 304, 267, 408, 267, 14771, 376, 5827, 11715, 8172, 1125, 340, 314, 901, 365, 4124, 267, 408, 267, 901, 63, 637, 275, 291, 14, 8275, 63, 576, 14, 362, 8, 698, 63, 354, 9, 267, 340, 440, 901, 63, 637, 26, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1069, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 1415, 1674, 908, 8, 698, 63, 354, 395, 355, 789, 288, 776, 267, 372, 901, 63, 637, 339, 347, 3633, 63, 2732, 63, 1418, 8, 277, 304, 267, 408, 267, 4821, 2335, 436, 2529, 314, 298, 2732, 63, 1418, 2, 901, 14, 267, 408, 267, 372, 291, 423, 4365, 63, 6126, 63, 698, 480, 2732, 63, 1418, 531, 339, 347, 3633, 63, 1258, 63, 344, 8, 277, 304, 267, 408, 267, 4821, 2335, 436, 2529, 314, 298, 1258, 63, 344, 2, 901, 14, 267, 408, 267, 372, 291, 423, 4365, 63, 6126, 63, 698, 480, 1258, 63, 344, 531, 339, 347, 3633, 8, 277, 304, 267, 340, 291, 423, 2550, 26, 288, 372, 1052, 398, 4865, 275, 291, 14, 1069, 14, 4620, 267, 340, 440, 1228, 8, 4620, 12, 20295, 63, 6126, 14, 1563, 12906, 18, 304, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1069, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 3748, 5022, 1674, 908, 8, 4620, 14, 354, 395, 355, 789, 288, 776, 398, 291, 14, 1069, 14, 1730, 59, 7379, 14, 5580, 63, 7285, 63, 3078, 61, 275, 7679, 14, 5580, 63, 7285, 63, 17208, 63, 3735, 398, 1890, 63, 344, 275, 291, 14, 8275, 63, 576, 905, 1258, 63, 344, 937, 267, 862, 26, 288, 1890, 275, 291, 14, 6126, 18, 63, 10394, 14, 362, 63, 1258, 8, 1258, 63, 344, 29, 1258, 63, 344, 9, 267, 871, 334, 3041, 14, 7400, 12, 13515, 14, 7400, 304, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1258, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 1686, 1890, 63, 344, 1674, 908, 8, 1258, 63, 344, 395, 355, 789, 288, 776, 267, 340, 1890, 14, 1258, 63, 466, 440, 315, 359, 3780, 14, 5559, 14, 19476, 12, 13515, 14, 9901, 63, 19476, 2189, 288, 746, 11715, 8172, 8, 355, 469, 490, 327, 3866, 63, 1258, 5712, 1133, 7710, 314, 2451, 1233, 12, 1325, 642, 15216, 83, 490, 327, 4178, 921, 5031, 14, 957, 15, 8268, 15, 1176, 13, 6126, 18, 13, 3780, 15, 6582, 15, 8268, 15, 3780, 15, 6126, 18, 15, 3351, 14, 647, 3, 44, 15638, 490, 298, 705, 582, 298, 3197, 63, 1258, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 4575, 1890, 1674, 908, 8, 1258, 63, 344, 395, 355, 789, 288, 776, 267, 291, 14, 8275, 63, 576, 905, 1258, 937, 275, 1890, 398, 922, 275, 488, 267, 862, 26, 288, 922, 275, 4865, 14, 1117, 63, 1178, 8, 277, 14, 8275, 63, 576, 14, 362, 480, 2732, 63, 1418, 1288, 2040, 63, 16856, 63, 751, 29, 549, 9, 267, 871, 334, 12815, 12, 3590, 1726, 304, 288, 986, 267, 340, 922, 436, 1228, 8, 751, 12, 2876, 304, 288, 291, 14, 8275, 63, 576, 905, 751, 937, 275, 922, 267, 587, 26, 288, 327, 7523, 922, 1630, 440, 295, 13, 4200, 314, 7679, 288, 291, 14, 1069, 14, 13574, 63, 8590, 14, 3118, 63, 6672, 63, 7379, 342, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 17362, 401, 490, 298, 705, 63, 1802, 582, 298, 2732, 63, 1418, 365, 440, 1686, 401, 355, 789, 288, 776, 398, 372, 291, 14, 8275, 63, 576, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 26028, 370, 2291, 10919, 13, 7522, 370, 1642, 13, 7522, 11715, 499, 14, 16, 2879, 1526, 15343, 199, 624, 199, 504, 1639, 14, 2828, 14, 1178, 14, 992, 492, 2876, 199, 504, 1639, 14, 3351, 492, 12064, 199, 504, 22435, 63, 6126, 18, 63, 3780, 14, 5559, 492, 428, 1439, 1510, 63, 14546, 199, 646, 5022, 14, 5559, 199, 504, 5022, 14, 3351, 492, 11715, 2821, 12, 11715, 8172, 199, 504, 5022, 14, 6126, 18, 14, 3351, 492, 20488, 15792, 12, 20488, 4256, 199, 504, 5022, 14, 6126, 18, 14, 992, 492, 6810, 199, 504, 9725, 18, 63, 3780, 14, 992, 492, 13515, 199, 504, 4145, 492, 15050, 199, 504, 20295, 14, 7765, 492, 9725, 465, 20295, 63, 6126, 199, 504, 20295, 14, 3924, 492, 3590, 1726, 199, 199, 504, 10919, 63, 7522, 63, 1178, 492, 7679, 421, 199, 533, 11003, 3264, 13188, 2821, 8, 7812, 4256, 12, 11715, 2821, 304, 272, 408, 2821, 367, 2879, 1526, 15343, 6037, 624, 272, 2879, 63, 1418, 275, 12064, 8, 2427, 29, 797, 9, 272, 4194, 275, 20488, 15792, 8, 4577, 29, 17998, 63, 14546, 12, 1415, 29, 797, 9, 272, 1890, 63, 344, 275, 12064, 8, 2427, 29, 797, 9, 339, 347, 636, 826, 721, 277, 12, 1056, 12, 9725, 18, 63, 10394, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 8, 3946, 3264, 13188, 2821, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 14, 1069, 275, 1056, 267, 291, 14, 6126, 18, 63, 10394, 275, 9725, 18, 63, 10394, 339, 347, 485, 4365, 63, 6126, 63, 698, 8, 277, 12, 901, 63, 354, 304, 267, 408, 267, 14771, 376, 5827, 11715, 8172, 1125, 340, 314, 901, 365, 4124, 267, 408, 267, 901, 63, 637, 275, 291, 14, 8275, 63, 576, 14, 362, 8, 698, 63, 354, 9, 267, 340, 440, 901, 63, 637, 26, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1069, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 1415, 1674, 908, 8, 698, 63, 354, 395, 355, 789, 288, 776, 267, 372, 901, 63, 637, 339, 347, 3633, 63, 2732, 63, 1418, 8, 277, 304, 267, 408, 267, 4821, 2335, 436, 2529, 314, 298, 2732, 63, 1418, 2, 901, 14, 267, 408, 267, 372, 291, 423, 4365, 63, 6126, 63, 698, 480, 2732, 63, 1418, 531, 339, 347, 3633, 63, 1258, 63, 344, 8, 277, 304, 267, 408, 267, 4821, 2335, 436, 2529, 314, 298, 1258, 63, 344, 2, 901, 14, 267, 408, 267, 372, 291, 423, 4365, 63, 6126, 63, 698, 480, 1258, 63, 344, 531, 339, 347, 3633, 8, 277, 304, 267, 340, 291, 423, 2550, 26, 288, 372, 1052, 398, 4865, 275, 291, 14, 1069, 14, 4620, 267, 340, 440, 1228, 8, 4620, 12, 20295, 63, 6126, 14, 1563, 12906, 18, 304, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1069, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 3748, 5022, 1674, 908, 8, 4620, 14, 354, 395, 355, 789, 288, 776, 398, 291, 14, 1069, 14, 1730, 59, 7379, 14, 5580, 63, 7285, 63, 3078, 61, 275, 7679, 14, 5580, 63, 7285, 63, 17208, 63, 3735, 398, 1890, 63, 344, 275, 291, 14, 8275, 63, 576, 905, 1258, 63, 344, 937, 267, 862, 26, 288, 1890, 275, 291, 14, 6126, 18, 63, 10394, 14, 362, 63, 1258, 8, 1258, 63, 344, 29, 1258, 63, 344, 9, 267, 871, 334, 3041, 14, 7400, 12, 13515, 14, 7400, 304, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 1258, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 1686, 1890, 63, 344, 1674, 908, 8, 1258, 63, 344, 395, 355, 789, 288, 776, 267, 340, 1890, 14, 1258, 63, 466, 440, 315, 359, 3780, 14, 5559, 14, 19476, 12, 13515, 14, 9901, 63, 19476, 2189, 288, 746, 11715, 8172, 8, 355, 469, 490, 327, 3866, 63, 1258, 5712, 1133, 7710, 314, 2451, 1233, 12, 1325, 642, 15216, 83, 490, 327, 4178, 921, 5031, 14, 957, 15, 8268, 15, 1176, 13, 6126, 18, 13, 3780, 15, 6582, 15, 8268, 15, 3780, 15, 6126, 18, 15, 3351, 14, 647, 3, 44, 15638, 490, 298, 705, 582, 298, 3197, 63, 1258, 401, 490, 298, 705, 63, 1802, 582, 11491, 365, 440, 282, 4575, 1890, 1674, 908, 8, 1258, 63, 344, 395, 355, 789, 288, 776, 267, 291, 14, 8275, 63, 576, 905, 1258, 937, 275, 1890, 398, 922, 275, 488, 267, 862, 26, 288, 922, 275, 4865, 14, 1117, 63, 1178, 8, 277, 14, 8275, 63, 576, 14, 362, 480, 2732, 63, 1418, 1288, 2040, 63, 16856, 63, 751, 29, 549, 9, 267, 871, 334, 12815, 12, 3590, 1726, 304, 288, 986, 267, 340, 922, 436, 1228, 8, 751, 12, 2876, 304, 288, 291, 14, 8275, 63, 576, 905, 751, 937, 275, 922, 267, 587, 26, 288, 327, 7523, 922, 1630, 440, 295, 13, 4200, 314, 7679, 288, 291, 14, 1069, 14, 13574, 63, 8590, 14, 3118, 63, 6672, 63, 7379, 342, 288, 746, 11715, 8172, 8, 355, 469, 490, 298, 705, 582, 298, 3197, 63, 17362, 401, 490, 298, 705, 63, 1802, 582, 298, 2732, 63, 1418, 365, 440, 1686, 401, 355, 789, 288, 776, 398, 372, 291, 14, 8275, 63, 576, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
EduPepperPD/pepper2013
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
6
62611
import threading import datetime import logging import pymongo import re from importlib import import_module from path import path from xmodule.errortracker import null_error_tracker from xmodule.x_module import XModuleDescriptor from xmodule.modulestore.locator import BlockUsageLocator, DescriptionLocator, CourseLocator, VersionTree, LocalId from xmodule.modulestore.exceptions import InsufficientSpecificationError, VersionConflictError from xmodule.modulestore import inheritance, ModuleStoreBase from ..exceptions import ItemNotFoundError from .definition_lazy_loader import DefinitionLazyLoader from .caching_descriptor_system import CachingDescriptorSystem from xblock.fields import Scope from xblock.runtime import Mixologist from pytz import UTC import collections log = logging.getLogger(__name__) #============================================================================== # Documentation is at # https://edx-wiki.atlassian.net/wiki/display/ENG/Mongostore+Data+Structure # # Known issue: # Inheritance for cached kvs doesn't work on edits. Use case. # 1) attribute foo is inheritable # 2) g.children = [p], p.children = [a] # 3) g.foo = 1 on load # 4) if g.foo > 0, if p.foo > 0, if a.foo > 0 all eval True # 5) p.foo = -1 # 6) g.foo > 0, p.foo <= 0 all eval True BUT # 7) BUG: a.foo > 0 still evals True but should be False # 8) reread and everything works right # 9) p.del(foo), p.foo > 0 is True! works # 10) BUG: a.foo < 0! # Local fix wont' permanently work b/c xblock may cache a.foo... # #============================================================================== class SplitMongoModuleStore(ModuleStoreBase): """ A Mongodb backed ModuleStore supporting versions, inheritance, and sharing. """ def __init__(self, host, db, collection, fs_root, render_template, port=27017, default_class=None, error_tracker=null_error_tracker, user=None, password=None, mongo_options=None, **kwargs): super(SplitMongoModuleStore, self).__init__(**kwargs) if mongo_options is None: mongo_options = {} self.db = pymongo.database.Database(pymongo.MongoClient( host=host, port=port, tz_aware=True, **mongo_options ), db) self.course_index = self.db[collection + '.active_versions'] self.structures = self.db[collection + '.structures'] self.definitions = self.db[collection + '.definitions'] # Code review question: How should I expire entries? # _add_cache could use a lru mechanism to control the cache size? self.thread_cache = threading.local() if user is not None and password is not None: self.db.authenticate(user, password) # every app has write access to the db (v having a flag to indicate r/o v write) # Force mongo to report errors, at the expense of performance # pymongo docs suck but explanation: # http://api.mongodb.org/java/2.10.1/com/mongodb/WriteConcern.html self.course_index.write_concern = {'w': 1} self.structures.write_concern = {'w': 1} self.definitions.write_concern = {'w': 1} if default_class is not None: module_path, _, class_name = default_class.rpartition('.') class_ = getattr(import_module(module_path), class_name) self.default_class = class_ else: self.default_class = None self.fs_root = path(fs_root) self.error_tracker = error_tracker self.render_template = render_template # TODO: Don't have a runtime just to generate the appropriate mixin classes (cpennington) # This is only used by _partition_fields_by_scope, which is only needed because # the split mongo store is used for item creation as well as item persistence self.mixologist = Mixologist(self.xblock_mixins) def cache_items(self, system, base_usage_ids, depth=0, lazy=True): ''' Handles caching of items once inheritance and any other one time per course per fetch operations are done. :param system: a CachingDescriptorSystem :param base_usage_ids: list of usage_ids to fetch :param depth: how deep below these to prefetch :param lazy: whether to fetch definitions or use placeholders ''' new_module_data = {} for usage_id in base_usage_ids: new_module_data = self.descendants( system.course_entry['blocks'], usage_id, depth, new_module_data ) # remove any which were already in module_data (not sure if there's a better way) for newkey in new_module_data.iterkeys(): if newkey in system.module_data: del new_module_data[newkey] if lazy: for block in new_module_data.itervalues(): block['definition'] = DefinitionLazyLoader(self, block['definition']) else: # Load all descendants by id descendent_definitions = self.definitions.find({ '_id': {'$in': [block['definition'] for block in new_module_data.itervalues()]}}) # turn into a map definitions = {definition['_id']: definition for definition in descendent_definitions} for block in new_module_data.itervalues(): if block['definition'] in definitions: block['fields'].update(definitions[block['definition']].get('fields')) system.module_data.update(new_module_data) return system.module_data def _load_items(self, course_entry, usage_ids, depth=0, lazy=True): ''' Load & cache the given blocks from the course. Prefetch down to the given depth. Load the definitions into each block if lazy is False; otherwise, use the lazy definition placeholder. ''' system = self._get_cache(course_entry['_id']) if system is None: system = CachingDescriptorSystem( modulestore=self, course_entry=course_entry, module_data={}, lazy=lazy, default_class=self.default_class, error_tracker=self.error_tracker, render_template=self.render_template, resources_fs=None, mixins=self.xblock_mixins ) self._add_cache(course_entry['_id'], system) self.cache_items(system, usage_ids, depth, lazy) return [system.load_item(usage_id, course_entry) for usage_id in usage_ids] def _get_cache(self, course_version_guid): """ Find the descriptor cache for this course if it exists :param course_version_guid: """ if not hasattr(self.thread_cache, 'course_cache'): self.thread_cache.course_cache = {} system = self.thread_cache.course_cache return system.get(course_version_guid) def _add_cache(self, course_version_guid, system): """ Save this cache for subsequent access :param course_version_guid: :param system: """ if not hasattr(self.thread_cache, 'course_cache'): self.thread_cache.course_cache = {} self.thread_cache.course_cache[course_version_guid] = system return system def _clear_cache(self): """ Should only be used by testing or something which implements transactional boundary semantics """ self.thread_cache.course_cache = {} def _lookup_course(self, course_locator): ''' Decode the locator into the right series of db access. Does not return the CourseDescriptor! It returns the actual db json from structures. Semantics: if course_id and branch given, then it will get that branch. If also give a version_guid, it will see if the current head of that branch == that guid. If not it raises VersionConflictError (the version now differs from what it was when you got your reference) :param course_locator: any subclass of CourseLocator ''' # NOTE: if and when this uses cache, the update if changed logic will break if the cache # holds the same objects as the descriptors! if not course_locator.is_fully_specified(): raise InsufficientSpecificationError('Not fully specified: %s' % course_locator) if course_locator.course_id is not None and course_locator.branch is not None: # use the course_id index = self.course_index.find_one({'_id': course_locator.course_id}) if index is None: raise ItemNotFoundError(course_locator) if course_locator.branch not in index['versions']: raise ItemNotFoundError(course_locator) version_guid = index['versions'][course_locator.branch] if course_locator.version_guid is not None and version_guid != course_locator.version_guid: # This may be a bit too touchy but it's hard to infer intent raise VersionConflictError(course_locator, CourseLocator(course_locator, version_guid=version_guid)) else: # TODO should this raise an exception if branch was provided? version_guid = course_locator.version_guid # cast string to ObjectId if necessary version_guid = course_locator.as_object_id(version_guid) entry = self.structures.find_one({'_id': version_guid}) # b/c more than one course can use same structure, the 'course_id' is not intrinsic to structure # and the one assoc'd w/ it by another fetch may not be the one relevant to this fetch; so, # fake it by explicitly setting it in the in memory structure. if course_locator.course_id: entry['course_id'] = course_locator.course_id entry['branch'] = course_locator.branch return entry def get_courses(self, branch='published', qualifiers=None): ''' Returns a list of course descriptors matching any given qualifiers. qualifiers should be a dict of keywords matching the db fields or any legal query for mongo to use against the active_versions collection. Note, this is to find the current head of the named branch type (e.g., 'draft'). To get specific versions via guid use get_course. :param branch: the branch for which to return courses. Default value is 'published'. :param qualifiers: a optional dict restricting which elements should match ''' if qualifiers is None: qualifiers = {} qualifiers.update({"versions.{}".format(branch): {"$exists": True}}) matching = self.course_index.find(qualifiers) # collect ids and then query for those version_guids = [] id_version_map = {} for course_entry in matching: version_guid = course_entry['versions'][branch] version_guids.append(version_guid) id_version_map[version_guid] = course_entry['_id'] course_entries = self.structures.find({'_id': {'$in': version_guids}}) # get the block for the course element (s/b the root) result = [] for entry in course_entries: # structures are course agnostic but the caller wants to know course, so add it in here entry['course_id'] = id_version_map[entry['_id']] root = entry['root'] result.extend(self._load_items(entry, [root], 0, lazy=True)) return result def get_course(self, course_locator): ''' Gets the course descriptor for the course identified by the locator which may or may not be a blockLocator. raises InsufficientSpecificationError ''' course_entry = self._lookup_course(course_locator) root = course_entry['root'] result = self._load_items(course_entry, [root], 0, lazy=True) return result[0] def get_course_for_item(self, location): ''' Provided for backward compatibility. Is equivalent to calling get_course :param location: ''' return self.get_course(location) def has_item(self, course_id, block_location): """ Returns True if location exists in its course. Returns false if the course or the block w/in the course do not exist for the given version. raises InsufficientSpecificationError if the locator does not id a block """ if block_location.usage_id is None: raise InsufficientSpecificationError(block_location) try: course_structure = self._lookup_course(block_location) except ItemNotFoundError: # this error only occurs if the course does not exist return False return course_structure['blocks'].get(block_location.usage_id) is not None def get_item(self, location, depth=0): """ depth (int): An argument that some module stores may use to prefetch descendants of the queried modules for more efficient results later in the request. The depth is counted in the number of calls to get_children() to cache. None indicates to cache all descendants. raises InsufficientSpecificationError or ItemNotFoundError """ assert isinstance(location, BlockUsageLocator) if not location.is_initialized(): raise InsufficientSpecificationError("Not yet initialized: %s" % location) course = self._lookup_course(location) items = self._load_items(course, [location.usage_id], depth, lazy=True) if len(items) == 0: raise ItemNotFoundError(location) return items[0] def get_items(self, locator, course_id=None, depth=0, qualifiers=None): """ Get all of the modules in the given course matching the qualifiers. The qualifiers should only be fields in the structures collection (sorry). There will be a separate search method for searching through definitions. Common qualifiers are category, definition (provide definition id), display_name, anyfieldname, children (return block if its children includes the one given value). If you want substring matching use {$regex: /acme.*corp/i} type syntax. Although these look like mongo queries, it is all done in memory; so, you cannot try arbitrary queries. :param locator: CourseLocator or BlockUsageLocator restricting search scope :param course_id: ignored. Only included for API compatibility. :param depth: ignored. Only included for API compatibility. :param qualifiers: a dict restricting which elements should match """ # TODO extend to only search a subdag of the course? if qualifiers is None: qualifiers = {} course = self._lookup_course(locator) items = [] for usage_id, value in course['blocks'].iteritems(): if self._block_matches(value, qualifiers): items.append(usage_id) if len(items) > 0: return self._load_items(course, items, 0, lazy=True) else: return [] def get_instance(self, course_id, location, depth=0): """ Get an instance of this location. For now, just delegate to get_item and ignore course policy. depth (int): An argument that some module stores may use to prefetch descendants of the queried modules for more efficient results later in the request. The depth is counted in the number of calls to get_children() to cache. None indicates to cache all descendants. """ return self.get_item(location, depth=depth) def get_parent_locations(self, locator, usage_id=None): ''' Return the locations (Locators w/ usage_ids) for the parents of this location in this course. Could use get_items(location, {'children': usage_id}) but this is slightly faster. NOTE: the locator must contain the usage_id, and this code does not actually ensure usage_id exists :param locator: BlockUsageLocator restricting search scope :param usage_id: ignored. Only included for API compatibility. Specify the usage_id within the locator. ''' course = self._lookup_course(locator) items = [] for parent_id, value in course['blocks'].iteritems(): for child_id in value['fields'].get('children', []): if locator.usage_id == child_id: items.append(BlockUsageLocator(url=locator.as_course_locator(), usage_id=parent_id)) return items def get_course_index_info(self, course_locator): """ The index records the initial creation of the indexed course and tracks the current version heads. This function is primarily for test verification but may serve some more general purpose. :param course_locator: must have a course_id set :return {'org': , 'prettyid': , versions: {'draft': the head draft version id, 'published': the head published version id if any, }, 'edited_by': who created the course originally (named edited for consistency), 'edited_on': when the course was originally created } """ if course_locator.course_id is None: return None index = self.course_index.find_one({'_id': course_locator.course_id}) return index # TODO figure out a way to make this info accessible from the course descriptor def get_course_history_info(self, course_locator): """ Because xblocks doesn't give a means to separate the course structure's meta information from the course xblock's, this method will get that info for the structure as a whole. :param course_locator: :return {'original_version': the version guid of the original version of this course, 'previous_version': the version guid of the previous version, 'edited_by': who made the last change, 'edited_on': when the change was made } """ course = self._lookup_course(course_locator) return {'original_version': course['original_version'], 'previous_version': course['previous_version'], 'edited_by': course['edited_by'], 'edited_on': course['edited_on'] } def get_definition_history_info(self, definition_locator): """ Because xblocks doesn't give a means to separate the definition's meta information from the usage xblock's, this method will get that info for the definition :return {'original_version': the version guid of the original version of this course, 'previous_version': the version guid of the previous version, 'edited_by': who made the last change, 'edited_on': when the change was made } """ definition = self.definitions.find_one({'_id': definition_locator.definition_id}) if definition is None: return None return definition['edit_info'] def get_course_successors(self, course_locator, version_history_depth=1): ''' Find the version_history_depth next versions of this course. Return as a VersionTree Mostly makes sense when course_locator uses a version_guid, but because it finds all relevant next versions, these do include those created for other courses. :param course_locator: ''' if version_history_depth < 1: return None if course_locator.version_guid is None: course = self._lookup_course(course_locator) version_guid = course.version_guid else: version_guid = course_locator.version_guid # TODO if depth is significant, it may make sense to get all that have the same original_version # and reconstruct the subtree from version_guid next_entries = self.structures.find({'previous_version' : version_guid}) # must only scan cursor's once next_versions = [struct for struct in next_entries] result = {version_guid: [CourseLocator(version_guid=struct['_id']) for struct in next_versions]} depth = 1 while depth < version_history_depth and len(next_versions) > 0: depth += 1 next_entries = self.structures.find({'previous_version': {'$in': [struct['_id'] for struct in next_versions]}}) next_versions = [struct for struct in next_entries] for course_structure in next_versions: result.setdefault(course_structure['previous_version'], []).append( CourseLocator(version_guid=struct['_id'])) return VersionTree(CourseLocator(course_locator, version_guid=version_guid), result) def get_block_generations(self, block_locator): ''' Find the history of this block. Return as a VersionTree of each place the block changed (except deletion). The block's history tracks its explicit changes but not the changes in its children. ''' block_locator = block_locator.version_agnostic() course_struct = self._lookup_course(block_locator) usage_id = block_locator.usage_id update_version_field = 'blocks.{}.edit_info.update_version'.format(usage_id) all_versions_with_block = self.structures.find({'original_version': course_struct['original_version'], update_version_field: {'$exists': True}}) # find (all) root versions and build map previous: [successors] possible_roots = [] result = {} for version in all_versions_with_block: if version['_id'] == version['blocks'][usage_id]['edit_info']['update_version']: if version['blocks'][usage_id]['edit_info'].get('previous_version') is None: possible_roots.append(version['blocks'][usage_id]['edit_info']['update_version']) else: result.setdefault(version['blocks'][usage_id]['edit_info']['previous_version'], set()).add( version['blocks'][usage_id]['edit_info']['update_version']) # more than one possible_root means usage was added and deleted > 1x. if len(possible_roots) > 1: # find the history segment including block_locator's version element_to_find = course_struct['blocks'][usage_id]['edit_info']['update_version'] if element_to_find in possible_roots: possible_roots = [element_to_find] for possibility in possible_roots: if self._find_local_root(element_to_find, possibility, result): possible_roots = [possibility] break elif len(possible_roots) == 0: return None # convert the results value sets to locators for k, versions in result.iteritems(): result[k] = [BlockUsageLocator(version_guid=version, usage_id=usage_id) for version in versions] return VersionTree(BlockUsageLocator(version_guid=possible_roots[0], usage_id=usage_id), result) def get_definition_successors(self, definition_locator, version_history_depth=1): ''' Find the version_history_depth next versions of this definition. Return as a VersionTree ''' # TODO implement raise NotImplementedError() def create_definition_from_data(self, new_def_data, category, user_id): """ Pull the definition fields out of descriptor and save to the db as a new definition w/o a predecessor and return the new id. :param user_id: request.user object """ new_def_data = self._filter_special_fields(new_def_data) document = { "category" : category, "fields": new_def_data, "edit_info": { "edited_by": user_id, "edited_on": datetime.datetime.now(UTC), "previous_version": None, "original_version": None } } new_id = self.definitions.insert(document) definition_locator = DescriptionLocator(new_id) document['edit_info']['original_version'] = new_id self.definitions.update({'_id': new_id}, {'$set': {"edit_info.original_version": new_id}}) return definition_locator def update_definition_from_data(self, definition_locator, new_def_data, user_id): """ See if new_def_data differs from the persisted version. If so, update the persisted version and return the new id. :param user_id: request.user """ new_def_data = self._filter_special_fields(new_def_data) def needs_saved(): for key, value in new_def_data.iteritems(): if key not in old_definition['fields'] or value != old_definition['fields'][key]: return True for key, value in old_definition.get('fields', {}).iteritems(): if key not in new_def_data: return True # if this looks in cache rather than fresh fetches, then it will probably not detect # actual change b/c the descriptor and cache probably point to the same objects old_definition = self.definitions.find_one({'_id': definition_locator.definition_id}) if old_definition is None: raise ItemNotFoundError(definition_locator.url()) del old_definition['_id'] if needs_saved(): old_definition['fields'] = new_def_data old_definition['edit_info']['edited_by'] = user_id old_definition['edit_info']['edited_on'] = datetime.datetime.now(UTC) old_definition['edit_info']['previous_version'] = definition_locator.definition_id new_id = self.definitions.insert(old_definition) return DescriptionLocator(new_id), True else: return definition_locator, False def _generate_usage_id(self, course_blocks, category): """ Generate a somewhat readable block id unique w/in this course using the category :param course_blocks: the current list of blocks. :param category: """ # NOTE: a potential bug is that a block is deleted and another created which gets the old # block's id. a possible fix is to cache the last serial in a dict in the structure # {category: last_serial...} # A potential confusion is if the name incorporates the parent's name, then if the child # moves, its id won't change and will be confusing serial = 1 while category + str(serial) in course_blocks: serial += 1 return category + str(serial) def _generate_course_id(self, id_root): """ Generate a somewhat readable course id unique w/in this db using the id_root :param course_blocks: the current list of blocks. :param category: """ existing_uses = self.course_index.find({"_id": {"$regex": id_root}}) if existing_uses.count() > 0: max_found = 0 matcher = re.compile(id_root + r'(\d+)') for entry in existing_uses: serial = re.search(matcher, entry['_id']) if serial is not None and serial.groups > 0: value = int(serial.group(1)) if value > max_found: max_found = value return id_root + str(max_found + 1) else: return id_root # TODO Should I rewrite this to take a new xblock instance rather than to construct it? That is, require the # caller to use XModuleDescriptor.load_from_json thus reducing similar code and making the object creation and # validation behavior a responsibility of the model layer rather than the persistence layer. def create_item(self, course_or_parent_locator, category, user_id, definition_locator=None, fields=None, force=False): """ Add a descriptor to persistence as the last child of the optional parent_location or just as an element of the course (if no parent provided). Return the resulting post saved version with populated locators. If the locator is a BlockUsageLocator, then it's assumed to be the parent. If it's a CourseLocator, then it's merely the containing course. raises InsufficientSpecificationError if there is no course locator. raises VersionConflictError if course_id and version_guid given and the current version head != version_guid and force is not True. force: fork the structure and don't update the course draftVersion if the above The incoming definition_locator should either be None to indicate this is a brand new definition or a pointer to the existing definition to which this block should point or from which this was derived. If fields does not contain any Scope.content, then definition_locator must have a value meaning that this block points to the existing definition. If fields contains Scope.content and definition_locator is not None, then the Scope.content fields are assumed to be a new payload for definition_locator. Creates a new version of the course structure, creates and inserts the new block, makes the block point to the definition which may be new or a new version of an existing or an existing. Rules for course locator: * If the course locator specifies a course_id and either it doesn't specify version_guid or the one it specifies == the current draft, it progresses the course to point to the new draft and sets the active version to point to the new draft * If the locator has a course_id but its version_guid != current draft, it raises VersionConflictError. NOTE: using a version_guid will end up creating a new version of the course. Your new item won't be in the course id'd by version_guid but instead in one w/ a new version_guid. Ensure in this case that you get the new version_guid from the locator in the returned object! """ # find course_index entry if applicable and structures entry index_entry = self._get_index_if_valid(course_or_parent_locator, force) structure = self._lookup_course(course_or_parent_locator) partitioned_fields = self._partition_fields_by_scope(category, fields) new_def_data = partitioned_fields.get(Scope.content, {}) # persist the definition if persisted != passed if (definition_locator is None or definition_locator.definition_id is None): definition_locator = self.create_definition_from_data(new_def_data, category, user_id) elif new_def_data is not None: definition_locator, _ = self.update_definition_from_data(definition_locator, new_def_data, user_id) # copy the structure and modify the new one new_structure = self._version_structure(structure, user_id) # generate an id new_usage_id = self._generate_usage_id(new_structure['blocks'], category) update_version_keys = ['blocks.{}.edit_info.update_version'.format(new_usage_id)] if isinstance(course_or_parent_locator, BlockUsageLocator) and course_or_parent_locator.usage_id is not None: parent = new_structure['blocks'][course_or_parent_locator.usage_id] parent['fields'].setdefault('children', []).append(new_usage_id) parent['edit_info']['edited_on'] = datetime.datetime.now(UTC) parent['edit_info']['edited_by'] = user_id parent['edit_info']['previous_version'] = parent['edit_info']['update_version'] update_version_keys.append('blocks.{}.edit_info.update_version'.format(course_or_parent_locator.usage_id)) block_fields = partitioned_fields.get(Scope.settings, {}) if Scope.children in partitioned_fields: block_fields.update(partitioned_fields[Scope.children]) new_structure['blocks'][new_usage_id] = { "category": category, "definition": definition_locator.definition_id, "fields": block_fields, 'edit_info': { 'edited_on': datetime.datetime.now(UTC), 'edited_by': user_id, 'previous_version': None } } new_id = self.structures.insert(new_structure) update_version_payload = {key: new_id for key in update_version_keys} self.structures.update({'_id': new_id}, {'$set': update_version_payload}) # update the index entry if appropriate if index_entry is not None: self._update_head(index_entry, course_or_parent_locator.branch, new_id) course_parent = course_or_parent_locator.as_course_locator() else: course_parent = None # fetch and return the new item--fetching is unnecessary but a good qc step return self.get_item(BlockUsageLocator(course_id=course_parent, usage_id=new_usage_id, version_guid=new_id)) def create_course( self, org, prettyid, user_id, id_root=None, fields=None, master_branch='draft', versions_dict=None, root_category='course'): """ Create a new entry in the active courses index which points to an existing or new structure. Returns the course root of the resulting entry (the location has the course id) id_root: allows the caller to specify the course_id. It's a root in that, if it's already taken, this method will append things to the root to make it unique. (defaults to org) fields: if scope.settings fields provided, will set the fields of the root course object in the new course. If both settings fields and a starting version are provided (via versions_dict), it will generate a successor version to the given version, and update the settings fields with any provided values (via update not setting). fields (content): if scope.content fields provided, will update the fields of the new course xblock definition to this. Like settings fields, if provided, this will cause a new version of any given version as well as a new version of the definition (which will point to the existing one if given a version). If not provided and given a version_dict, it will reuse the same definition as that version's course (obvious since it's reusing the course). If not provided and no version_dict is given, it will be empty and get the field defaults when loaded. master_branch: the tag (key) for the version name in the dict which is the 'draft' version. Not the actual version guid, but what to call it. versions_dict: the starting version ids where the keys are the tags such as 'draft' and 'published' and the values are structure guids. If provided, the new course will reuse this version (unless you also provide any fields overrides, see above). if not provided, will create a mostly empty course structure with just a category course root xblock. """ partitioned_fields = self._partition_fields_by_scope('course', fields) block_fields = partitioned_fields.setdefault(Scope.settings, {}) if Scope.children in partitioned_fields: block_fields.update(partitioned_fields[Scope.children]) definition_fields = self._filter_special_fields(partitioned_fields.get(Scope.content, {})) # build from inside out: definition, structure, index entry # if building a wholly new structure if versions_dict is None or master_branch not in versions_dict: # create new definition and structure definition_entry = { 'category': root_category, 'fields': definition_fields, 'edit_info': { 'edited_by': user_id, 'edited_on': datetime.datetime.now(UTC), 'previous_version': None, } } definition_id = self.definitions.insert(definition_entry) definition_entry['edit_info']['original_version'] = definition_id self.definitions.update({'_id': definition_id}, {'$set': {"edit_info.original_version": definition_id}}) draft_structure = { 'root': 'course', 'previous_version': None, 'edited_by': user_id, 'edited_on': datetime.datetime.now(UTC), 'blocks': { 'course': { 'category': 'course', 'definition': definition_id, 'fields': block_fields, 'edit_info': { 'edited_on': datetime.datetime.now(UTC), 'edited_by': user_id, 'previous_version': None } } } } new_id = self.structures.insert(draft_structure) draft_structure['original_version'] = new_id self.structures.update({'_id': new_id}, {'$set': {"original_version": new_id, 'blocks.course.edit_info.update_version': new_id}}) if versions_dict is None: versions_dict = {master_branch: new_id} else: versions_dict[master_branch] = new_id else: # just get the draft_version structure draft_version = CourseLocator(version_guid=versions_dict[master_branch]) draft_structure = self._lookup_course(draft_version) if definition_fields or block_fields: draft_structure = self._version_structure(draft_structure, user_id) root_block = draft_structure['blocks'][draft_structure['root']] if block_fields is not None: root_block['fields'].update(block_fields) if definition_fields is not None: definition = self.definitions.find_one({'_id': root_block['definition']}) definition['fields'].update(definition_fields) definition['edit_info']['previous_version'] = definition['_id'] definition['edit_info']['edited_by'] = user_id definition['edit_info']['edited_on'] = datetime.datetime.now(UTC) del definition['_id'] root_block['definition'] = self.definitions.insert(definition) root_block['edit_info']['edited_on'] = datetime.datetime.now(UTC) root_block['edit_info']['edited_by'] = user_id root_block['edit_info']['previous_version'] = root_block['edit_info'].get('update_version') # insert updates the '_id' in draft_structure new_id = self.structures.insert(draft_structure) versions_dict[master_branch] = new_id self.structures.update({'_id': new_id}, {'$set': {'blocks.{}.edit_info.update_version'.format(draft_structure['root']): new_id}}) # create the index entry if id_root is None: id_root = org new_id = self._generate_course_id(id_root) index_entry = { '_id': new_id, 'org': org, 'prettyid': prettyid, 'edited_by': user_id, 'edited_on': datetime.datetime.now(UTC), 'versions': versions_dict} new_id = self.course_index.insert(index_entry) return self.get_course(CourseLocator(course_id=new_id, branch=master_branch)) def update_item(self, descriptor, user_id, force=False): """ Save the descriptor's fields. it doesn't descend the course dag to save the children. Return the new descriptor (updated location). raises ItemNotFoundError if the location does not exist. Creates a new course version. If the descriptor's location has a course_id, it moves the course head pointer. If the version_guid of the descriptor points to a non-head version and there's been an intervening change to this item, it raises a VersionConflictError unless force is True. In the force case, it forks the course but leaves the head pointer where it is (this change will not be in the course head). The implementation tries to detect which, if any changes, actually need to be saved and thus won't version the definition, structure, nor course if they didn't change. """ original_structure = self._lookup_course(descriptor.location) index_entry = self._get_index_if_valid(descriptor.location, force) descriptor.definition_locator, is_updated = self.update_definition_from_data( descriptor.definition_locator, descriptor.get_explicitly_set_fields_by_scope(Scope.content), user_id) # check children original_entry = original_structure['blocks'][descriptor.location.usage_id] if (not is_updated and descriptor.has_children and not self._xblock_lists_equal(original_entry['fields']['children'], descriptor.children)): is_updated = True # check metadata if not is_updated: is_updated = self._compare_settings( descriptor.get_explicitly_set_fields_by_scope(Scope.settings), original_entry['fields'] ) # if updated, rev the structure if is_updated: new_structure = self._version_structure(original_structure, user_id) block_data = new_structure['blocks'][descriptor.location.usage_id] block_data["definition"] = descriptor.definition_locator.definition_id block_data["fields"] = descriptor.get_explicitly_set_fields_by_scope(Scope.settings) if descriptor.has_children: block_data['fields']["children"] = [self._usage_id(child) for child in descriptor.children] block_data['edit_info'] = { 'edited_on': datetime.datetime.now(UTC), 'edited_by': user_id, 'previous_version': block_data['edit_info']['update_version'], } new_id = self.structures.insert(new_structure) self.structures.update( {'_id': new_id}, {'$set': {'blocks.{}.edit_info.update_version'.format(descriptor.location.usage_id): new_id}}) # update the index entry if appropriate if index_entry is not None: self._update_head(index_entry, descriptor.location.branch, new_id) # fetch and return the new item--fetching is unnecessary but a good qc step return self.get_item(BlockUsageLocator(descriptor.location, version_guid=new_id)) else: # nothing changed, just return the one sent in return descriptor def persist_xblock_dag(self, xblock, user_id, force=False): """ create or update the xblock and all of its children. The xblock's location must specify a course. If it doesn't specify a usage_id, then it's presumed to be new and need creation. This function descends the children performing the same operation for any that are xblocks. Any children which are usage_ids just update the children pointer. All updates go into the same course version (bulk updater). Updates the objects which came in w/ updated location and definition_location info. returns the post-persisted version of the incoming xblock. Note that its children will be ids not objects. :param xblock: the head of the dag :param user_id: who's doing the change """ # find course_index entry if applicable and structures entry index_entry = self._get_index_if_valid(xblock.location, force) structure = self._lookup_course(xblock.location) new_structure = self._version_structure(structure, user_id) changed_blocks = self._persist_subdag(xblock, user_id, new_structure['blocks']) if changed_blocks: new_id = self.structures.insert(new_structure) update_command = {} for usage_id in changed_blocks: update_command['blocks.{}.edit_info.update_version'.format(usage_id)] = new_id self.structures.update({'_id': new_id}, {'$set': update_command}) # update the index entry if appropriate if index_entry is not None: self._update_head(index_entry, xblock.location.branch, new_id) # fetch and return the new item--fetching is unnecessary but a good qc step return self.get_item(BlockUsageLocator(xblock.location, version_guid=new_id)) else: return xblock def _persist_subdag(self, xblock, user_id, structure_blocks): # persist the definition if persisted != passed new_def_data = self._filter_special_fields(xblock.get_explicitly_set_fields_by_scope(Scope.content)) if (xblock.definition_locator is None or xblock.definition_locator.definition_id is None): xblock.definition_locator = self.create_definition_from_data( new_def_data, xblock.category, user_id) is_updated = True elif new_def_data: xblock.definition_locator, is_updated = self.update_definition_from_data( xblock.definition_locator, new_def_data, user_id) if isinstance(xblock.scope_ids.usage_id.usage_id, LocalId): # generate an id is_new = True is_updated = True usage_id = self._generate_usage_id(structure_blocks, xblock.category) xblock.scope_ids.usage_id.usage_id = usage_id else: is_new = False usage_id = xblock.location.usage_id if (not is_updated and xblock.has_children and not self._xblock_lists_equal(structure_blocks[usage_id]['fields']['children'], xblock.children)): is_updated = True children = [] updated_blocks = [] if xblock.has_children: for child in xblock.children: if isinstance(child.usage_id, LocalId): child_block = xblock.system.get_block(child) updated_blocks += self._persist_subdag(child_block, user_id, structure_blocks) children.append(child_block.location.usage_id) else: children.append(child) is_updated = is_updated or updated_blocks block_fields = xblock.get_explicitly_set_fields_by_scope(Scope.settings) if not is_new and not is_updated: is_updated = self._compare_settings(block_fields, structure_blocks[usage_id]['fields']) if children: block_fields['children'] = children if is_updated: previous_version = None if is_new else structure_blocks[usage_id]['edit_info'].get('update_version') structure_blocks[usage_id] = { "category": xblock.category, "definition": xblock.definition_locator.definition_id, "fields": block_fields, 'edit_info': { 'previous_version': previous_version, 'edited_by': user_id, 'edited_on': datetime.datetime.now(UTC) } } updated_blocks.append(usage_id) return updated_blocks def _compare_settings(self, settings, original_fields): """ Return True if the settings are not == to the original fields :param settings: :param original_fields: """ original_keys = original_fields.keys() if 'children' in original_keys: original_keys.remove('children') if len(settings) != len(original_keys): return True else: new_keys = settings.keys() for key in original_keys: if key not in new_keys or original_fields[key] != settings[key]: return True def update_children(self, location, children): '''Deprecated, use update_item.''' raise NotImplementedError('use update_item') def update_metadata(self, location, metadata): '''Deprecated, use update_item.''' raise NotImplementedError('use update_item') def update_course_index(self, course_locator, new_values_dict, update_versions=False): """ Change the given course's index entry for the given fields. new_values_dict should be a subset of the dict returned by get_course_index_info. It cannot include '_id' (will raise IllegalArgument). Provide update_versions=True if you intend this to replace the versions hash. Note, this operation can be dangerous and break running courses. If the dict includes versions and not update_versions, it will raise an exception. If the dict includes edited_on or edited_by, it will raise an exception Does not return anything useful. """ # TODO how should this log the change? edited_on and edited_by for this entry # has the semantic of who created the course and when; so, changing those will lose # that information. if '_id' in new_values_dict: raise ValueError("Cannot override _id") if 'edited_on' in new_values_dict or 'edited_by' in new_values_dict: raise ValueError("Cannot set edited_on or edited_by") if not update_versions and 'versions' in new_values_dict: raise ValueError("Cannot override versions without setting update_versions") self.course_index.update({'_id': course_locator.course_id}, {'$set': new_values_dict}) def delete_item(self, usage_locator, user_id, delete_children=False, force=False): """ Delete the block or tree rooted at block (if delete_children) and any references w/in the course to the block from a new version of the course structure. returns CourseLocator for new version raises ItemNotFoundError if the location does not exist. raises ValueError if usage_locator points to the structure root Creates a new course version. If the descriptor's location has a course_id, it moves the course head pointer. If the version_guid of the descriptor points to a non-head version and there's been an intervening change to this item, it raises a VersionConflictError unless force is True. In the force case, it forks the course but leaves the head pointer where it is (this change will not be in the course head). """ assert isinstance(usage_locator, BlockUsageLocator) and usage_locator.is_initialized() original_structure = self._lookup_course(usage_locator) if original_structure['root'] == usage_locator.usage_id: raise ValueError("Cannot delete the root of a course") index_entry = self._get_index_if_valid(usage_locator, force) new_structure = self._version_structure(original_structure, user_id) new_blocks = new_structure['blocks'] parents = self.get_parent_locations(usage_locator) update_version_keys = [] for parent in parents: parent_block = new_blocks[parent.usage_id] parent_block['fields']['children'].remove(usage_locator.usage_id) parent_block['edit_info']['edited_on'] = datetime.datetime.now(UTC) parent_block['edit_info']['edited_by'] = user_id parent_block['edit_info']['previous_version'] = parent_block['edit_info']['update_version'] update_version_keys.append('blocks.{}.edit_info.update_version'.format(parent.usage_id)) # remove subtree def remove_subtree(usage_id): for child in new_blocks[usage_id]['fields'].get('children', []): remove_subtree(child) del new_blocks[usage_id] if delete_children: remove_subtree(usage_locator.usage_id) # update index if appropriate and structures new_id = self.structures.insert(new_structure) if update_version_keys: update_version_payload = {key: new_id for key in update_version_keys} self.structures.update({'_id': new_id}, {'$set': update_version_payload}) result = CourseLocator(version_guid=new_id) # update the index entry if appropriate if index_entry is not None: self._update_head(index_entry, usage_locator.branch, new_id) result.course_id = usage_locator.course_id result.branch = usage_locator.branch return result def delete_course(self, course_id): """ Remove the given course from the course index. Only removes the course from the index. The data remains. You can use create_course with a versions hash to restore the course; however, the edited_on and edited_by won't reflect the originals, of course. :param course_id: uses course_id rather than locator to emphasize its global effect """ index = self.course_index.find_one({'_id': course_id}) if index is None: raise ItemNotFoundError(course_id) # this is the only real delete in the system. should it do something else? self.course_index.remove(index['_id']) def get_errored_courses(self): """ This function doesn't make sense for the mongo modulestore, as structures are loaded on demand, rather than up front """ return {} def inherit_settings(self, block_map, block_json, inheriting_settings=None): """ Updates block_json with any inheritable setting set by an ancestor and recurses to children. """ if block_json is None: return if inheriting_settings is None: inheriting_settings = {} # the currently passed down values take precedence over any previously cached ones # NOTE: this should show the values which all fields would have if inherited: i.e., # not set to the locally defined value but to value set by nearest ancestor who sets it # ALSO NOTE: no xblock should ever define a _inherited_settings field as it will collide w/ this logic. block_json.setdefault('_inherited_settings', {}).update(inheriting_settings) # update the inheriting w/ what should pass to children inheriting_settings = block_json['_inherited_settings'].copy() block_fields = block_json['fields'] for field_name in inheritance.InheritanceMixin.fields: if field_name in block_fields: inheriting_settings[field_name] = block_fields[field_name] for child in block_fields.get('children', []): self.inherit_settings(block_map, block_map[child], inheriting_settings) def descendants(self, block_map, usage_id, depth, descendent_map): """ adds block and its descendants out to depth to descendent_map Depth specifies the number of levels of descendants to return (0 => this usage only, 1 => this usage and its children, etc...) A depth of None returns all descendants """ if usage_id not in block_map: return descendent_map if usage_id not in descendent_map: descendent_map[usage_id] = block_map[usage_id] if depth is None or depth > 0: depth = depth - 1 if depth is not None else None for child in block_map[usage_id]['fields'].get('children', []): descendent_map = self.descendants(block_map, child, depth, descendent_map) return descendent_map def definition_locator(self, definition): ''' Pull the id out of the definition w/ correct semantics for its representation ''' if isinstance(definition, DefinitionLazyLoader): return definition.definition_locator elif '_id' not in definition: return None else: return DescriptionLocator(definition['_id']) def _block_matches(self, value, qualifiers): ''' Return True or False depending on whether the value (block contents) matches the qualifiers as per get_items :param value: :param qualifiers: ''' for key, criteria in qualifiers.iteritems(): if key in value: target = value[key] if not self._value_matches(target, criteria): return False elif criteria is not None: return False return True def _value_matches(self, target, criteria): ''' helper for _block_matches ''' if isinstance(target, list): return any(self._value_matches(ele, criteria) for ele in target) elif isinstance(criteria, dict): if '$regex' in criteria: return re.search(criteria['$regex'], target) is not None elif not isinstance(target, dict): return False else: return (isinstance(target, dict) and self._block_matches(target, criteria)) else: return criteria == target def _xblock_lists_equal(self, lista, listb): """ Do the 2 lists refer to the same xblocks in the same order (presumes they're from the same course) :param lista: :param listb: """ if len(lista) != len(listb): return False for idx in enumerate(lista): if lista[idx] != listb[idx]: itema = self._usage_id(lista[idx]) if itema != self._usage_id(listb[idx]): return False return True def _usage_id(self, xblock_or_id): """ arg is either an xblock or an id. If an xblock, get the usage_id from its location. Otherwise, return itself. :param xblock_or_id: """ if isinstance(xblock_or_id, XModuleDescriptor): return xblock_or_id.location.usage_id else: return xblock_or_id def _get_index_if_valid(self, locator, force=False): """ If the locator identifies a course and points to its draft (or plausibly its draft), then return the index entry. raises VersionConflictError if not the right version :param locator: """ if locator.course_id is None or locator.branch is None: return None else: index_entry = self.course_index.find_one({'_id': locator.course_id}) if (locator.version_guid is not None and index_entry['versions'][locator.branch] != locator.version_guid and not force): raise VersionConflictError( locator, CourseLocator( course_id=index_entry['_id'], version_guid=index_entry['versions'][locator.branch], branch=locator.branch)) else: return index_entry def _version_structure(self, structure, user_id): """ Copy the structure and update the history info (edited_by, edited_on, previous_version) :param structure: :param user_id: """ new_structure = structure.copy() new_structure['blocks'] = new_structure['blocks'].copy() del new_structure['_id'] new_structure['previous_version'] = structure['_id'] new_structure['edited_by'] = user_id new_structure['edited_on'] = datetime.datetime.now(UTC) return new_structure def _find_local_root(self, element_to_find, possibility, tree): if possibility not in tree: return False if element_to_find in tree[possibility]: return True for subtree in tree[possibility]: if self._find_local_root(element_to_find, subtree, tree): return True return False def _update_head(self, index_entry, branch, new_id): """ Update the active index for the given course's branch to point to new_id :param index_entry: :param course_locator: :param new_id: """ self.course_index.update( {"_id": index_entry["_id"]}, {"$set": {"versions.{}".format(branch): new_id}}) def _partition_fields_by_scope(self, category, fields): """ Return dictionary of {scope: {field1: val, ..}..} for the fields of this potential xblock :param category: the xblock category :param fields: the dictionary of {fieldname: value} """ if fields is None: return {} cls = self.mixologist.mix(XModuleDescriptor.load_class(category)) result = collections.defaultdict(dict) for field_name, value in fields.iteritems(): field = getattr(cls, field_name) result[field.scope][field_name] = value return result def _filter_special_fields(self, fields): """ Remove any fields which split or its kvs computes or adds but does not want persisted. :param fields: a dict of fields """ if 'location' in fields: del fields['location'] if 'category' in fields: del fields['category'] return fields
agpl-3.0
[ 646, 5796, 199, 646, 2197, 199, 646, 2050, 199, 646, 21878, 199, 646, 295, 199, 504, 14802, 492, 492, 63, 578, 199, 504, 931, 492, 931, 199, 199, 504, 9872, 14, 1508, 361, 8085, 281, 492, 2973, 63, 705, 63, 8877, 199, 504, 9872, 14, 88, 63, 578, 492, 25656, 4311, 199, 504, 9872, 14, 10012, 14, 6354, 492, 8651, 7692, 10725, 12, 11994, 10725, 12, 31480, 12, 3394, 3987, 12, 10111, 1304, 199, 504, 9872, 14, 10012, 14, 3924, 492, 12062, 12983, 26235, 547, 12, 3394, 15919, 547, 199, 504, 9872, 14, 10012, 492, 15433, 12, 17996, 1563, 199, 199, 504, 2508, 3924, 492, 7020, 10870, 199, 504, 1275, 7463, 63, 6395, 63, 3422, 492, 29398, 14269, 5455, 199, 504, 1275, 22738, 63, 4120, 63, 2253, 492, 445, 23302, 4311, 3989, 199, 504, 12971, 14, 955, 492, 20488, 199, 504, 12971, 14, 7726, 492, 603, 1148, 79, 793, 631, 199, 504, 15444, 492, 12174, 199, 646, 5055, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 31436, 199, 3, 15249, 365, 737, 199, 3, 4178, 921, 8268, 13, 6797, 14, 292, 76, 2608, 290, 14, 846, 15, 6797, 15, 2918, 15, 742, 39, 15, 45, 951, 941, 720, 11, 1451, 11, 10766, 199, 3, 199, 3, 31862, 4976, 26, 199, 3, 259, 27502, 554, 367, 6328, 1022, 3122, 3181, 1133, 1736, 641, 7860, 1086, 14, 3645, 1930, 14, 199, 3, 258, 413, 9, 2225, 3925, 365, 8287, 461, 199, 3, 258, 499, 9, 486, 14, 3223, 275, 359, 80, 467, 299, 14, 3223, 275, 359, 65, 61, 199, 3, 258, 650, 9, 486, 14, 1421, 275, 413, 641, 2248, 199, 3, 258, 841, 9, 340, 486, 14, 1421, 690, 378, 12, 340, 299, 14, 1421, 690, 378, 12, 340, 282, 14, 1421, 690, 378, 1006, 3468, 715, 199, 3, 258, 959, 9, 299, 14, 1421, 275, 446, 17, 199, 3, 258, 1227, 9, 486, 14, 1421, 690, 378, 12, 299, 14, 1421, 2695, 378, 1006, 3468, 715, 5400, 199, 3, 258, 1520, 9, 699, 10134, 26, 282, 14, 1421, 690, 378, 5139, 3468, 83, 715, 1325, 1077, 506, 756, 199, 3, 258, 1695, 9, 295, 739, 436, 8137, 5419, 2451, 199, 3, 258, 1749, 9, 299, 14, 2264, 8, 1421, 395, 299, 14, 1421, 690, 378, 365, 715, 1, 5419, 199, 3, 259, 1616, 9, 699, 10134, 26, 282, 14, 1421, 665, 378, 1, 199, 3, 257, 10111, 5325, 336, 1888, 7, 19860, 590, 1736, 330, 15, 67, 12971, 1443, 2581, 282, 14, 1421, 1396, 199, 3, 199, 31436, 6905, 199, 533, 11740, 20393, 14389, 8, 14389, 1563, 304, 272, 408, 272, 437, 603, 951, 13152, 1771, 379, 17996, 21038, 5459, 12, 15433, 12, 272, 436, 26994, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1591, 12, 1592, 12, 3245, 12, 7449, 63, 1231, 12, 3795, 63, 1160, 12, 326, 1844, 29, 1465, 9570, 12, 849, 63, 533, 29, 403, 12, 326, 1125, 63, 8877, 29, 2307, 63, 705, 63, 8877, 12, 326, 922, 29, 403, 12, 2505, 29, 403, 12, 326, 18006, 63, 1419, 29, 403, 12, 326, 1011, 958, 304, 398, 1613, 8, 8862, 20393, 14389, 12, 291, 2843, 826, 14155, 958, 9, 267, 340, 18006, 63, 1419, 365, 488, 26, 288, 18006, 63, 1419, 275, 1052, 398, 291, 14, 697, 275, 21878, 14, 4659, 14, 7243, 8, 29380, 14, 20393, 3041, 8, 288, 1591, 29, 1102, 12, 288, 1844, 29, 719, 12, 288, 5823, 63, 14600, 29, 549, 12, 288, 1011, 9217, 63, 1419, 267, 2318, 1592, 9, 398, 291, 14, 1972, 63, 1080, 275, 291, 14, 697, 59, 3627, 435, 1987, 2682, 63, 6234, 418, 267, 291, 14, 13547, 275, 291, 14, 697, 59, 3627, 435, 1987, 13547, 418, 267, 291, 14, 15388, 275, 291, 14, 697, 59, 3627, 435, 1987, 15388, 418, 398, 327, 5495, 11248, 7894, 26, 7494, 1077, 473, 16667, 4811, 31, 267, 327, 485, 525, 63, 1637, 4293, 675, 282, 634, 6558, 14729, 370, 3304, 314, 2581, 1568, 31, 267, 291, 14, 2671, 63, 1637, 275, 5796, 14, 1832, 342, 398, 340, 922, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 288, 291, 14, 697, 14, 13975, 8, 751, 12, 2505, 9, 398, 327, 4036, 1145, 965, 2218, 2879, 370, 314, 1592, 334, 86, 9445, 282, 3305, 370, 6623, 519, 15, 79, 373, 2218, 9, 267, 327, 18771, 18006, 370, 3622, 2552, 12, 737, 314, 26963, 402, 10238, 267, 327, 21878, 9149, 308, 10112, 1325, 17531, 26, 267, 327, 1455, 921, 1246, 14, 22130, 13152, 14, 1308, 15, 6138, 15, 18, 14, 709, 14, 17, 15, 957, 15, 22130, 13152, 15, 3534, 714, 22082, 14, 1360, 267, 291, 14, 1972, 63, 1080, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 267, 291, 14, 13547, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 267, 291, 14, 15388, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 398, 340, 849, 63, 533, 365, 440, 488, 26, 288, 859, 63, 515, 12, 5501, 1021, 63, 354, 275, 849, 63, 533, 14, 25817, 7563, 288, 1021, 63, 275, 2519, 8, 646, 63, 578, 8, 578, 63, 515, 395, 1021, 63, 354, 9, 288, 291, 14, 885, 63, 533, 275, 1021, 63, 267, 587, 26, 288, 291, 14, 885, 63, 533, 275, 488, 267, 291, 14, 2319, 63, 1231, 275, 931, 8, 2319, 63, 1231, 9, 267, 291, 14, 705, 63, 8877, 275, 1125, 63, 8877, 267, 291, 14, 3352, 63, 1160, 275, 3795, 63, 1160, 398, 327, 3254, 26, 7529, 1133, 1172, 282, 8836, 2951, 370, 3550, 314, 5827, 20048, 3992, 334, 67, 897, 1835, 1860, 9, 267, 327, 961, 365, 1454, 1202, 701, 485, 5312, 63, 955, 63, 991, 63, 2645, 12, 1314, 365, 1454, 4346, 2952, 267, 327, 314, 3715, 18006, 3877, 365, 1202, 367, 1242, 7143, 465, 5521, 465, 1242, 26882, 267, 291, 14, 13979, 79, 793, 631, 275, 603, 1148, 79, 793, 631, 8, 277, 14, 11283, 63, 30192, 9, 339, 347, 2581, 63, 1744, 8, 277, 12, 2656, 12, 1300, 63, 3807, 63, 1580, 12, 5818, 29, 16, 12, 9617, 29, 549, 304, 267, 1449, 267, 23873, 13627, 402, 2974, 5403 ]
[ 5796, 199, 646, 2197, 199, 646, 2050, 199, 646, 21878, 199, 646, 295, 199, 504, 14802, 492, 492, 63, 578, 199, 504, 931, 492, 931, 199, 199, 504, 9872, 14, 1508, 361, 8085, 281, 492, 2973, 63, 705, 63, 8877, 199, 504, 9872, 14, 88, 63, 578, 492, 25656, 4311, 199, 504, 9872, 14, 10012, 14, 6354, 492, 8651, 7692, 10725, 12, 11994, 10725, 12, 31480, 12, 3394, 3987, 12, 10111, 1304, 199, 504, 9872, 14, 10012, 14, 3924, 492, 12062, 12983, 26235, 547, 12, 3394, 15919, 547, 199, 504, 9872, 14, 10012, 492, 15433, 12, 17996, 1563, 199, 199, 504, 2508, 3924, 492, 7020, 10870, 199, 504, 1275, 7463, 63, 6395, 63, 3422, 492, 29398, 14269, 5455, 199, 504, 1275, 22738, 63, 4120, 63, 2253, 492, 445, 23302, 4311, 3989, 199, 504, 12971, 14, 955, 492, 20488, 199, 504, 12971, 14, 7726, 492, 603, 1148, 79, 793, 631, 199, 504, 15444, 492, 12174, 199, 646, 5055, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 31436, 199, 3, 15249, 365, 737, 199, 3, 4178, 921, 8268, 13, 6797, 14, 292, 76, 2608, 290, 14, 846, 15, 6797, 15, 2918, 15, 742, 39, 15, 45, 951, 941, 720, 11, 1451, 11, 10766, 199, 3, 199, 3, 31862, 4976, 26, 199, 3, 259, 27502, 554, 367, 6328, 1022, 3122, 3181, 1133, 1736, 641, 7860, 1086, 14, 3645, 1930, 14, 199, 3, 258, 413, 9, 2225, 3925, 365, 8287, 461, 199, 3, 258, 499, 9, 486, 14, 3223, 275, 359, 80, 467, 299, 14, 3223, 275, 359, 65, 61, 199, 3, 258, 650, 9, 486, 14, 1421, 275, 413, 641, 2248, 199, 3, 258, 841, 9, 340, 486, 14, 1421, 690, 378, 12, 340, 299, 14, 1421, 690, 378, 12, 340, 282, 14, 1421, 690, 378, 1006, 3468, 715, 199, 3, 258, 959, 9, 299, 14, 1421, 275, 446, 17, 199, 3, 258, 1227, 9, 486, 14, 1421, 690, 378, 12, 299, 14, 1421, 2695, 378, 1006, 3468, 715, 5400, 199, 3, 258, 1520, 9, 699, 10134, 26, 282, 14, 1421, 690, 378, 5139, 3468, 83, 715, 1325, 1077, 506, 756, 199, 3, 258, 1695, 9, 295, 739, 436, 8137, 5419, 2451, 199, 3, 258, 1749, 9, 299, 14, 2264, 8, 1421, 395, 299, 14, 1421, 690, 378, 365, 715, 1, 5419, 199, 3, 259, 1616, 9, 699, 10134, 26, 282, 14, 1421, 665, 378, 1, 199, 3, 257, 10111, 5325, 336, 1888, 7, 19860, 590, 1736, 330, 15, 67, 12971, 1443, 2581, 282, 14, 1421, 1396, 199, 3, 199, 31436, 6905, 199, 533, 11740, 20393, 14389, 8, 14389, 1563, 304, 272, 408, 272, 437, 603, 951, 13152, 1771, 379, 17996, 21038, 5459, 12, 15433, 12, 272, 436, 26994, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 1591, 12, 1592, 12, 3245, 12, 7449, 63, 1231, 12, 3795, 63, 1160, 12, 326, 1844, 29, 1465, 9570, 12, 849, 63, 533, 29, 403, 12, 326, 1125, 63, 8877, 29, 2307, 63, 705, 63, 8877, 12, 326, 922, 29, 403, 12, 2505, 29, 403, 12, 326, 18006, 63, 1419, 29, 403, 12, 326, 1011, 958, 304, 398, 1613, 8, 8862, 20393, 14389, 12, 291, 2843, 826, 14155, 958, 9, 267, 340, 18006, 63, 1419, 365, 488, 26, 288, 18006, 63, 1419, 275, 1052, 398, 291, 14, 697, 275, 21878, 14, 4659, 14, 7243, 8, 29380, 14, 20393, 3041, 8, 288, 1591, 29, 1102, 12, 288, 1844, 29, 719, 12, 288, 5823, 63, 14600, 29, 549, 12, 288, 1011, 9217, 63, 1419, 267, 2318, 1592, 9, 398, 291, 14, 1972, 63, 1080, 275, 291, 14, 697, 59, 3627, 435, 1987, 2682, 63, 6234, 418, 267, 291, 14, 13547, 275, 291, 14, 697, 59, 3627, 435, 1987, 13547, 418, 267, 291, 14, 15388, 275, 291, 14, 697, 59, 3627, 435, 1987, 15388, 418, 398, 327, 5495, 11248, 7894, 26, 7494, 1077, 473, 16667, 4811, 31, 267, 327, 485, 525, 63, 1637, 4293, 675, 282, 634, 6558, 14729, 370, 3304, 314, 2581, 1568, 31, 267, 291, 14, 2671, 63, 1637, 275, 5796, 14, 1832, 342, 398, 340, 922, 365, 440, 488, 436, 2505, 365, 440, 488, 26, 288, 291, 14, 697, 14, 13975, 8, 751, 12, 2505, 9, 398, 327, 4036, 1145, 965, 2218, 2879, 370, 314, 1592, 334, 86, 9445, 282, 3305, 370, 6623, 519, 15, 79, 373, 2218, 9, 267, 327, 18771, 18006, 370, 3622, 2552, 12, 737, 314, 26963, 402, 10238, 267, 327, 21878, 9149, 308, 10112, 1325, 17531, 26, 267, 327, 1455, 921, 1246, 14, 22130, 13152, 14, 1308, 15, 6138, 15, 18, 14, 709, 14, 17, 15, 957, 15, 22130, 13152, 15, 3534, 714, 22082, 14, 1360, 267, 291, 14, 1972, 63, 1080, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 267, 291, 14, 13547, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 267, 291, 14, 15388, 14, 952, 63, 388, 22082, 275, 791, 87, 356, 413, 93, 398, 340, 849, 63, 533, 365, 440, 488, 26, 288, 859, 63, 515, 12, 5501, 1021, 63, 354, 275, 849, 63, 533, 14, 25817, 7563, 288, 1021, 63, 275, 2519, 8, 646, 63, 578, 8, 578, 63, 515, 395, 1021, 63, 354, 9, 288, 291, 14, 885, 63, 533, 275, 1021, 63, 267, 587, 26, 288, 291, 14, 885, 63, 533, 275, 488, 267, 291, 14, 2319, 63, 1231, 275, 931, 8, 2319, 63, 1231, 9, 267, 291, 14, 705, 63, 8877, 275, 1125, 63, 8877, 267, 291, 14, 3352, 63, 1160, 275, 3795, 63, 1160, 398, 327, 3254, 26, 7529, 1133, 1172, 282, 8836, 2951, 370, 3550, 314, 5827, 20048, 3992, 334, 67, 897, 1835, 1860, 9, 267, 327, 961, 365, 1454, 1202, 701, 485, 5312, 63, 955, 63, 991, 63, 2645, 12, 1314, 365, 1454, 4346, 2952, 267, 327, 314, 3715, 18006, 3877, 365, 1202, 367, 1242, 7143, 465, 5521, 465, 1242, 26882, 267, 291, 14, 13979, 79, 793, 631, 275, 603, 1148, 79, 793, 631, 8, 277, 14, 11283, 63, 30192, 9, 339, 347, 2581, 63, 1744, 8, 277, 12, 2656, 12, 1300, 63, 3807, 63, 1580, 12, 5818, 29, 16, 12, 9617, 29, 549, 304, 267, 1449, 267, 23873, 13627, 402, 2974, 5403, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
danakj/chromium
content/test/gpu/gpu_tests/gpu_rasterization.py
1
3218
# Copyright 2014 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 gpu_tests import cloud_storage_test_base from gpu_tests import gpu_rasterization_expectations import page_sets from telemetry.page import page_test from telemetry.util import image_util test_harness_script = r""" var domAutomationController = {}; domAutomationController._succeeded = false; domAutomationController._finished = false; domAutomationController.setAutomationId = function(id) {} domAutomationController.send = function(msg) { domAutomationController._finished = true; if (msg.toLowerCase() == "success") domAutomationController._succeeded = true; else domAutomationController._succeeded = false; } window.domAutomationController = domAutomationController; """ def _DidTestSucceed(tab): return tab.EvaluateJavaScript('domAutomationController._succeeded') class GpuRasterizationValidator(cloud_storage_test_base.ValidatorBase): def CustomizeBrowserOptions(self, options): # --test-type=gpu is used only to suppress the "Google API Keys are missing" # infobar, which causes flakiness in tests. options.AppendExtraBrowserArgs(['--enable-threaded-compositing', '--enable-impl-side-painting', '--force-gpu-rasterization', '--enable-gpu-benchmarking', '--test-type=gpu']) def ValidateAndMeasurePage(self, page, tab, results): if not _DidTestSucceed(tab): raise page_test.Failure('Page indicated a failure') if not hasattr(page, 'expectations') or not page.expectations: raise page_test.Failure('Expectations not specified') if not tab.screenshot_supported: raise page_test.Failure('Browser does not support screenshot capture') screenshot = tab.Screenshot() if screenshot is None: raise page_test.Failure('Could not capture screenshot') device_pixel_ratio = tab.EvaluateJavaScript('window.devicePixelRatio') if hasattr(page, 'test_rect'): test_rect = [int(x * device_pixel_ratio) for x in page.test_rect] screenshot = image_util.Crop(screenshot, test_rect[0], test_rect[1], test_rect[2], test_rect[3]) self._ValidateScreenshotSamples( tab, page.display_name, screenshot, page.expectations, device_pixel_ratio) class GpuRasterization(cloud_storage_test_base.CloudStorageTestBase): """Tests that GPU rasterization produces valid content""" test = GpuRasterizationValidator def __init__(self, max_failures=None): super(GpuRasterization, self).__init__(max_failures=max_failures) @classmethod def Name(cls): return 'gpu_rasterization' def CreateStorySet(self, options): story_set = page_sets.GpuRasterizationTestsStorySet(self.GetExpectations()) for page in story_set: page.script_to_evaluate_on_commit = test_harness_script return story_set def _CreateExpectations(self): return gpu_rasterization_expectations.GpuRasterizationExpectations()
bsd-3-clause
[ 3, 1898, 6927, 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, 21758, 63, 2219, 492, 8002, 63, 3494, 63, 396, 63, 1095, 199, 504, 21758, 63, 2219, 492, 21758, 63, 6360, 6236, 13362, 63, 15752, 199, 646, 2034, 63, 2193, 199, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1974, 492, 1834, 63, 1974, 421, 199, 396, 63, 23569, 63, 1579, 275, 519, 624, 523, 2729, 8266, 3358, 1615, 7506, 275, 27978, 523, 8266, 3358, 1615, 7506, 423, 20003, 275, 3055, 27, 523, 8266, 3358, 1615, 7506, 423, 8669, 275, 3055, 27, 819, 8266, 3358, 1615, 7506, 14, 409, 3358, 1615, 1304, 275, 805, 8, 344, 9, 1052, 523, 8266, 3358, 1615, 7506, 14, 2254, 275, 805, 8, 1328, 9, 469, 272, 8266, 3358, 1615, 7506, 423, 8669, 275, 2549, 27, 272, 340, 334, 1328, 14, 475, 17846, 1538, 342, 508, 298, 3742, 531, 489, 8266, 3358, 1615, 7506, 423, 20003, 275, 2549, 27, 272, 587, 489, 8266, 3358, 1615, 7506, 423, 20003, 275, 3055, 27, 523, 789, 819, 4353, 14, 4556, 3358, 1615, 7506, 275, 8266, 3358, 1615, 7506, 27, 199, 624, 199, 199, 318, 485, 17366, 774, 22937, 379, 8, 2902, 304, 523, 372, 5174, 14, 25002, 21986, 360, 4556, 3358, 1615, 7506, 423, 20003, 358, 199, 199, 533, 598, 3165, 50, 305, 6236, 13362, 8640, 8, 4091, 63, 3494, 63, 396, 63, 1095, 14, 8640, 1563, 304, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 327, 1553, 396, 13, 466, 29, 6477, 365, 1202, 1454, 370, 15678, 314, 298, 13266, 3261, 17276, 787, 4124, 2, 272, 327, 2256, 1700, 12, 1314, 14486, 17566, 75, 9585, 315, 2295, 14, 272, 1511, 14, 8310, 7426, 11930, 6213, 18510, 4296, 13, 19710, 13, 7784, 338, 1337, 297, 2511, 2850, 4296, 13, 5472, 13, 2441, 13, 17486, 316, 297, 2511, 2850, 3990, 13, 6477, 13, 6360, 6236, 13362, 297, 2511, 2850, 4296, 13, 6477, 13, 11861, 316, 297, 2511, 2850, 396, 13, 466, 29, 6477, 1105, 819, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 2058, 304, 272, 340, 440, 485, 17366, 774, 22937, 379, 8, 2902, 304, 489, 746, 2034, 63, 396, 14, 6782, 360, 3276, 22141, 282, 5988, 358, 339, 340, 440, 2688, 8, 1606, 12, 283, 15752, 358, 503, 440, 2034, 14, 15752, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 31323, 440, 2013, 358, 339, 340, 440, 5174, 14, 23269, 63, 4946, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 11930, 1630, 440, 2291, 27981, 12296, 358, 339, 27981, 275, 5174, 14, 9616, 2782, 342, 272, 340, 27981, 365, 488, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 6531, 440, 12296, 27981, 358, 339, 2243, 63, 8435, 63, 6884, 275, 5174, 14, 25002, 21986, 360, 3806, 14, 1782, 14383, 13971, 358, 272, 340, 2688, 8, 1606, 12, 283, 396, 63, 1201, 735, 489, 511, 63, 1201, 275, 359, 442, 8, 88, 627, 2243, 63, 8435, 63, 6884, 9, 367, 671, 315, 2034, 14, 396, 63, 1201, 61, 489, 27981, 275, 1834, 63, 1974, 14, 35, 2675, 8, 23269, 12, 511, 63, 1201, 59, 16, 467, 511, 63, 1201, 59, 17, 467, 3521, 511, 63, 1201, 59, 18, 467, 511, 63, 1201, 59, 19, 566, 339, 291, 423, 12584, 9616, 2782, 27665, 8, 267, 5174, 12, 267, 2034, 14, 2918, 63, 354, 12, 267, 27981, 12, 267, 2034, 14, 15752, 12, 267, 2243, 63, 8435, 63, 6884, 9, 421, 199, 533, 598, 3165, 50, 305, 6236, 13362, 8, 4091, 63, 3494, 63, 396, 63, 1095, 14, 9089, 6408, 14440, 304, 523, 408, 2925, 626, 18613, 519, 305, 6236, 13362, 16904, 1686, 1564, 624, 523, 511, 275, 598, 3165, 50, 305, 6236, 13362, 8640, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 9968, 29, 403, 304, 272, 1613, 8, 39, 3165, 50, 305, 6236, 13362, 12, 291, 2843, 826, 721, 988, 63, 9968, 29, 988, 63, 9968, 9, 819, 768, 3744, 523, 347, 2812, 8, 1886, 304, 272, 372, 283, 6477, 63, 6360, 6236, 13362, 7, 819, 347, 2790, 25120, 1084, 8, 277, 12, 1511, 304, 272, 19222, 63, 409, 275, 2034, 63, 2193, 14, 39, 3165, 50, 305, 6236, 13362, 2925, 25120, 1084, 8, 277, 14, 1002, 31323, 1012, 272, 367, 2034, 315, 19222, 63, 409, 26, 489, 2034, 14, 1579, 63, 475, 63, 7383, 63, 265, 63, 3543, 275, 511, 63, 23569, 63, 1579, 272, 372, 19222, 63, 409, 819, 347, 485, 2499, 31323, 8, 277, 304, 272, 372, 21758, 63, 6360, 6236, 13362, 63, 15752, 14, 39, 3165, 50, 305, 6236, 13362, 31323, 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 ]
[ 1898, 6927, 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, 21758, 63, 2219, 492, 8002, 63, 3494, 63, 396, 63, 1095, 199, 504, 21758, 63, 2219, 492, 21758, 63, 6360, 6236, 13362, 63, 15752, 199, 646, 2034, 63, 2193, 199, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1974, 492, 1834, 63, 1974, 421, 199, 396, 63, 23569, 63, 1579, 275, 519, 624, 523, 2729, 8266, 3358, 1615, 7506, 275, 27978, 523, 8266, 3358, 1615, 7506, 423, 20003, 275, 3055, 27, 523, 8266, 3358, 1615, 7506, 423, 8669, 275, 3055, 27, 819, 8266, 3358, 1615, 7506, 14, 409, 3358, 1615, 1304, 275, 805, 8, 344, 9, 1052, 523, 8266, 3358, 1615, 7506, 14, 2254, 275, 805, 8, 1328, 9, 469, 272, 8266, 3358, 1615, 7506, 423, 8669, 275, 2549, 27, 272, 340, 334, 1328, 14, 475, 17846, 1538, 342, 508, 298, 3742, 531, 489, 8266, 3358, 1615, 7506, 423, 20003, 275, 2549, 27, 272, 587, 489, 8266, 3358, 1615, 7506, 423, 20003, 275, 3055, 27, 523, 789, 819, 4353, 14, 4556, 3358, 1615, 7506, 275, 8266, 3358, 1615, 7506, 27, 199, 624, 199, 199, 318, 485, 17366, 774, 22937, 379, 8, 2902, 304, 523, 372, 5174, 14, 25002, 21986, 360, 4556, 3358, 1615, 7506, 423, 20003, 358, 199, 199, 533, 598, 3165, 50, 305, 6236, 13362, 8640, 8, 4091, 63, 3494, 63, 396, 63, 1095, 14, 8640, 1563, 304, 523, 347, 8388, 794, 11930, 4558, 8, 277, 12, 1511, 304, 272, 327, 1553, 396, 13, 466, 29, 6477, 365, 1202, 1454, 370, 15678, 314, 298, 13266, 3261, 17276, 787, 4124, 2, 272, 327, 2256, 1700, 12, 1314, 14486, 17566, 75, 9585, 315, 2295, 14, 272, 1511, 14, 8310, 7426, 11930, 6213, 18510, 4296, 13, 19710, 13, 7784, 338, 1337, 297, 2511, 2850, 4296, 13, 5472, 13, 2441, 13, 17486, 316, 297, 2511, 2850, 3990, 13, 6477, 13, 6360, 6236, 13362, 297, 2511, 2850, 4296, 13, 6477, 13, 11861, 316, 297, 2511, 2850, 396, 13, 466, 29, 6477, 1105, 819, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 2058, 304, 272, 340, 440, 485, 17366, 774, 22937, 379, 8, 2902, 304, 489, 746, 2034, 63, 396, 14, 6782, 360, 3276, 22141, 282, 5988, 358, 339, 340, 440, 2688, 8, 1606, 12, 283, 15752, 358, 503, 440, 2034, 14, 15752, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 31323, 440, 2013, 358, 339, 340, 440, 5174, 14, 23269, 63, 4946, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 11930, 1630, 440, 2291, 27981, 12296, 358, 339, 27981, 275, 5174, 14, 9616, 2782, 342, 272, 340, 27981, 365, 488, 26, 489, 746, 2034, 63, 396, 14, 6782, 360, 6531, 440, 12296, 27981, 358, 339, 2243, 63, 8435, 63, 6884, 275, 5174, 14, 25002, 21986, 360, 3806, 14, 1782, 14383, 13971, 358, 272, 340, 2688, 8, 1606, 12, 283, 396, 63, 1201, 735, 489, 511, 63, 1201, 275, 359, 442, 8, 88, 627, 2243, 63, 8435, 63, 6884, 9, 367, 671, 315, 2034, 14, 396, 63, 1201, 61, 489, 27981, 275, 1834, 63, 1974, 14, 35, 2675, 8, 23269, 12, 511, 63, 1201, 59, 16, 467, 511, 63, 1201, 59, 17, 467, 3521, 511, 63, 1201, 59, 18, 467, 511, 63, 1201, 59, 19, 566, 339, 291, 423, 12584, 9616, 2782, 27665, 8, 267, 5174, 12, 267, 2034, 14, 2918, 63, 354, 12, 267, 27981, 12, 267, 2034, 14, 15752, 12, 267, 2243, 63, 8435, 63, 6884, 9, 421, 199, 533, 598, 3165, 50, 305, 6236, 13362, 8, 4091, 63, 3494, 63, 396, 63, 1095, 14, 9089, 6408, 14440, 304, 523, 408, 2925, 626, 18613, 519, 305, 6236, 13362, 16904, 1686, 1564, 624, 523, 511, 275, 598, 3165, 50, 305, 6236, 13362, 8640, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 9968, 29, 403, 304, 272, 1613, 8, 39, 3165, 50, 305, 6236, 13362, 12, 291, 2843, 826, 721, 988, 63, 9968, 29, 988, 63, 9968, 9, 819, 768, 3744, 523, 347, 2812, 8, 1886, 304, 272, 372, 283, 6477, 63, 6360, 6236, 13362, 7, 819, 347, 2790, 25120, 1084, 8, 277, 12, 1511, 304, 272, 19222, 63, 409, 275, 2034, 63, 2193, 14, 39, 3165, 50, 305, 6236, 13362, 2925, 25120, 1084, 8, 277, 14, 1002, 31323, 1012, 272, 367, 2034, 315, 19222, 63, 409, 26, 489, 2034, 14, 1579, 63, 475, 63, 7383, 63, 265, 63, 3543, 275, 511, 63, 23569, 63, 1579, 272, 372, 19222, 63, 409, 819, 347, 485, 2499, 31323, 8, 277, 304, 272, 372, 21758, 63, 6360, 6236, 13362, 63, 15752, 14, 39, 3165, 50, 305, 6236, 13362, 31323, 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,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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 ]
fossoult/odoo
addons/hr/res_users.py
303
3192
from openerp import api from openerp.osv import fields, osv class res_users(osv.Model): """ Update of res.users class - if adding groups to an user, check if base.group_user is in it (member of 'Employee'), create an employee form linked to it. """ _name = 'res.users' _inherit = ['res.users'] _columns = { 'display_employees_suggestions': fields.boolean("Display Employees Suggestions"), } _defaults = { 'display_employees_suggestions': True, } def __init__(self, pool, cr): """ Override of __init__ to add access rights on display_employees_suggestions fields. Access rights are disabled by default, but allowed on some specific fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS. """ init_res = super(res_users, self).__init__(pool, cr) # duplicate list to avoid modifying the original reference self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) self.SELF_WRITEABLE_FIELDS.append('display_employees_suggestions') # duplicate list to avoid modifying the original reference self.SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS) self.SELF_READABLE_FIELDS.append('display_employees_suggestions') return init_res def stop_showing_employees_suggestions(self, cr, uid, user_id, context=None): """Update display_employees_suggestions value to False""" if context is None: context = {} self.write(cr, uid, user_id, {"display_employees_suggestions": False}, context) def _create_welcome_message(self, cr, uid, user, context=None): """Do not welcome new users anymore, welcome new employees instead""" return True def _message_post_get_eid(self, cr, uid, thread_id, context=None): assert thread_id, "res.users does not support posting global messages" if context and 'thread_model' in context: context = dict(context or {}) context['thread_model'] = 'hr.employee' if isinstance(thread_id, (list, tuple)): thread_id = thread_id[0] return self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', thread_id)], context=context) @api.cr_uid_ids_context def message_post(self, cr, uid, thread_id, context=None, **kwargs): """ Redirect the posting of message on res.users to the related employee. This is done because when giving the context of Chatter on the various mailboxes, we do not have access to the current partner_id. """ if kwargs.get('type') == 'email': return super(res_users, self).message_post(cr, uid, thread_id, context=context, **kwargs) res = None employee_ids = self._message_post_get_eid(cr, uid, thread_id, context=context) if not employee_ids: # no employee: fall back on previous behavior return super(res_users, self).message_post(cr, uid, thread_id, context=context, **kwargs) for employee_id in employee_ids: res = self.pool.get('hr.employee').message_post(cr, uid, employee_id, context=context, **kwargs) return res
agpl-3.0
[ 504, 5166, 492, 2986, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 421, 199, 533, 522, 63, 3707, 8, 4795, 14, 1685, 304, 272, 408, 6162, 402, 522, 14, 3707, 1021, 267, 446, 340, 7791, 4652, 370, 376, 922, 12, 1104, 340, 1300, 14, 923, 63, 751, 365, 315, 652, 267, 334, 1114, 402, 283, 22635, 659, 1218, 376, 15778, 1824, 10632, 370, 652, 14, 272, 408, 272, 485, 354, 275, 283, 470, 14, 3707, 7, 272, 485, 6486, 275, 788, 470, 14, 3707, 418, 339, 485, 3406, 275, 469, 267, 283, 2918, 63, 24561, 63, 19957, 15293, 356, 1504, 14, 4871, 480, 7687, 662, 311, 18149, 428, 11914, 15293, 1288, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2918, 63, 24561, 63, 19957, 15293, 356, 715, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4203, 12, 2467, 304, 267, 408, 11041, 402, 636, 826, 363, 370, 1050, 2879, 4481, 641, 267, 2929, 63, 24561, 63, 19957, 15293, 1504, 14, 11003, 4481, 787, 6980, 701, 267, 849, 12, 1325, 4370, 641, 2005, 2488, 1504, 3247, 315, 267, 291, 14, 899, 15965, 7348, 5670, 15, 10387, 93, 2617, 63, 12767, 14, 267, 408, 267, 4205, 63, 470, 275, 1613, 8, 470, 63, 3707, 12, 291, 2843, 826, 721, 2293, 12, 2467, 9, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 14, 740, 360, 2918, 63, 24561, 63, 19957, 15293, 358, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 14, 740, 360, 2918, 63, 24561, 63, 19957, 15293, 358, 267, 372, 4205, 63, 470, 339, 347, 3631, 63, 2384, 316, 63, 24561, 63, 19957, 15293, 8, 277, 12, 2467, 12, 1747, 12, 922, 63, 344, 12, 1067, 29, 403, 304, 267, 408, 4152, 2929, 63, 24561, 63, 19957, 15293, 574, 370, 756, 624, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 291, 14, 952, 8, 1556, 12, 1747, 12, 922, 63, 344, 12, 2420, 2918, 63, 24561, 63, 19957, 15293, 582, 756, 1386, 1067, 9, 339, 347, 485, 981, 63, 28508, 63, 1188, 8, 277, 12, 2467, 12, 1747, 12, 922, 12, 1067, 29, 403, 304, 267, 408, 2585, 440, 336, 14628, 892, 4390, 20827, 12, 336, 14628, 892, 9052, 18149, 3140, 624, 267, 372, 715, 339, 347, 485, 1188, 63, 1932, 63, 362, 63, 30065, 8, 277, 12, 2467, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 403, 304, 267, 702, 2462, 63, 344, 12, 298, 470, 14, 3707, 1630, 440, 2291, 25386, 2288, 3788, 2, 267, 340, 1067, 436, 283, 2671, 63, 1238, 7, 315, 1067, 26, 288, 1067, 275, 1211, 8, 1100, 503, 5009, 288, 1067, 459, 2671, 63, 1238, 418, 275, 283, 6271, 14, 10103, 7, 267, 340, 1228, 8, 2671, 63, 344, 12, 334, 513, 12, 2008, 2298, 288, 2462, 63, 344, 275, 2462, 63, 344, 59, 16, 61, 267, 372, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 751, 63, 344, 297, 6291, 2462, 63, 344, 4360, 1067, 29, 1100, 9, 339, 768, 1246, 14, 1556, 63, 1535, 63, 1580, 63, 1100, 272, 347, 1245, 63, 1932, 8, 277, 12, 2467, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 403, 12, 1011, 958, 304, 267, 408, 18532, 314, 25386, 402, 1245, 641, 522, 14, 3707, 370, 314, 4048, 15778, 14, 288, 961, 365, 4224, 2952, 1380, 15131, 314, 1067, 402, 2799, 3760, 641, 314, 288, 7750, 6016, 12922, 12, 781, 886, 440, 1172, 2879, 370, 314, 1453, 5854, 63, 344, 14, 408, 267, 340, 2074, 14, 362, 360, 466, 358, 508, 283, 2123, 356, 288, 372, 1613, 8, 470, 63, 3707, 12, 291, 680, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 522, 275, 488, 267, 15778, 63, 1580, 275, 291, 423, 1188, 63, 1932, 63, 362, 63, 30065, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 9, 267, 340, 440, 15778, 63, 1580, 26, 221, 327, 949, 15778, 26, 11264, 1771, 641, 4136, 5953, 288, 372, 1613, 8, 470, 63, 3707, 12, 291, 680, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 367, 15778, 63, 344, 315, 15778, 63, 1580, 26, 288, 522, 275, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 15778, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 372, 522, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5166, 492, 2986, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 421, 199, 533, 522, 63, 3707, 8, 4795, 14, 1685, 304, 272, 408, 6162, 402, 522, 14, 3707, 1021, 267, 446, 340, 7791, 4652, 370, 376, 922, 12, 1104, 340, 1300, 14, 923, 63, 751, 365, 315, 652, 267, 334, 1114, 402, 283, 22635, 659, 1218, 376, 15778, 1824, 10632, 370, 652, 14, 272, 408, 272, 485, 354, 275, 283, 470, 14, 3707, 7, 272, 485, 6486, 275, 788, 470, 14, 3707, 418, 339, 485, 3406, 275, 469, 267, 283, 2918, 63, 24561, 63, 19957, 15293, 356, 1504, 14, 4871, 480, 7687, 662, 311, 18149, 428, 11914, 15293, 1288, 272, 789, 339, 485, 4322, 275, 469, 267, 283, 2918, 63, 24561, 63, 19957, 15293, 356, 715, 12, 272, 789, 339, 347, 636, 826, 721, 277, 12, 4203, 12, 2467, 304, 267, 408, 11041, 402, 636, 826, 363, 370, 1050, 2879, 4481, 641, 267, 2929, 63, 24561, 63, 19957, 15293, 1504, 14, 11003, 4481, 787, 6980, 701, 267, 849, 12, 1325, 4370, 641, 2005, 2488, 1504, 3247, 315, 267, 291, 14, 899, 15965, 7348, 5670, 15, 10387, 93, 2617, 63, 12767, 14, 267, 408, 267, 4205, 63, 470, 275, 1613, 8, 470, 63, 3707, 12, 291, 2843, 826, 721, 2293, 12, 2467, 9, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 10387, 2617, 63, 12767, 14, 740, 360, 2918, 63, 24561, 63, 19957, 15293, 358, 267, 327, 9250, 769, 370, 5126, 24662, 314, 3379, 3659, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 275, 769, 8, 277, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 9, 267, 291, 14, 899, 15965, 63, 5670, 2617, 63, 12767, 14, 740, 360, 2918, 63, 24561, 63, 19957, 15293, 358, 267, 372, 4205, 63, 470, 339, 347, 3631, 63, 2384, 316, 63, 24561, 63, 19957, 15293, 8, 277, 12, 2467, 12, 1747, 12, 922, 63, 344, 12, 1067, 29, 403, 304, 267, 408, 4152, 2929, 63, 24561, 63, 19957, 15293, 574, 370, 756, 624, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 291, 14, 952, 8, 1556, 12, 1747, 12, 922, 63, 344, 12, 2420, 2918, 63, 24561, 63, 19957, 15293, 582, 756, 1386, 1067, 9, 339, 347, 485, 981, 63, 28508, 63, 1188, 8, 277, 12, 2467, 12, 1747, 12, 922, 12, 1067, 29, 403, 304, 267, 408, 2585, 440, 336, 14628, 892, 4390, 20827, 12, 336, 14628, 892, 9052, 18149, 3140, 624, 267, 372, 715, 339, 347, 485, 1188, 63, 1932, 63, 362, 63, 30065, 8, 277, 12, 2467, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 403, 304, 267, 702, 2462, 63, 344, 12, 298, 470, 14, 3707, 1630, 440, 2291, 25386, 2288, 3788, 2, 267, 340, 1067, 436, 283, 2671, 63, 1238, 7, 315, 1067, 26, 288, 1067, 275, 1211, 8, 1100, 503, 5009, 288, 1067, 459, 2671, 63, 1238, 418, 275, 283, 6271, 14, 10103, 7, 267, 340, 1228, 8, 2671, 63, 344, 12, 334, 513, 12, 2008, 2298, 288, 2462, 63, 344, 275, 2462, 63, 344, 59, 16, 61, 267, 372, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 1733, 8, 1556, 12, 1747, 12, 4274, 751, 63, 344, 297, 6291, 2462, 63, 344, 4360, 1067, 29, 1100, 9, 339, 768, 1246, 14, 1556, 63, 1535, 63, 1580, 63, 1100, 272, 347, 1245, 63, 1932, 8, 277, 12, 2467, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 403, 12, 1011, 958, 304, 267, 408, 18532, 314, 25386, 402, 1245, 641, 522, 14, 3707, 370, 314, 4048, 15778, 14, 288, 961, 365, 4224, 2952, 1380, 15131, 314, 1067, 402, 2799, 3760, 641, 314, 288, 7750, 6016, 12922, 12, 781, 886, 440, 1172, 2879, 370, 314, 1453, 5854, 63, 344, 14, 408, 267, 340, 2074, 14, 362, 360, 466, 358, 508, 283, 2123, 356, 288, 372, 1613, 8, 470, 63, 3707, 12, 291, 680, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 522, 275, 488, 267, 15778, 63, 1580, 275, 291, 423, 1188, 63, 1932, 63, 362, 63, 30065, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 9, 267, 340, 440, 15778, 63, 1580, 26, 221, 327, 949, 15778, 26, 11264, 1771, 641, 4136, 5953, 288, 372, 1613, 8, 470, 63, 3707, 12, 291, 680, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 2462, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 367, 15778, 63, 344, 315, 15778, 63, 1580, 26, 288, 522, 275, 291, 14, 2293, 14, 362, 360, 6271, 14, 10103, 1959, 1188, 63, 1932, 8, 1556, 12, 1747, 12, 15778, 63, 344, 12, 1067, 29, 1100, 12, 1011, 958, 9, 267, 372, 522, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mationic/pyload
module/network/CookieJar.py
41
1550
# -*- coding: utf-8 -*- """ 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/>. @author: mkaay, RaNaN """ from time import time class CookieJar(): def __init__(self, pluginname, account=None): self.cookies = {} self.plugin = pluginname self.account = account def addCookies(self, clist): for c in clist: name = c.split("\t")[5] self.cookies[name] = c def getCookies(self): return self.cookies.values() def parseCookie(self, name): if name in self.cookies: return self.cookies[name].split("\t")[6] else: return None def getCookie(self, name): return self.parseCookie(name) def setCookie(self, domain, name, value, path="/", exp=time()+3600*24*180): s = ".%s TRUE %s FALSE %s %s %s" % (domain, path, exp, name, value) self.cookies[name] = s def clear(self): self.cookies = {}
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 272, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 272, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 272, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 339, 768, 2502, 26, 333, 7351, 1187, 12, 3898, 14300, 199, 624, 199, 199, 504, 900, 492, 900, 199, 199, 533, 25143, 837, 272, 347, 636, 826, 721, 277, 12, 3589, 354, 12, 2933, 29, 403, 304, 267, 291, 14, 7792, 275, 1052, 267, 291, 14, 2718, 275, 3589, 354, 267, 291, 14, 2048, 275, 2933, 339, 347, 1050, 967, 5635, 8, 277, 12, 286, 513, 304, 267, 367, 286, 315, 286, 513, 26, 288, 536, 275, 286, 14, 1294, 4582, 84, 9981, 21, 61, 288, 291, 14, 7792, 59, 354, 61, 275, 286, 339, 347, 664, 967, 5635, 8, 277, 304, 267, 372, 291, 14, 7792, 14, 1459, 342, 339, 347, 2198, 7810, 8, 277, 12, 536, 304, 267, 340, 536, 315, 291, 14, 7792, 26, 288, 372, 291, 14, 7792, 59, 354, 1055, 1294, 4582, 84, 9981, 22, 61, 267, 587, 26, 288, 372, 488, 339, 347, 664, 7810, 8, 277, 12, 536, 304, 267, 372, 291, 14, 1122, 7810, 8, 354, 9, 339, 347, 663, 7810, 8, 277, 12, 2881, 12, 536, 12, 574, 12, 931, 9555, 401, 1437, 29, 521, 24543, 11035, 10, 1194, 10, 7663, 304, 267, 308, 275, 3680, 5, 83, 198, 15064, 198, 5, 83, 198, 19823, 198, 5, 83, 198, 5, 83, 198, 5, 83, 2, 450, 334, 2261, 12, 931, 12, 1437, 12, 536, 12, 574, 9, 267, 291, 14, 7792, 59, 354, 61, 275, 308, 339, 347, 5436, 8, 277, 304, 267, 291, 14, 7792, 275, 1052, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 272, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 272, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 272, 1666, 314, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 27, 340, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 339, 768, 2502, 26, 333, 7351, 1187, 12, 3898, 14300, 199, 624, 199, 199, 504, 900, 492, 900, 199, 199, 533, 25143, 837, 272, 347, 636, 826, 721, 277, 12, 3589, 354, 12, 2933, 29, 403, 304, 267, 291, 14, 7792, 275, 1052, 267, 291, 14, 2718, 275, 3589, 354, 267, 291, 14, 2048, 275, 2933, 339, 347, 1050, 967, 5635, 8, 277, 12, 286, 513, 304, 267, 367, 286, 315, 286, 513, 26, 288, 536, 275, 286, 14, 1294, 4582, 84, 9981, 21, 61, 288, 291, 14, 7792, 59, 354, 61, 275, 286, 339, 347, 664, 967, 5635, 8, 277, 304, 267, 372, 291, 14, 7792, 14, 1459, 342, 339, 347, 2198, 7810, 8, 277, 12, 536, 304, 267, 340, 536, 315, 291, 14, 7792, 26, 288, 372, 291, 14, 7792, 59, 354, 1055, 1294, 4582, 84, 9981, 22, 61, 267, 587, 26, 288, 372, 488, 339, 347, 664, 7810, 8, 277, 12, 536, 304, 267, 372, 291, 14, 1122, 7810, 8, 354, 9, 339, 347, 663, 7810, 8, 277, 12, 2881, 12, 536, 12, 574, 12, 931, 9555, 401, 1437, 29, 521, 24543, 11035, 10, 1194, 10, 7663, 304, 267, 308, 275, 3680, 5, 83, 198, 15064, 198, 5, 83, 198, 19823, 198, 5, 83, 198, 5, 83, 198, 5, 83, 2, 450, 334, 2261, 12, 931, 12, 1437, 12, 536, 12, 574, 9, 267, 291, 14, 7792, 59, 354, 61, 275, 308, 339, 347, 5436, 8, 277, 304, 267, 291, 14, 7792, 275, 1052, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
perezg/infoxchange
BASE/lib/python2.7/site-packages/django/utils/crypto.py
52
5567
""" Django's standard crypto functions and utilities. """ from __future__ import unicode_literals import hmac import struct import hashlib import binascii import operator import time from functools import reduce # Use the system PRNG if possible import random try: random = random.SystemRandom() using_sysrandom = True except NotImplementedError: import warnings warnings.warn('A secure pseudo-random number generator is not available ' 'on your system. Falling back to Mersenne Twister.') using_sysrandom = False from django.conf import settings from django.utils.encoding import force_bytes from django.utils import six from django.utils.six.moves import xrange _trans_5c = bytearray([(x ^ 0x5C) for x in xrange(256)]) _trans_36 = bytearray([(x ^ 0x36) for x in xrange(256)]) def salted_hmac(key_salt, value, secret=None): """ Returns the HMAC-SHA1 of 'value', using a key generated from key_salt and a secret (which defaults to settings.SECRET_KEY). A different key_salt should be passed in for every application of HMAC. """ if secret is None: secret = settings.SECRET_KEY # We need to generate a derived key from our base key. We can do this by # passing the key_salt and our base key through a pseudo-random function and # SHA1 works nicely. key = hashlib.sha1((key_salt + secret).encode('utf-8')).digest() # If len(key_salt + secret) > sha_constructor().block_size, the above # line is redundant and could be replaced by key = key_salt + secret, since # the hmac module does the same thing for keys longer than the block size. # However, we need to ensure that we *always* do this. return hmac.new(key, msg=force_bytes(value), digestmod=hashlib.sha1) def get_random_string(length=12, allowed_chars='abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'): """ Returns a securely generated random string. The default length of 12 with the a-z, A-Z, 0-9 character set returns a 71-bit value. log_2((26+26+10)^12) =~ 71 bits """ if not using_sysrandom: # This is ugly, and a hack, but it makes things better than # the alternative of predictability. This re-seeds the PRNG # using a value that is hard for an attacker to predict, every # time a random string is required. This may change the # properties of the chosen random sequence slightly, but this # is better than absolute predictability. random.seed( hashlib.sha256( ("%s%s%s" % ( random.getstate(), time.time(), settings.SECRET_KEY)).encode('utf-8') ).digest()) return ''.join([random.choice(allowed_chars) for i in range(length)]) def constant_time_compare(val1, val2): """ Returns True if the two strings are equal, False otherwise. The time taken is independent of the number of characters that match. """ if len(val1) != len(val2): return False result = 0 if six.PY3 and isinstance(val1, bytes) and isinstance(val2, bytes): for x, y in zip(val1, val2): result |= x ^ y else: for x, y in zip(val1, val2): result |= ord(x) ^ ord(y) return result == 0 def _bin_to_long(x): """ Convert a binary string into a long integer This is a clever optimization for fast xor vector math """ return int(binascii.hexlify(x), 16) def _long_to_bin(x, hex_format_string): """ Convert a long integer into a binary string. hex_format_string is like "%020x" for padding 10 characters. """ return binascii.unhexlify((hex_format_string % x).encode('ascii')) def _fast_hmac(key, msg, digest): """ A trimmed down version of Python's HMAC implementation. This function operates on bytes. """ dig1, dig2 = digest(), digest() if len(key) > dig1.block_size: key = digest(key).digest() key += b'\x00' * (dig1.block_size - len(key)) dig1.update(key.translate(_trans_36)) dig1.update(msg) dig2.update(key.translate(_trans_5c)) dig2.update(dig1.digest()) return dig2 def pbkdf2(password, salt, iterations, dklen=0, digest=None): """ Implements PBKDF2 as defined in RFC 2898, section 5.2 HMAC+SHA256 is used as the default pseudo random function. Right now 10,000 iterations is the recommended default which takes 100ms on a 2.2Ghz Core 2 Duo. This is probably the bare minimum for security given 1000 iterations was recommended in 2001. This code is very well optimized for CPython and is only four times slower than openssl's implementation. """ assert iterations > 0 if not digest: digest = hashlib.sha256 password = force_bytes(password) salt = force_bytes(salt) hlen = digest().digest_size if not dklen: dklen = hlen if dklen > (2 ** 32 - 1) * hlen: raise OverflowError('dklen too big') l = -(-dklen // hlen) r = dklen - (l - 1) * hlen hex_format_string = "%%0%ix" % (hlen * 2) def F(i): def U(): u = salt + struct.pack(b'>I', i) for j in xrange(int(iterations)): u = _fast_hmac(password, u, digest).digest() yield _bin_to_long(u) return _long_to_bin(reduce(operator.xor, U()), hex_format_string) T = [F(x) for x in range(1, l + 1)] return b''.join(T[:-1]) + T[-1][:r]
apache-2.0
[ 624, 199, 9323, 1159, 4465, 13230, 3423, 436, 15841, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 20330, 199, 646, 2702, 199, 646, 8337, 199, 646, 14755, 199, 646, 4182, 199, 646, 900, 199, 504, 9143, 492, 7114, 199, 199, 3, 3645, 314, 2656, 12218, 12259, 340, 3962, 199, 646, 2196, 199, 893, 26, 272, 2196, 275, 2196, 14, 3989, 3883, 342, 272, 1808, 63, 1274, 2355, 275, 715, 199, 2590, 4279, 26, 272, 492, 3598, 272, 3598, 14, 4050, 360, 33, 11153, 15984, 13, 2355, 1329, 4306, 365, 440, 2808, 283, 2116, 283, 265, 2195, 2656, 14, 481, 26039, 1771, 370, 18880, 2464, 685, 377, 87, 1429, 2659, 272, 1808, 63, 1274, 2355, 275, 756, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 421, 199, 63, 1515, 63, 21, 67, 275, 11640, 7694, 88, 7167, 378, 88, 21, 35, 9, 367, 671, 315, 4945, 8, 3912, 3948, 199, 63, 1515, 63, 1344, 275, 11640, 7694, 88, 7167, 378, 88, 1344, 9, 367, 671, 315, 4945, 8, 3912, 3948, 421, 199, 318, 18641, 471, 63, 18537, 8, 498, 63, 12597, 12, 574, 12, 7565, 29, 403, 304, 272, 408, 272, 1803, 314, 29817, 13, 8461, 17, 402, 283, 585, 297, 1808, 282, 790, 4046, 687, 790, 63, 12597, 436, 282, 272, 7565, 334, 6777, 4243, 370, 2202, 14, 12961, 63, 3078, 680, 339, 437, 3365, 790, 63, 12597, 1077, 506, 3032, 315, 367, 4036, 4223, 402, 29817, 14, 272, 408, 272, 340, 7565, 365, 488, 26, 267, 7565, 275, 2202, 14, 12961, 63, 3078, 339, 327, 2136, 1929, 370, 3550, 282, 7131, 790, 687, 4154, 1300, 790, 14, 221, 2136, 883, 886, 642, 701, 272, 327, 9476, 314, 790, 63, 12597, 436, 4154, 1300, 790, 4012, 282, 15984, 13, 2355, 805, 436, 272, 327, 12002, 17, 5419, 14213, 590, 14, 272, 790, 275, 8337, 14, 4835, 17, 1332, 498, 63, 12597, 435, 7565, 680, 2143, 360, 1624, 13, 24, 11103, 5671, 342, 339, 327, 982, 822, 8, 498, 63, 12597, 435, 7565, 9, 690, 7793, 63, 1880, 1252, 1457, 63, 890, 12, 314, 3432, 272, 327, 1004, 365, 22649, 436, 4293, 506, 8717, 701, 790, 275, 790, 63, 12597, 435, 7565, 12, 3967, 272, 327, 314, 20330, 859, 1630, 314, 2011, 8377, 367, 2883, 8088, 2419, 314, 1853, 1568, 14, 272, 327, 9738, 12, 781, 1929, 370, 4868, 626, 781, 627, 9223, 10, 886, 642, 14, 272, 372, 20330, 14, 1222, 8, 498, 12, 1499, 29, 3990, 63, 2394, 8, 585, 395, 10017, 1494, 29, 24722, 14, 4835, 17, 9, 421, 199, 318, 664, 63, 2355, 63, 875, 8, 1267, 29, 713, 12, 1993, 4370, 63, 6574, 534, 23459, 7, 2511, 283, 28114, 11371, 735, 272, 408, 272, 1803, 282, 11153, 590, 4046, 2196, 1059, 14, 339, 710, 849, 2582, 402, 3144, 543, 314, 282, 13, 90, 12, 437, 13, 58, 12, 378, 13, 25, 4528, 663, 2529, 272, 282, 17245, 13, 2075, 574, 14, 943, 63, 18, 1332, 1479, 11, 1479, 11, 709, 18979, 713, 9, 275, 94, 17245, 5821, 272, 408, 272, 340, 440, 1808, 63, 1274, 2355, 26, 267, 327, 961, 365, 23761, 12, 436, 282, 11176, 12, 1325, 652, 7704, 7645, 8034, 2419, 267, 327, 314, 13943, 402, 12610, 3616, 14, 961, 295, 13, 5176, 83, 314, 12218, 12259, 267, 327, 1808, 282, 574, 626, 365, 7508, 367, 376, 23326, 281, 370, 12610, 12, 4036, 267, 327, 900, 282, 2196, 1059, 365, 1415, 14, 961, 1443, 1570, 314, 267, 327, 4382, 402, 314, 12414, 2196, 3414, 18023, 12, 1325, 642, 267, 327, 365, 8034, 2419, 3679, 12610, 3616, 14, 267, 2196, 14, 5176, 8, 288, 8337, 14, 4835, 3912, 8, 355, 19426, 83, 5, 83, 5, 83, 2, 450, 334, 490, 2196, 14, 16011, 1062, 490, 900, 14, 521, 1062, 490, 2202, 14, 12961, 63, 3078, 4992, 2143, 360, 1624, 13, 24, 358, 355, 7092, 5671, 1012, 272, 372, 6522, 904, 779, 2355, 14, 5095, 8, 6541, 63, 6574, 9, 367, 284, 315, 1425, 8, 1267, 3948, 421, 199, 318, 4413, 63, 521, 63, 5785, 8, 637, 17, 12, 1139, 18, 304, 272, 408, 272, 1803, 715, 340, 314, 2877, 3326, 787, 4472, 12, 756, 4257, 14, 339, 710, 900, 9394, 365, 12717, 402, 314, 1329, 402, 4110, 626, 1336, 14, 272, 408, 272, 340, 822, 8, 637, 17, 9, 1137, 822, 8, 637, 18, 304, 267, 372, 756, 272, 754, 275, 378, 272, 340, 3816, 14, 4521, 19, 436, 1228, 8, 637, 17, 12, 2783, 9, 436, 1228, 8, 637, 18, 12, 2783, 304, 267, 367, 671, 12, 612, 315, 3482, 8, 637, 17, 12, 1139, 18, 304, 288, 754, 8901, 671, 7167, 612, 272, 587, 26, 267, 367, 671, 12, 612, 315, 3482, 8, 637, 17, 12, 1139, 18, 304, 288, 754, 8901, 6206, 8, 88, 9, 7167, 6206, 8, 89, 9, 272, 372, 754, 508, 378, 421, 199, 318, 485, 1393, 63, 475, 63, 2809, 8, 88, 304, 272, 408, 272, 7905, 282, 3366, 1059, 1901, 282, 1846, 3000, 339, 961, 365, 282, 15158, 422, 13712, 367, 7377, 31770, 5477, 3473, 272, 408, 272, 372, 1109, 8, 27460, 14, 20677, 8, 88, 395, 3193, 9, 421, 199, 318, 485, 2809, 63, 475, 63, 1393, 8, 88, 12, 6318, 63, 908, 63, 875, 304, 272, 408, 272, 7905, 282, 1846, 3000, 1901, 282, 3366, 1059, 14, 272, 6318, 63, 908, 63, 875, 365, 2839, 2071, 10173, 88, 2, 367, 6273, 1616, 4110, 14, 272, 408, 272, 372, 14755, 14, 324, 20677, 1332, 4097, 63, 908, 63, 875, 450, 671, 680, 2143, 360, 4371, 1333, 421, 199, 318, 485, 7015, 63, 18537, 8, 498, 12, 1499, 12, 10017, 304, 272, 408, 272, 437, 24196, 3224, 1015, 402, 2018, 1159, 29817, 4514, 14, 339, 961, 805, 1758, 2335, 641, 2783, 14, 272, 408, 272, 31190, 17, 12, 31190, 18, 275, 10017, 1062, 10017, 342, 272, 340, 822, 8, 498, 9, 690, 31190, 17, 14, 1457, 63, 890, 26, 267, 790, 275, 10017, 8, 498 ]
[ 199, 9323, 1159, 4465, 13230, 3423, 436, 15841, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 20330, 199, 646, 2702, 199, 646, 8337, 199, 646, 14755, 199, 646, 4182, 199, 646, 900, 199, 504, 9143, 492, 7114, 199, 199, 3, 3645, 314, 2656, 12218, 12259, 340, 3962, 199, 646, 2196, 199, 893, 26, 272, 2196, 275, 2196, 14, 3989, 3883, 342, 272, 1808, 63, 1274, 2355, 275, 715, 199, 2590, 4279, 26, 272, 492, 3598, 272, 3598, 14, 4050, 360, 33, 11153, 15984, 13, 2355, 1329, 4306, 365, 440, 2808, 283, 2116, 283, 265, 2195, 2656, 14, 481, 26039, 1771, 370, 18880, 2464, 685, 377, 87, 1429, 2659, 272, 1808, 63, 1274, 2355, 275, 756, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2394, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 421, 199, 63, 1515, 63, 21, 67, 275, 11640, 7694, 88, 7167, 378, 88, 21, 35, 9, 367, 671, 315, 4945, 8, 3912, 3948, 199, 63, 1515, 63, 1344, 275, 11640, 7694, 88, 7167, 378, 88, 1344, 9, 367, 671, 315, 4945, 8, 3912, 3948, 421, 199, 318, 18641, 471, 63, 18537, 8, 498, 63, 12597, 12, 574, 12, 7565, 29, 403, 304, 272, 408, 272, 1803, 314, 29817, 13, 8461, 17, 402, 283, 585, 297, 1808, 282, 790, 4046, 687, 790, 63, 12597, 436, 282, 272, 7565, 334, 6777, 4243, 370, 2202, 14, 12961, 63, 3078, 680, 339, 437, 3365, 790, 63, 12597, 1077, 506, 3032, 315, 367, 4036, 4223, 402, 29817, 14, 272, 408, 272, 340, 7565, 365, 488, 26, 267, 7565, 275, 2202, 14, 12961, 63, 3078, 339, 327, 2136, 1929, 370, 3550, 282, 7131, 790, 687, 4154, 1300, 790, 14, 221, 2136, 883, 886, 642, 701, 272, 327, 9476, 314, 790, 63, 12597, 436, 4154, 1300, 790, 4012, 282, 15984, 13, 2355, 805, 436, 272, 327, 12002, 17, 5419, 14213, 590, 14, 272, 790, 275, 8337, 14, 4835, 17, 1332, 498, 63, 12597, 435, 7565, 680, 2143, 360, 1624, 13, 24, 11103, 5671, 342, 339, 327, 982, 822, 8, 498, 63, 12597, 435, 7565, 9, 690, 7793, 63, 1880, 1252, 1457, 63, 890, 12, 314, 3432, 272, 327, 1004, 365, 22649, 436, 4293, 506, 8717, 701, 790, 275, 790, 63, 12597, 435, 7565, 12, 3967, 272, 327, 314, 20330, 859, 1630, 314, 2011, 8377, 367, 2883, 8088, 2419, 314, 1853, 1568, 14, 272, 327, 9738, 12, 781, 1929, 370, 4868, 626, 781, 627, 9223, 10, 886, 642, 14, 272, 372, 20330, 14, 1222, 8, 498, 12, 1499, 29, 3990, 63, 2394, 8, 585, 395, 10017, 1494, 29, 24722, 14, 4835, 17, 9, 421, 199, 318, 664, 63, 2355, 63, 875, 8, 1267, 29, 713, 12, 1993, 4370, 63, 6574, 534, 23459, 7, 2511, 283, 28114, 11371, 735, 272, 408, 272, 1803, 282, 11153, 590, 4046, 2196, 1059, 14, 339, 710, 849, 2582, 402, 3144, 543, 314, 282, 13, 90, 12, 437, 13, 58, 12, 378, 13, 25, 4528, 663, 2529, 272, 282, 17245, 13, 2075, 574, 14, 943, 63, 18, 1332, 1479, 11, 1479, 11, 709, 18979, 713, 9, 275, 94, 17245, 5821, 272, 408, 272, 340, 440, 1808, 63, 1274, 2355, 26, 267, 327, 961, 365, 23761, 12, 436, 282, 11176, 12, 1325, 652, 7704, 7645, 8034, 2419, 267, 327, 314, 13943, 402, 12610, 3616, 14, 961, 295, 13, 5176, 83, 314, 12218, 12259, 267, 327, 1808, 282, 574, 626, 365, 7508, 367, 376, 23326, 281, 370, 12610, 12, 4036, 267, 327, 900, 282, 2196, 1059, 365, 1415, 14, 961, 1443, 1570, 314, 267, 327, 4382, 402, 314, 12414, 2196, 3414, 18023, 12, 1325, 642, 267, 327, 365, 8034, 2419, 3679, 12610, 3616, 14, 267, 2196, 14, 5176, 8, 288, 8337, 14, 4835, 3912, 8, 355, 19426, 83, 5, 83, 5, 83, 2, 450, 334, 490, 2196, 14, 16011, 1062, 490, 900, 14, 521, 1062, 490, 2202, 14, 12961, 63, 3078, 4992, 2143, 360, 1624, 13, 24, 358, 355, 7092, 5671, 1012, 272, 372, 6522, 904, 779, 2355, 14, 5095, 8, 6541, 63, 6574, 9, 367, 284, 315, 1425, 8, 1267, 3948, 421, 199, 318, 4413, 63, 521, 63, 5785, 8, 637, 17, 12, 1139, 18, 304, 272, 408, 272, 1803, 715, 340, 314, 2877, 3326, 787, 4472, 12, 756, 4257, 14, 339, 710, 900, 9394, 365, 12717, 402, 314, 1329, 402, 4110, 626, 1336, 14, 272, 408, 272, 340, 822, 8, 637, 17, 9, 1137, 822, 8, 637, 18, 304, 267, 372, 756, 272, 754, 275, 378, 272, 340, 3816, 14, 4521, 19, 436, 1228, 8, 637, 17, 12, 2783, 9, 436, 1228, 8, 637, 18, 12, 2783, 304, 267, 367, 671, 12, 612, 315, 3482, 8, 637, 17, 12, 1139, 18, 304, 288, 754, 8901, 671, 7167, 612, 272, 587, 26, 267, 367, 671, 12, 612, 315, 3482, 8, 637, 17, 12, 1139, 18, 304, 288, 754, 8901, 6206, 8, 88, 9, 7167, 6206, 8, 89, 9, 272, 372, 754, 508, 378, 421, 199, 318, 485, 1393, 63, 475, 63, 2809, 8, 88, 304, 272, 408, 272, 7905, 282, 3366, 1059, 1901, 282, 1846, 3000, 339, 961, 365, 282, 15158, 422, 13712, 367, 7377, 31770, 5477, 3473, 272, 408, 272, 372, 1109, 8, 27460, 14, 20677, 8, 88, 395, 3193, 9, 421, 199, 318, 485, 2809, 63, 475, 63, 1393, 8, 88, 12, 6318, 63, 908, 63, 875, 304, 272, 408, 272, 7905, 282, 1846, 3000, 1901, 282, 3366, 1059, 14, 272, 6318, 63, 908, 63, 875, 365, 2839, 2071, 10173, 88, 2, 367, 6273, 1616, 4110, 14, 272, 408, 272, 372, 14755, 14, 324, 20677, 1332, 4097, 63, 908, 63, 875, 450, 671, 680, 2143, 360, 4371, 1333, 421, 199, 318, 485, 7015, 63, 18537, 8, 498, 12, 1499, 12, 10017, 304, 272, 408, 272, 437, 24196, 3224, 1015, 402, 2018, 1159, 29817, 4514, 14, 339, 961, 805, 1758, 2335, 641, 2783, 14, 272, 408, 272, 31190, 17, 12, 31190, 18, 275, 10017, 1062, 10017, 342, 272, 340, 822, 8, 498, 9, 690, 31190, 17, 14, 1457, 63, 890, 26, 267, 790, 275, 10017, 8, 498, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
lsk112233/Clone-test-repo
events/models.py
1
9946
import datetime from dateutil.rrule import rrule, YEARLY, MONTHLY, WEEKLY, DAILY from operator import itemgetter from django.conf import settings from django.core.urlresolvers import reverse from django.db import models from django.db.models import Q from django.template.defaultfilters import date from django.utils import timezone from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from cms.models import ContentManageable, NameSlugModel from markupfield.fields import MarkupField from timedelta.fields import TimedeltaField from timedelta.helpers import nice_repr as timedelta_nice_repr from timedelta.helpers import parse as timedelta_parse from .utils import minutes_resolution DEFAULT_MARKUP_TYPE = getattr(settings, 'DEFAULT_MARKUP_TYPE', 'restructuredtext') # Create your models here. class Calendar(ContentManageable): url = models.URLField('URL iCal', blank=True, null=True) rss = models.URLField('RSS Feed', blank=True, null=True) embed = models.URLField('URL embed', blank=True, null=True) twitter = models.URLField('Twitter feed', blank=True, null=True) name = models.CharField(max_length=100) slug = models.SlugField(unique=True) description = models.CharField(max_length=255, null=True, blank=True) def __str__(self): return self.name def get_absolute_url(self): return reverse('events:event_list', kwargs={'calendar_slug': self.slug}) def from_url(self, url=None): if url is None and self.url is None: raise RuntimeError("Calendar must have a url field set, or you must pass a URL to `.import_ics()`.") if url is None: url = self.url from .importer import ICSImporter importer = ICSImporter(calendar=self) importer.from_url(url) class EventCategory(NameSlugModel): calendar = models.ForeignKey(Calendar, related_name='categories', null=True, blank=True) class Meta: verbose_name_plural = 'event categories' ordering = ('name',) def get_absolute_url(self): return reverse('events:eventlist_category', kwargs={'calendar_slug': self.calendar.slug, 'slug': self.slug}) class EventLocation(models.Model): calendar = models.ForeignKey(Calendar, related_name='locations', null=True, blank=True) name = models.CharField(max_length=255) address = models.CharField(blank=True, null=True, max_length=255) url = models.URLField('URL', blank=True, null=True) class Meta: ordering = ('name',) def __str__(self): return self.name def get_absolute_url(self): return reverse('events:eventlist_location', kwargs={'calendar_slug': self.calendar.slug, 'pk': self.pk}) class EventManager(models.Manager): def for_datetime(self, dt=None): if dt is None: dt = timezone.now() return self.filter(Q(occurring_rule__dt_start__gt=dt) | Q(recurring_rules__finish__gt=dt)) def until_datetime(self, dt=None): if dt is None: dt = timezone.now() return self.filter(Q(occurring_rule__dt_end__lt=dt) | Q(recurring_rules__begin__lt=dt)) class Event(ContentManageable): uid = models.CharField(max_length=200, null=True, blank=True) title = models.CharField(max_length=200) calendar = models.ForeignKey(Calendar, related_name='events') description = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE, escape_html=False) venue = models.ForeignKey(EventLocation, null=True, blank=True, related_name='events') categories = models.ManyToManyField(EventCategory, related_name='events', blank=True, null=True) featured = models.BooleanField(default=False, db_index=True) objects = EventManager() class Meta: ordering = ('-occurring_rule__dt_start',) def __str__(self): return self.title def get_absolute_url(self): return reverse('events:event_detail', kwargs={'calendar_slug': self.calendar.slug, 'pk': self.pk}) @cached_property def previous_event(self): dt = self.next_time.dt_end try: return Event.objects.until_datetime(dt).filter(calendar=self.calendar)[0] except IndexError: return None @cached_property def next_event(self): dt = self.next_time.dt_start try: return Event.objects.for_datetime(dt).filter(calendar=self.calendar)[0] except IndexError: return None @property def next_time(self): """ Return the OccurringRule or RecurringRule with the closest `dt_start` from now. """ now = timezone.now() recurring_start = occurring_start = None try: occurring_rule = self.occurring_rule except OccurringRule.DoesNotExist: pass else: if occurring_rule and occurring_rule.dt_start > now: occurring_start = (occurring_rule.dt_start, occurring_rule) rrules = self.recurring_rules.filter(finish__gt=now) recurring_starts = [(rule.dt_start, rule) for rule in rrules if rule.dt_start is not None] recurring_starts.sort(key=itemgetter(0)) try: recurring_start = recurring_starts[0] except IndexError: pass starts = [i for i in (recurring_start, occurring_start) if i is not None] starts.sort(key=itemgetter(0)) try: return starts[0][1] except IndexError: return None @property def previous_time(self): now = timezone.now() recurring_end = occurring_end = None try: occurring_rule = self.occurring_rule except OccurringRule.DoesNotExist: pass else: if occurring_rule and occurring_rule.dt_end < now: occurring_end = (occurring_rule.dt_end, occurring_rule) rrules = self.recurring_rules.filter(begin__lt=now) recurring_ends = [(rule.dt_end, rule) for rule in rrules if rule.dt_end is not None] recurring_ends.sort(key=itemgetter(0), reverse=True) try: recurring_end = recurring_ends[0] except IndexError: pass ends = [i for i in (recurring_end, occurring_end) if i is not None] ends.sort(key=itemgetter(0), reverse=True) try: return ends[0][1] except IndexError: return None @property def next_or_previous_time(self): return self.next_time or self.previous_time @property def is_past(self): return self.next_time == None class RuleMixin(object): def valid_dt_end(self): return minutes_resolution(self.dt_end) > minutes_resolution(self.dt_start) class OccurringRule(RuleMixin, models.Model): """ A single occurrence of an Event. Shares the same API of `RecurringRule`. """ event = models.OneToOneField(Event, related_name='occurring_rule') dt_start = models.DateTimeField(default=timezone.now) dt_end = models.DateTimeField(default=timezone.now) def __str__(self): strftime = settings.SHORT_DATETIME_FORMAT return '%s %s - %s' % (self.event.title, date(self.dt_start.strftime, strftime), date(self.dt_end.strftime, strftime)) @property def begin(self): return self.dt_start @property def finish(self): return self.dt_end @property def duration(self): return self.dt_end - self.dt_start @property def single_day(self): return self.dt_start.date() == self.dt_end.date() class RecurringRule(RuleMixin, models.Model): """ A repeating occurrence of an Event. Shares the same API of `OccurringRule`. """ FREQ_CHOICES = ( (YEARLY, 'year(s)'), (MONTHLY, 'month(s)'), (WEEKLY, 'week(s)'), (DAILY, 'day(s)'), ) event = models.ForeignKey(Event, related_name='recurring_rules') begin = models.DateTimeField(default=timezone.now) finish = models.DateTimeField(default=timezone.now) duration = TimedeltaField(default='15 mins') interval = models.PositiveSmallIntegerField(default=1) frequency = models.PositiveSmallIntegerField(FREQ_CHOICES, default=WEEKLY) def __str__(self): strftime = settings.SHORT_DATETIME_FORMAT return '%s every %s since %s' % (self.event.title, timedelta_nice_repr(self.interval), date(self.dt_start.strftime, strftime)) def to_rrule(self): return rrule( freq=self.frequency, interval=self.interval, dtstart=self.begin, until=self.finish, ) @property def freq_interval_as_timedelta(self): timedelta_frequencies = { YEARLY: datetime.timedelta(days=365), MONTHLY: datetime.timedelta(days=30), WEEKLY: datetime.timedelta(days=7), DAILY: datetime.timedelta(days=1), } return self.interval * timedelta_frequencies[self.frequency] @property def dt_start(self): since = timezone.now() return self.to_rrule().after(since) @property def dt_end(self): duration = self.duration if not isinstance(duration, datetime.timedelta): duration = timedelta_parse(duration) return self.dt_start + duration @property def single_day(self): return self.dt_start.date() == self.dt_end.date() class Alarm(ContentManageable): event = models.ForeignKey(Event) trigger = models.PositiveSmallIntegerField(_("hours before the event occurs"), default=24) def __str__(self): return 'Alarm for %s to %s' % (self.event.title, self.recipient) @property def recipient(self): full_name = self.creator.get_full_name() if full_name: return "%s <%s>" % (full_name, self.creator.email) return self.creator.email
apache-2.0
[ 646, 2197, 199, 504, 22208, 14, 82, 2200, 492, 519, 2200, 12, 1488, 15550, 6084, 12, 603, 615, 2080, 6084, 12, 644, 8699, 43, 6084, 12, 577, 6593, 57, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 1434, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 19240, 14, 992, 492, 6646, 20588, 461, 12, 2812, 15554, 1685, 199, 199, 504, 9189, 698, 14, 955, 492, 17504, 792, 199, 504, 6871, 14, 955, 492, 4703, 3136, 792, 199, 504, 6871, 14, 7546, 492, 14213, 63, 2722, 465, 6871, 63, 22746, 63, 2722, 199, 504, 6871, 14, 7546, 492, 2198, 465, 6871, 63, 1122, 199, 199, 504, 1275, 1208, 492, 9395, 63, 12588, 199, 199, 3472, 63, 10520, 2160, 63, 2711, 275, 2519, 8, 1751, 12, 283, 3472, 63, 10520, 2160, 63, 2711, 297, 283, 26854, 358, 421, 199, 3, 2790, 2195, 1709, 2348, 14, 199, 533, 27779, 8, 2714, 20588, 461, 304, 272, 1166, 275, 1709, 14, 17363, 360, 2632, 284, 6584, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 32291, 275, 1709, 14, 17363, 360, 22786, 16261, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 6441, 275, 1709, 14, 17363, 360, 2632, 6441, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 15811, 275, 1709, 14, 17363, 360, 24540, 4733, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 272, 1369, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 63, 513, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 5464, 1552, 339, 347, 687, 63, 633, 8, 277, 12, 1166, 29, 403, 304, 267, 340, 1166, 365, 488, 436, 291, 14, 633, 365, 488, 26, 288, 746, 6064, 480, 18688, 1471, 1172, 282, 1166, 901, 663, 12, 503, 1265, 1471, 986, 282, 2851, 370, 19853, 646, 63, 2932, 25593, 531, 267, 340, 1166, 365, 488, 26, 288, 1166, 275, 291, 14, 633, 267, 687, 1275, 12138, 492, 473, 35, 2684, 311, 3968, 267, 13479, 275, 473, 35, 2684, 311, 3968, 8, 8183, 29, 277, 9, 267, 13479, 14, 504, 63, 633, 8, 633, 9, 421, 199, 533, 6763, 7841, 8, 985, 15554, 1685, 304, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 8906, 297, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 63, 10019, 275, 283, 1430, 9695, 7, 267, 7794, 275, 661, 354, 9538, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 513, 63, 3710, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 8183, 14, 5464, 12, 283, 5464, 356, 291, 14, 5464, 1552, 421, 199, 533, 6763, 6592, 8, 992, 14, 1685, 304, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 8022, 297, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 2287, 275, 1709, 14, 2183, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 1390, 63, 1267, 29, 2299, 9, 272, 1166, 275, 1709, 14, 17363, 360, 2632, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 513, 63, 1985, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 8183, 14, 5464, 12, 283, 2051, 356, 291, 14, 2051, 1552, 421, 199, 533, 6763, 2988, 8, 992, 14, 2988, 304, 272, 347, 367, 63, 2083, 8, 277, 12, 4487, 29, 403, 304, 267, 340, 4487, 365, 488, 26, 288, 4487, 275, 7137, 14, 2131, 342, 267, 372, 291, 14, 1541, 8, 49, 8, 20051, 5985, 63, 2200, 363, 3583, 63, 928, 363, 3308, 29, 3583, 9, 1204, 1413, 8, 6794, 5985, 63, 4423, 363, 8192, 363, 3308, 29, 3583, 430, 339, 347, 5133, 63, 2083, 8, 277, 12, 4487, 29, 403, 304, 267, 340, 4487, 365, 488, 26, 288, 4487, 275, 7137, 14, 2131, 342, 267, 372, 291, 14, 1541, 8, 49, 8, 20051, 5985, 63, 2200, 363, 3583, 63, 500, 363, 4116, 29, 3583, 9, 1204, 1413, 8, 6794, 5985, 63, 4423, 363, 5037, 363, 4116, 29, 3583, 430, 421, 199, 533, 6763, 8, 2714, 20588, 461, 304, 272, 1747, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 4368, 358, 339, 1369, 275, 17504, 792, 8, 885, 63, 10131, 63, 466, 29, 3472, 63, 10520, 2160, 63, 2711, 12, 4772, 63, 1360, 29, 797, 9, 272, 373, 287, 310, 275, 1709, 14, 3190, 8, 2390, 6592, 12, 2973, 29, 549, 12, 4596, 29, 549, 12, 4048, 63, 354, 534, 4368, 358, 339, 9695, 275, 1709, 14, 7624, 8, 2390, 7841, 12, 4048, 63, 354, 534, 4368, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 13953, 3297, 275, 1709, 14, 5036, 8, 885, 29, 797, 12, 1592, 63, 1080, 29, 549, 9, 339, 2251, 275, 6763, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 12291, 20051, 5985, 63, 2200, 363, 3583, 63, 928, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291 ]
[ 2197, 199, 504, 22208, 14, 82, 2200, 492, 519, 2200, 12, 1488, 15550, 6084, 12, 603, 615, 2080, 6084, 12, 644, 8699, 43, 6084, 12, 577, 6593, 57, 199, 504, 4182, 492, 1242, 7416, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 1434, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 504, 19240, 14, 992, 492, 6646, 20588, 461, 12, 2812, 15554, 1685, 199, 199, 504, 9189, 698, 14, 955, 492, 17504, 792, 199, 504, 6871, 14, 955, 492, 4703, 3136, 792, 199, 504, 6871, 14, 7546, 492, 14213, 63, 2722, 465, 6871, 63, 22746, 63, 2722, 199, 504, 6871, 14, 7546, 492, 2198, 465, 6871, 63, 1122, 199, 199, 504, 1275, 1208, 492, 9395, 63, 12588, 199, 199, 3472, 63, 10520, 2160, 63, 2711, 275, 2519, 8, 1751, 12, 283, 3472, 63, 10520, 2160, 63, 2711, 297, 283, 26854, 358, 421, 199, 3, 2790, 2195, 1709, 2348, 14, 199, 533, 27779, 8, 2714, 20588, 461, 304, 272, 1166, 275, 1709, 14, 17363, 360, 2632, 284, 6584, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 32291, 275, 1709, 14, 17363, 360, 22786, 16261, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 6441, 275, 1709, 14, 17363, 360, 2632, 6441, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 15811, 275, 1709, 14, 17363, 360, 24540, 4733, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8889, 275, 1709, 14, 17315, 8, 3235, 29, 549, 9, 272, 1369, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 63, 513, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 5464, 1552, 339, 347, 687, 63, 633, 8, 277, 12, 1166, 29, 403, 304, 267, 340, 1166, 365, 488, 436, 291, 14, 633, 365, 488, 26, 288, 746, 6064, 480, 18688, 1471, 1172, 282, 1166, 901, 663, 12, 503, 1265, 1471, 986, 282, 2851, 370, 19853, 646, 63, 2932, 25593, 531, 267, 340, 1166, 365, 488, 26, 288, 1166, 275, 291, 14, 633, 267, 687, 1275, 12138, 492, 473, 35, 2684, 311, 3968, 267, 13479, 275, 473, 35, 2684, 311, 3968, 8, 8183, 29, 277, 9, 267, 13479, 14, 504, 63, 633, 8, 633, 9, 421, 199, 533, 6763, 7841, 8, 985, 15554, 1685, 304, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 8906, 297, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 1021, 6288, 26, 267, 3376, 63, 354, 63, 10019, 275, 283, 1430, 9695, 7, 267, 7794, 275, 661, 354, 9538, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 513, 63, 3710, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 8183, 14, 5464, 12, 283, 5464, 356, 291, 14, 5464, 1552, 421, 199, 533, 6763, 6592, 8, 992, 14, 1685, 304, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 8022, 297, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 2287, 275, 1709, 14, 2183, 8, 2500, 29, 549, 12, 2973, 29, 549, 12, 1390, 63, 1267, 29, 2299, 9, 272, 1166, 275, 1709, 14, 17363, 360, 2632, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 339, 1021, 6288, 26, 267, 7794, 275, 661, 354, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 347, 664, 63, 6116, 63, 633, 8, 277, 304, 267, 372, 3837, 360, 4368, 26, 1430, 513, 63, 1985, 297, 2074, 3713, 8183, 63, 5464, 356, 291, 14, 8183, 14, 5464, 12, 283, 2051, 356, 291, 14, 2051, 1552, 421, 199, 533, 6763, 2988, 8, 992, 14, 2988, 304, 272, 347, 367, 63, 2083, 8, 277, 12, 4487, 29, 403, 304, 267, 340, 4487, 365, 488, 26, 288, 4487, 275, 7137, 14, 2131, 342, 267, 372, 291, 14, 1541, 8, 49, 8, 20051, 5985, 63, 2200, 363, 3583, 63, 928, 363, 3308, 29, 3583, 9, 1204, 1413, 8, 6794, 5985, 63, 4423, 363, 8192, 363, 3308, 29, 3583, 430, 339, 347, 5133, 63, 2083, 8, 277, 12, 4487, 29, 403, 304, 267, 340, 4487, 365, 488, 26, 288, 4487, 275, 7137, 14, 2131, 342, 267, 372, 291, 14, 1541, 8, 49, 8, 20051, 5985, 63, 2200, 363, 3583, 63, 500, 363, 4116, 29, 3583, 9, 1204, 1413, 8, 6794, 5985, 63, 4423, 363, 5037, 363, 4116, 29, 3583, 430, 421, 199, 533, 6763, 8, 2714, 20588, 461, 304, 272, 1747, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 11234, 275, 1709, 14, 3190, 8, 18688, 12, 4048, 63, 354, 534, 4368, 358, 339, 1369, 275, 17504, 792, 8, 885, 63, 10131, 63, 466, 29, 3472, 63, 10520, 2160, 63, 2711, 12, 4772, 63, 1360, 29, 797, 9, 272, 373, 287, 310, 275, 1709, 14, 3190, 8, 2390, 6592, 12, 2973, 29, 549, 12, 4596, 29, 549, 12, 4048, 63, 354, 534, 4368, 358, 339, 9695, 275, 1709, 14, 7624, 8, 2390, 7841, 12, 4048, 63, 354, 534, 4368, 297, 4596, 29, 549, 12, 2973, 29, 549, 9, 272, 13953, 3297, 275, 1709, 14, 5036, 8, 885, 29, 797, 12, 1592, 63, 1080, 29, 549, 9, 339, 2251, 275, 6763, 2988, 342, 339, 1021, 6288, 26, 267, 7794, 275, 12291, 20051, 5985, 63, 2200, 363, 3583, 63, 928, 9538, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gmcastil/numpy
numpy/doc/structured_arrays.py
56
11442
""" ================= Structured Arrays ================= Introduction ============ NumPy provides powerful capabilities to create arrays of structured datatype. These arrays permit one to manipulate the data by named fields. A simple example will show what is meant.: :: >>> x = np.array([(1,2.,'Hello'), (2,3.,"World")], ... dtype=[('foo', 'i4'),('bar', 'f4'), ('baz', 'S10')]) >>> x array([(1, 2.0, 'Hello'), (2, 3.0, 'World')], dtype=[('foo', '>i4'), ('bar', '>f4'), ('baz', '|S10')]) Here we have created a one-dimensional array of length 2. Each element of this array is a structure that contains three items, a 32-bit integer, a 32-bit float, and a string of length 10 or less. If we index this array at the second position we get the second structure: :: >>> x[1] (2,3.,"World") Conveniently, one can access any field of the array by indexing using the string that names that field. :: >>> y = x['bar'] >>> y array([ 2., 3.], dtype=float32) >>> y[:] = 2*y >>> y array([ 4., 6.], dtype=float32) >>> x array([(1, 4.0, 'Hello'), (2, 6.0, 'World')], dtype=[('foo', '>i4'), ('bar', '>f4'), ('baz', '|S10')]) In these examples, y is a simple float array consisting of the 2nd field in the structured type. But, rather than being a copy of the data in the structured array, it is a view, i.e., it shares exactly the same memory locations. Thus, when we updated this array by doubling its values, the structured array shows the corresponding values as doubled as well. Likewise, if one changes the structured array, the field view also changes: :: >>> x[1] = (-1,-1.,"Master") >>> x array([(1, 4.0, 'Hello'), (-1, -1.0, 'Master')], dtype=[('foo', '>i4'), ('bar', '>f4'), ('baz', '|S10')]) >>> y array([ 4., -1.], dtype=float32) Defining Structured Arrays ========================== One defines a structured array through the dtype object. There are **several** alternative ways to define the fields of a record. Some of these variants provide backward compatibility with Numeric, numarray, or another module, and should not be used except for such purposes. These will be so noted. One specifies record structure in one of four alternative ways, using an argument (as supplied to a dtype function keyword or a dtype object constructor itself). This argument must be one of the following: 1) string, 2) tuple, 3) list, or 4) dictionary. Each of these is briefly described below. 1) String argument. In this case, the constructor expects a comma-separated list of type specifiers, optionally with extra shape information. The fields are given the default names 'f0', 'f1', 'f2' and so on. The type specifiers can take 4 different forms: :: a) b1, i1, i2, i4, i8, u1, u2, u4, u8, f2, f4, f8, c8, c16, a<n> (representing bytes, ints, unsigned ints, floats, complex and fixed length strings of specified byte lengths) b) int8,...,uint8,...,float16, float32, float64, complex64, complex128 (this time with bit sizes) c) older Numeric/numarray type specifications (e.g. Float32). Don't use these in new code! d) Single character type specifiers (e.g H for unsigned short ints). Avoid using these unless you must. Details can be found in the NumPy book These different styles can be mixed within the same string (but why would you want to do that?). Furthermore, each type specifier can be prefixed with a repetition number, or a shape. In these cases an array element is created, i.e., an array within a record. That array is still referred to as a single field. An example: :: >>> x = np.zeros(3, dtype='3int8, float32, (2,3)float64') >>> x array([([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]), ([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]), ([0, 0, 0], 0.0, [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])], dtype=[('f0', '|i1', 3), ('f1', '>f4'), ('f2', '>f8', (2, 3))]) By using strings to define the record structure, it precludes being able to name the fields in the original definition. The names can be changed as shown later, however. 2) Tuple argument: The only relevant tuple case that applies to record structures is when a structure is mapped to an existing data type. This is done by pairing in a tuple, the existing data type with a matching dtype definition (using any of the variants being described here). As an example (using a definition using a list, so see 3) for further details): :: >>> x = np.zeros(3, dtype=('i4',[('r','u1'), ('g','u1'), ('b','u1'), ('a','u1')])) >>> x array([0, 0, 0]) >>> x['r'] array([0, 0, 0], dtype=uint8) In this case, an array is produced that looks and acts like a simple int32 array, but also has definitions for fields that use only one byte of the int32 (a bit like Fortran equivalencing). 3) List argument: In this case the record structure is defined with a list of tuples. Each tuple has 2 or 3 elements specifying: 1) The name of the field ('' is permitted), 2) the type of the field, and 3) the shape (optional). For example:: >>> x = np.zeros(3, dtype=[('x','f4'),('y',np.float32),('value','f4',(2,2))]) >>> x array([(0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]]), (0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]]), (0.0, 0.0, [[0.0, 0.0], [0.0, 0.0]])], dtype=[('x', '>f4'), ('y', '>f4'), ('value', '>f4', (2, 2))]) 4) Dictionary argument: two different forms are permitted. The first consists of a dictionary with two required keys ('names' and 'formats'), each having an equal sized list of values. The format list contains any type/shape specifier allowed in other contexts. The names must be strings. There are two optional keys: 'offsets' and 'titles'. Each must be a correspondingly matching list to the required two where offsets contain integer offsets for each field, and titles are objects containing metadata for each field (these do not have to be strings), where the value of None is permitted. As an example: :: >>> x = np.zeros(3, dtype={'names':['col1', 'col2'], 'formats':['i4','f4']}) >>> x array([(0, 0.0), (0, 0.0), (0, 0.0)], dtype=[('col1', '>i4'), ('col2', '>f4')]) The other dictionary form permitted is a dictionary of name keys with tuple values specifying type, offset, and an optional title. :: >>> x = np.zeros(3, dtype={'col1':('i1',0,'title 1'), 'col2':('f4',1,'title 2')}) >>> x array([(0, 0.0), (0, 0.0), (0, 0.0)], dtype=[(('title 1', 'col1'), '|i1'), (('title 2', 'col2'), '>f4')]) Accessing and modifying field names =================================== The field names are an attribute of the dtype object defining the structure. For the last example: :: >>> x.dtype.names ('col1', 'col2') >>> x.dtype.names = ('x', 'y') >>> x array([(0, 0.0), (0, 0.0), (0, 0.0)], dtype=[(('title 1', 'x'), '|i1'), (('title 2', 'y'), '>f4')]) >>> x.dtype.names = ('x', 'y', 'z') # wrong number of names <type 'exceptions.ValueError'>: must replace all names at once with a sequence of length 2 Accessing field titles ==================================== The field titles provide a standard place to put associated info for fields. They do not have to be strings. :: >>> x.dtype.fields['x'][2] 'title 1' Accessing multiple fields at once ==================================== You can access multiple fields at once using a list of field names: :: >>> x = np.array([(1.5,2.5,(1.0,2.0)),(3.,4.,(4.,5.)),(1.,3.,(2.,6.))], dtype=[('x','f4'),('y',np.float32),('value','f4',(2,2))]) Notice that `x` is created with a list of tuples. :: >>> x[['x','y']] array([(1.5, 2.5), (3.0, 4.0), (1.0, 3.0)], dtype=[('x', '<f4'), ('y', '<f4')]) >>> x[['x','value']] array([(1.5, [[1.0, 2.0], [1.0, 2.0]]), (3.0, [[4.0, 5.0], [4.0, 5.0]]), (1.0, [[2.0, 6.0], [2.0, 6.0]])], dtype=[('x', '<f4'), ('value', '<f4', (2, 2))]) The fields are returned in the order they are asked for.:: >>> x[['y','x']] array([(2.5, 1.5), (4.0, 3.0), (3.0, 1.0)], dtype=[('y', '<f4'), ('x', '<f4')]) Filling structured arrays ========================= Structured arrays can be filled by field or row by row. :: >>> arr = np.zeros((5,), dtype=[('var1','f8'),('var2','f8')]) >>> arr['var1'] = np.arange(5) If you fill it in row by row, it takes a take a tuple (but not a list or array!):: >>> arr[0] = (10,20) >>> arr array([(10.0, 20.0), (1.0, 0.0), (2.0, 0.0), (3.0, 0.0), (4.0, 0.0)], dtype=[('var1', '<f8'), ('var2', '<f8')]) Record Arrays ============= For convenience, numpy provides "record arrays" which allow one to access fields of structured arrays by attribute rather than by index. Record arrays are structured arrays wrapped using a subclass of ndarray, :class:`numpy.recarray`, which allows field access by attribute on the array object, and record arrays also use a special datatype, :class:`numpy.record`, which allows field access by attribute on the individual elements of the array. The simplest way to create a record array is with :func:`numpy.rec.array`: :: >>> recordarr = np.rec.array([(1,2.,'Hello'),(2,3.,"World")], ... dtype=[('foo', 'i4'),('bar', 'f4'), ('baz', 'S10')]) >>> recordarr.bar array([ 2., 3.], dtype=float32) >>> recordarr[1:2] rec.array([(2, 3.0, 'World')], dtype=[('foo', '<i4'), ('bar', '<f4'), ('baz', 'S10')]) >>> recordarr[1:2].foo array([2], dtype=int32) >>> recordarr.foo[1:2] array([2], dtype=int32) >>> recordarr[1].baz 'World' numpy.rec.array can convert a wide variety of arguments into record arrays, including normal structured arrays: :: >>> arr = array([(1,2.,'Hello'),(2,3.,"World")], ... dtype=[('foo', 'i4'), ('bar', 'f4'), ('baz', 'S10')]) >>> recordarr = np.rec.array(arr) The numpy.rec module provides a number of other convenience functions for creating record arrays, see :ref:`record array creation routines <routines.array-creation.rec>`. A record array representation of a structured array can be obtained using the appropriate :ref:`view`: :: >>> arr = np.array([(1,2.,'Hello'),(2,3.,"World")], ... dtype=[('foo', 'i4'),('bar', 'f4'), ('baz', 'a10')]) >>> recordarr = arr.view(dtype=dtype((np.record, arr.dtype)), ... type=np.recarray) For convenience, viewing an ndarray as type `np.recarray` will automatically convert to `np.record` datatype, so the dtype can be left out of the view: :: >>> recordarr = arr.view(np.recarray) >>> recordarr.dtype dtype((numpy.record, [('foo', '<i4'), ('bar', '<f4'), ('baz', 'S10')])) To get back to a plain ndarray both the dtype and type must be reset. The following view does so, taking into account the unusual case that the recordarr was not a structured type: :: >>> arr2 = recordarr.view(recordarr.dtype.fields or recordarr.dtype, np.ndarray) Record array fields accessed by index or by attribute are returned as a record array if the field has a structured type but as a plain ndarray otherwise. :: >>> recordarr = np.rec.array([('Hello', (1,2)),("World", (3,4))], ... dtype=[('foo', 'S6'),('bar', [('A', int), ('B', int)])]) >>> type(recordarr.foo) <type 'numpy.ndarray'> >>> type(recordarr.bar) <class 'numpy.core.records.recarray'> Note that if a field has the same name as an ndarray attribute, the ndarray attribute takes precedence. Such fields will be inaccessible by attribute but may still be accessed by index. """ from __future__ import division, absolute_import, print_function
bsd-3-clause
[ 624, 199, 1280, 29, 199, 27486, 1952, 4814, 199, 1280, 29, 199, 199, 3241, 293, 5199, 199, 5769, 199, 199, 5667, 2713, 6571, 7074, 1893, 14918, 370, 1218, 6572, 402, 21781, 16048, 14, 199, 20676, 6572, 11291, 1373, 370, 27232, 314, 666, 701, 4310, 1504, 14, 437, 3486, 221, 199, 2694, 911, 2498, 4052, 365, 18329, 16781, 3800, 421, 1306, 671, 275, 980, 14, 1144, 7694, 17, 12, 18, 2020, 7, 6257, 659, 334, 18, 12, 19, 2020, 2, 15943, 17857, 199, 2263, 4519, 2152, 11699, 1421, 297, 283, 73, 20, 8157, 1700, 297, 283, 70, 20, 659, 661, 6185, 297, 283, 51, 709, 2023, 199, 1306, 671, 199, 1625, 7694, 17, 12, 499, 14, 16, 12, 283, 6257, 659, 334, 18, 12, 650, 14, 16, 12, 283, 15943, 2665, 489, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 199, 21741, 781, 1172, 2737, 282, 1373, 13, 13014, 1625, 402, 2582, 499, 14, 7048, 1819, 402, 199, 3749, 1625, 365, 282, 5523, 626, 3509, 7795, 2974, 12, 282, 4337, 13, 2075, 3000, 12, 282, 4337, 13, 2075, 199, 1609, 12, 436, 282, 1059, 402, 2582, 1616, 503, 6656, 14, 982, 781, 1478, 642, 1625, 737, 314, 3499, 199, 3124, 781, 664, 314, 3499, 5523, 26, 3800, 421, 1306, 671, 59, 17, 61, 199, 334, 18, 12, 19, 2020, 2, 15943, 531, 199, 199, 714, 1856, 6792, 590, 12, 1373, 883, 2879, 1263, 901, 402, 314, 1625, 701, 16356, 1808, 314, 199, 875, 626, 1561, 626, 901, 14, 3800, 421, 1306, 612, 275, 671, 459, 1700, 418, 199, 1306, 612, 199, 1625, 779, 499, 2020, 221, 650, 8333, 2152, 29, 1609, 708, 9, 199, 1306, 612, 5873, 275, 499, 10, 89, 199, 1306, 612, 199, 1625, 779, 841, 2020, 221, 1227, 8333, 2152, 29, 1609, 708, 9, 199, 1306, 671, 199, 1625, 7694, 17, 12, 841, 14, 16, 12, 283, 6257, 659, 334, 18, 12, 1227, 14, 16, 12, 283, 15943, 2665, 2126, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 199, 607, 3520, 7251, 12, 612, 365, 282, 3486, 2069, 1625, 22581, 402, 314, 499, 977, 901, 199, 262, 314, 21781, 730, 14, 11017, 12, 7830, 2419, 3769, 282, 1331, 402, 314, 666, 315, 314, 21781, 199, 1144, 12, 652, 365, 282, 2455, 12, 284, 14, 69, 2020, 652, 25616, 8840, 314, 2011, 4402, 9918, 14, 199, 2719, 527, 12, 1380, 781, 4588, 642, 1625, 701, 28584, 2983, 2399, 1338, 12, 314, 21781, 199, 1144, 13703, 314, 5226, 1338, 465, 28584, 1146, 465, 5521, 14, 16485, 2605, 12, 340, 1373, 199, 6627, 314, 21781, 1625, 12, 314, 901, 2455, 2597, 4493, 26, 3800, 421, 1306, 671, 59, 17, 61, 275, 5868, 17, 3057, 17, 2020, 2, 12288, 531, 199, 1306, 671, 199, 1625, 7694, 17, 12, 841, 14, 16, 12, 283, 6257, 659, 5868, 17, 12, 446, 17, 14, 16, 12, 283, 12288, 2665, 2126, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 1306, 612, 199, 1625, 779, 841, 2020, 446, 17, 8333, 2152, 29, 1609, 708, 9, 199, 199, 872, 2408, 316, 13039, 3297, 1952, 4814, 199, 1280, 17575, 199, 199, 4395, 7890, 282, 21781, 1625, 4012, 314, 2152, 909, 14, 221, 6006, 787, 199, 538, 261, 422, 279, 538, 13943, 15217, 370, 5627, 314, 1504, 402, 282, 2777, 14, 221, 6601, 402, 199, 29032, 21169, 5647, 13388, 7163, 543, 19378, 12, 1967, 1144, 12, 503, 199, 13565, 859, 12, 436, 1077, 440, 506, 1202, 871, 367, 4066, 12901, 14, 5723, 199, 14117, 506, 880, 949, 471, 14, 7309, 9314, 2777, 5523, 315, 199, 368, 402, 11648, 13943, 15217, 12, 1808, 376, 1423, 334, 305, 6841, 370, 282, 2152, 199, 1593, 4252, 503, 282, 2152, 909, 3787, 6337, 680, 221, 961, 199, 2094, 1471, 506, 1373, 402, 314, 2569, 26, 413, 9, 1059, 12, 499, 9, 2008, 12, 650, 9, 769, 12, 503, 199, 20, 9, 2600, 14, 221, 7048, 402, 3520, 365, 29226, 590, 11736, 5084, 14, 199, 199, 17, 9, 2624, 1423, 14, 199, 607, 642, 1930, 12, 314, 3787, 14292, 282, 10029, 13, 12794, 769, 402, 730, 199, 31659, 12, 14190, 543, 2402, 2215, 2556, 14, 710, 1504, 787, 221, 199, 11809, 314, 849, 1561, 283, 70, 16, 297, 283, 70, 17, 297, 283, 70, 18, 7, 436, 880, 641, 14, 199, 1918, 730, 29558, 883, 5452, 841, 3365, 4513, 26, 3800, 819, 282, 9, 330, 17, 12, 284, 17, 12, 284, 18, 12, 284, 20, 12, 284, 24, 12, 399, 17, 12, 399, 18, 12, 399, 20, 12, 399, 24, 12, 289, 18, 12, 289, 20, 12, 289, 24, 12, 286, 24, 12, 286, 975, 12, 282, 28, 78, 30, 1362, 334, 13063, 316, 2783, 12, 14526, 12, 7381, 14526, 12, 15657, 12, 6114, 436, 489, 6317, 2582, 3326, 402, 2013, 3696, 17464, 9, 523, 330, 9, 1109, 24, 32699, 1635, 24, 32699, 1609, 975, 12, 2069, 708, 12, 2069, 772, 12, 6114, 772, 12, 6114, 3933, 1362, 334, 3749, 900, 543, 4546, 10627, 9, 523, 286, 9, 12731, 19378, 15, 1507, 1144, 730, 28754, 334, 69, 14, 71, 14, 11140, 708, 680, 1362, 7529, 1133, 675, 3520, 315, 892, 1233, 1, 523, 366, 9, 13050, 4528, 730, 29558, 334, 69, 14, 71, 869, 367, 7381, 3974, 14526, 680, 1362, 19503, 1808, 3520, 7444, 1265, 1471, 14, 15621, 883, 506, 1911, 315, 314, 1362, 20602, 6719, 199, 199, 20676, 3365, 15725, 883, 506, 13492, 4453, 314, 2011, 1059, 334, 7911, 10842, 3955, 1265, 199, 7051, 370, 886, 626, 31, 680, 28876, 6878, 12, 1924, 730, 16628, 883, 506, 18239, 199, 1045, 282, 6375, 3348, 1329, 12, 503, 282, 2215, 14, 1010, 3520, 5560, 376, 1625, 199, 2108, 365, 2737, 12, 284, 14, 69, 2020, 376, 1625, 4453, 282, 2777, 14, 10314, 1625, 199, 374, 5139, 25713, 370, 465, 282, 2849, 901, 14, 1626, 2893, 26, 3800, 421, 1306, 671, 275, 980, 14, 4250, 8, 19, 12, 2152, 534, 19, 442, 24, 12, 2069, 708 ]
[ 199, 1280, 29, 199, 27486, 1952, 4814, 199, 1280, 29, 199, 199, 3241, 293, 5199, 199, 5769, 199, 199, 5667, 2713, 6571, 7074, 1893, 14918, 370, 1218, 6572, 402, 21781, 16048, 14, 199, 20676, 6572, 11291, 1373, 370, 27232, 314, 666, 701, 4310, 1504, 14, 437, 3486, 221, 199, 2694, 911, 2498, 4052, 365, 18329, 16781, 3800, 421, 1306, 671, 275, 980, 14, 1144, 7694, 17, 12, 18, 2020, 7, 6257, 659, 334, 18, 12, 19, 2020, 2, 15943, 17857, 199, 2263, 4519, 2152, 11699, 1421, 297, 283, 73, 20, 8157, 1700, 297, 283, 70, 20, 659, 661, 6185, 297, 283, 51, 709, 2023, 199, 1306, 671, 199, 1625, 7694, 17, 12, 499, 14, 16, 12, 283, 6257, 659, 334, 18, 12, 650, 14, 16, 12, 283, 15943, 2665, 489, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 199, 21741, 781, 1172, 2737, 282, 1373, 13, 13014, 1625, 402, 2582, 499, 14, 7048, 1819, 402, 199, 3749, 1625, 365, 282, 5523, 626, 3509, 7795, 2974, 12, 282, 4337, 13, 2075, 3000, 12, 282, 4337, 13, 2075, 199, 1609, 12, 436, 282, 1059, 402, 2582, 1616, 503, 6656, 14, 982, 781, 1478, 642, 1625, 737, 314, 3499, 199, 3124, 781, 664, 314, 3499, 5523, 26, 3800, 421, 1306, 671, 59, 17, 61, 199, 334, 18, 12, 19, 2020, 2, 15943, 531, 199, 199, 714, 1856, 6792, 590, 12, 1373, 883, 2879, 1263, 901, 402, 314, 1625, 701, 16356, 1808, 314, 199, 875, 626, 1561, 626, 901, 14, 3800, 421, 1306, 612, 275, 671, 459, 1700, 418, 199, 1306, 612, 199, 1625, 779, 499, 2020, 221, 650, 8333, 2152, 29, 1609, 708, 9, 199, 1306, 612, 5873, 275, 499, 10, 89, 199, 1306, 612, 199, 1625, 779, 841, 2020, 221, 1227, 8333, 2152, 29, 1609, 708, 9, 199, 1306, 671, 199, 1625, 7694, 17, 12, 841, 14, 16, 12, 283, 6257, 659, 334, 18, 12, 1227, 14, 16, 12, 283, 15943, 2665, 2126, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 199, 607, 3520, 7251, 12, 612, 365, 282, 3486, 2069, 1625, 22581, 402, 314, 499, 977, 901, 199, 262, 314, 21781, 730, 14, 11017, 12, 7830, 2419, 3769, 282, 1331, 402, 314, 666, 315, 314, 21781, 199, 1144, 12, 652, 365, 282, 2455, 12, 284, 14, 69, 2020, 652, 25616, 8840, 314, 2011, 4402, 9918, 14, 199, 2719, 527, 12, 1380, 781, 4588, 642, 1625, 701, 28584, 2983, 2399, 1338, 12, 314, 21781, 199, 1144, 13703, 314, 5226, 1338, 465, 28584, 1146, 465, 5521, 14, 16485, 2605, 12, 340, 1373, 199, 6627, 314, 21781, 1625, 12, 314, 901, 2455, 2597, 4493, 26, 3800, 421, 1306, 671, 59, 17, 61, 275, 5868, 17, 3057, 17, 2020, 2, 12288, 531, 199, 1306, 671, 199, 1625, 7694, 17, 12, 841, 14, 16, 12, 283, 6257, 659, 5868, 17, 12, 446, 17, 14, 16, 12, 283, 12288, 2665, 2126, 2152, 11699, 1421, 297, 12696, 73, 20, 659, 661, 1700, 297, 12696, 70, 20, 659, 661, 6185, 297, 11280, 51, 709, 2023, 199, 1306, 612, 199, 1625, 779, 841, 2020, 446, 17, 8333, 2152, 29, 1609, 708, 9, 199, 199, 872, 2408, 316, 13039, 3297, 1952, 4814, 199, 1280, 17575, 199, 199, 4395, 7890, 282, 21781, 1625, 4012, 314, 2152, 909, 14, 221, 6006, 787, 199, 538, 261, 422, 279, 538, 13943, 15217, 370, 5627, 314, 1504, 402, 282, 2777, 14, 221, 6601, 402, 199, 29032, 21169, 5647, 13388, 7163, 543, 19378, 12, 1967, 1144, 12, 503, 199, 13565, 859, 12, 436, 1077, 440, 506, 1202, 871, 367, 4066, 12901, 14, 5723, 199, 14117, 506, 880, 949, 471, 14, 7309, 9314, 2777, 5523, 315, 199, 368, 402, 11648, 13943, 15217, 12, 1808, 376, 1423, 334, 305, 6841, 370, 282, 2152, 199, 1593, 4252, 503, 282, 2152, 909, 3787, 6337, 680, 221, 961, 199, 2094, 1471, 506, 1373, 402, 314, 2569, 26, 413, 9, 1059, 12, 499, 9, 2008, 12, 650, 9, 769, 12, 503, 199, 20, 9, 2600, 14, 221, 7048, 402, 3520, 365, 29226, 590, 11736, 5084, 14, 199, 199, 17, 9, 2624, 1423, 14, 199, 607, 642, 1930, 12, 314, 3787, 14292, 282, 10029, 13, 12794, 769, 402, 730, 199, 31659, 12, 14190, 543, 2402, 2215, 2556, 14, 710, 1504, 787, 221, 199, 11809, 314, 849, 1561, 283, 70, 16, 297, 283, 70, 17, 297, 283, 70, 18, 7, 436, 880, 641, 14, 199, 1918, 730, 29558, 883, 5452, 841, 3365, 4513, 26, 3800, 819, 282, 9, 330, 17, 12, 284, 17, 12, 284, 18, 12, 284, 20, 12, 284, 24, 12, 399, 17, 12, 399, 18, 12, 399, 20, 12, 399, 24, 12, 289, 18, 12, 289, 20, 12, 289, 24, 12, 286, 24, 12, 286, 975, 12, 282, 28, 78, 30, 1362, 334, 13063, 316, 2783, 12, 14526, 12, 7381, 14526, 12, 15657, 12, 6114, 436, 489, 6317, 2582, 3326, 402, 2013, 3696, 17464, 9, 523, 330, 9, 1109, 24, 32699, 1635, 24, 32699, 1609, 975, 12, 2069, 708, 12, 2069, 772, 12, 6114, 772, 12, 6114, 3933, 1362, 334, 3749, 900, 543, 4546, 10627, 9, 523, 286, 9, 12731, 19378, 15, 1507, 1144, 730, 28754, 334, 69, 14, 71, 14, 11140, 708, 680, 1362, 7529, 1133, 675, 3520, 315, 892, 1233, 1, 523, 366, 9, 13050, 4528, 730, 29558, 334, 69, 14, 71, 869, 367, 7381, 3974, 14526, 680, 1362, 19503, 1808, 3520, 7444, 1265, 1471, 14, 15621, 883, 506, 1911, 315, 314, 1362, 20602, 6719, 199, 199, 20676, 3365, 15725, 883, 506, 13492, 4453, 314, 2011, 1059, 334, 7911, 10842, 3955, 1265, 199, 7051, 370, 886, 626, 31, 680, 28876, 6878, 12, 1924, 730, 16628, 883, 506, 18239, 199, 1045, 282, 6375, 3348, 1329, 12, 503, 282, 2215, 14, 1010, 3520, 5560, 376, 1625, 199, 2108, 365,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
westinedu/newertrends
django/core/cache/backends/base.py
232
7960
"Base Cache class." import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning from django.utils.encoding import smart_str from django.utils.importlib import import_module class InvalidCacheBackendError(ImproperlyConfigured): pass class CacheKeyWarning(DjangoRuntimeWarning): pass # Memcached does not accept keys longer than this. MEMCACHE_MAX_KEY_LENGTH = 250 def default_key_func(key, key_prefix, version): """ Default function to generate keys. Constructs the key used by all other methods. By default it prepends the `key_prefix'. KEY_FUNCTION can be used to specify an alternate function with custom key making behavior. """ return ':'.join([key_prefix, str(version), smart_str(key)]) def get_key_func(key_func): """ Function to decide which key function to use. Defaults to ``default_key_func``. """ if key_func is not None: if callable(key_func): return key_func else: key_func_module_path, key_func_name = key_func.rsplit('.', 1) key_func_module = import_module(key_func_module_path) return getattr(key_func_module, key_func_name) return default_key_func class BaseCache(object): def __init__(self, params): timeout = params.get('timeout', params.get('TIMEOUT', 300)) try: timeout = int(timeout) except (ValueError, TypeError): timeout = 300 self.default_timeout = timeout options = params.get('OPTIONS', {}) max_entries = params.get('max_entries', options.get('MAX_ENTRIES', 300)) try: self._max_entries = int(max_entries) except (ValueError, TypeError): self._max_entries = 300 cull_frequency = params.get('cull_frequency', options.get('CULL_FREQUENCY', 3)) try: self._cull_frequency = int(cull_frequency) except (ValueError, TypeError): self._cull_frequency = 3 self.key_prefix = smart_str(params.get('KEY_PREFIX', '')) self.version = params.get('VERSION', 1) self.key_func = get_key_func(params.get('KEY_FUNCTION', None)) def make_key(self, key, version=None): """Constructs the key used by all other methods. By default it uses the key_func to generate a key (which, by default, prepends the `key_prefix' and 'version'). An different key function can be provided at the time of cache construction; alternatively, you can subclass the cache backend to provide custom key making behavior. """ if version is None: version = self.version new_key = self.key_func(key, self.key_prefix, version) return new_key def add(self, key, value, timeout=None, version=None): """ Set a value in the cache if the key does not already exist. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. Returns True if the value was stored, False otherwise. """ raise NotImplementedError def get(self, key, default=None, version=None): """ Fetch a given key from the cache. If the key does not exist, return default, which itself defaults to None. """ raise NotImplementedError def set(self, key, value, timeout=None, version=None): """ Set a value in the cache. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ raise NotImplementedError def delete(self, key, version=None): """ Delete a key from the cache, failing silently. """ raise NotImplementedError def get_many(self, keys, version=None): """ Fetch a bunch of keys from the cache. For certain backends (memcached, pgsql) this can be *much* faster when fetching multiple values. Returns a dict mapping each key in keys to its value. If the given key is missing, it will be missing from the response dict. """ d = {} for k in keys: val = self.get(k, version=version) if val is not None: d[k] = val return d def has_key(self, key, version=None): """ Returns True if the key is in the cache and has not expired. """ return self.get(key, version=version) is not None def incr(self, key, delta=1, version=None): """ Add delta to value in the cache. If the key does not exist, raise a ValueError exception. """ value = self.get(key, version=version) if value is None: raise ValueError("Key '%s' not found" % key) new_value = value + delta self.set(key, new_value, version=version) return new_value def decr(self, key, delta=1, version=None): """ Subtract delta from value in the cache. If the key does not exist, raise a ValueError exception. """ return self.incr(key, -delta, version=version) def __contains__(self, key): """ Returns True if the key is in the cache and has not expired. """ # This is a separate method, rather than just a copy of has_key(), # so that it always has the same functionality as has_key(), even # if a subclass overrides it. return self.has_key(key) def set_many(self, data, timeout=None, version=None): """ Set a bunch of values in the cache at once from a dict of key/value pairs. For certain backends (memcached), this is much more efficient than calling set() multiple times. If timeout is given, that timeout will be used for the key; otherwise the default cache timeout will be used. """ for key, value in data.items(): self.set(key, value, timeout=timeout, version=version) def delete_many(self, keys, version=None): """ Set a bunch of values in the cache at once. For certain backends (memcached), this is much more efficient than calling delete() multiple times. """ for key in keys: self.delete(key, version=version) def clear(self): """Remove *all* values from the cache at once.""" raise NotImplementedError def validate_key(self, key): """ Warn about keys that would not be portable to the memcached backend. This encourages (but does not force) writing backend-portable cache code. """ if len(key) > MEMCACHE_MAX_KEY_LENGTH: warnings.warn('Cache key will cause errors if used with memcached: ' '%s (longer than %s)' % (key, MEMCACHE_MAX_KEY_LENGTH), CacheKeyWarning) for char in key: if ord(char) < 33 or ord(char) == 127: warnings.warn('Cache key contains characters that will cause ' 'errors if used with memcached: %r' % key, CacheKeyWarning) def incr_version(self, key, delta=1, version=None): """Adds delta to the cache version for the supplied key. Returns the new version. """ if version is None: version = self.version value = self.get(key, version=version) if value is None: raise ValueError("Key '%s' not found" % key) self.set(key, value, version=version+delta) self.delete(key, version=version) return version+delta def decr_version(self, key, delta=1, version=None): """Substracts delta from the cache version for the supplied key. Returns the new version. """ return self.incr_version(key, -delta, version)
bsd-3-clause
[ 2, 1563, 11977, 1021, 2122, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 5634, 14357, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 199, 199, 533, 11977, 1197, 3849, 8, 9323, 14357, 3849, 304, 272, 986, 199, 199, 3, 30465, 5245, 1630, 440, 4729, 2883, 8088, 2419, 642, 14, 199, 10293, 8677, 63, 4283, 63, 3078, 63, 9127, 275, 16074, 199, 199, 318, 849, 63, 498, 63, 1532, 8, 498, 12, 790, 63, 1861, 12, 1015, 304, 272, 408, 272, 3758, 805, 370, 3550, 2883, 14, 339, 9215, 83, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 19986, 3198, 272, 314, 658, 498, 63, 1861, 1370, 9301, 63, 15476, 883, 506, 1202, 370, 4165, 376, 18034, 272, 805, 543, 3537, 790, 10663, 5953, 14, 272, 408, 272, 372, 29010, 904, 779, 498, 63, 1861, 12, 620, 8, 1023, 395, 11179, 63, 495, 8, 498, 3948, 199, 199, 318, 664, 63, 498, 63, 1532, 8, 498, 63, 1532, 304, 272, 408, 272, 6801, 370, 19822, 1314, 790, 805, 370, 675, 14, 339, 7827, 370, 1124, 885, 63, 498, 63, 1532, 4345, 272, 408, 272, 340, 790, 63, 1532, 365, 440, 488, 26, 267, 340, 4550, 8, 498, 63, 1532, 304, 288, 372, 790, 63, 1532, 267, 587, 26, 288, 790, 63, 1532, 63, 578, 63, 515, 12, 790, 63, 1532, 63, 354, 275, 790, 63, 1532, 14, 13490, 14078, 413, 9, 288, 790, 63, 1532, 63, 578, 275, 492, 63, 578, 8, 498, 63, 1532, 63, 578, 63, 515, 9, 288, 372, 2519, 8, 498, 63, 1532, 63, 578, 12, 790, 63, 1532, 63, 354, 9, 272, 372, 849, 63, 498, 63, 1532, 199, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 1862, 14, 362, 360, 8899, 297, 9601, 430, 267, 862, 26, 288, 2653, 275, 1109, 8, 2593, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 398, 1511, 275, 1862, 14, 362, 360, 8808, 297, 5009, 267, 1390, 63, 3189, 275, 1862, 14, 362, 360, 988, 63, 3189, 297, 1511, 14, 362, 360, 4283, 63, 1309, 23359, 297, 9601, 430, 267, 862, 26, 288, 291, 423, 988, 63, 3189, 275, 1109, 8, 988, 63, 3189, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 988, 63, 3189, 275, 9601, 398, 286, 979, 63, 11132, 275, 1862, 14, 362, 360, 67, 979, 63, 11132, 297, 1511, 14, 362, 360, 35, 3785, 63, 38, 5255, 17059, 297, 650, 430, 267, 862, 26, 288, 291, 423, 67, 979, 63, 11132, 275, 1109, 8, 67, 979, 63, 11132, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 67, 979, 63, 11132, 275, 650, 398, 291, 14, 498, 63, 1861, 275, 11179, 63, 495, 8, 1162, 14, 362, 360, 3078, 63, 6351, 297, 12381, 267, 291, 14, 1023, 275, 1862, 14, 362, 360, 4612, 297, 413, 9, 267, 291, 14, 498, 63, 1532, 275, 664, 63, 498, 63, 1532, 8, 1162, 14, 362, 360, 3078, 63, 15476, 297, 488, 430, 339, 347, 1852, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 27943, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 267, 4440, 314, 790, 63, 1532, 370, 3550, 282, 790, 334, 6777, 12, 701, 849, 12, 267, 19986, 3198, 314, 658, 498, 63, 1861, 7, 436, 283, 1023, 1959, 1626, 3365, 790, 267, 805, 883, 506, 2741, 737, 314, 900, 402, 2581, 14538, 27, 267, 8679, 17330, 12, 1265, 883, 5516, 314, 2581, 4865, 370, 5647, 267, 3537, 790, 10663, 5953, 14, 267, 408, 267, 340, 1015, 365, 488, 26, 288, 1015, 275, 291, 14, 1023, 398, 892, 63, 498, 275, 291, 14, 498, 63, 1532, 8, 498, 12, 291, 14, 498, 63, 1861, 12, 1015, 9, 267, 372, 892, 63, 498, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 63, 3479, 8, 277, 12, 2883, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 22219, 402, 2883, 687, 314, 2581, 14, 2104, 9842, 14745, 334, 32567, 12, 267, 299, 458, 1710, 9, 642, 883, 506, 627, 77, 2133, 10, 12930, 1380, 21239, 3663, 1338, 14, 398, 1803, 282, 1211, 4412, 1924, 790, 315, 2883, 370, 2399, 574, 14, 982, 314, 1627, 267, 790, 365, 4124, 12, 652, 911, 506, 4124, 687, 314, 1177, 1211, 14, 267, 408, 267, 366, 275, 1052, 267, 367, 1022, 315, 2883, 26, 288, 1139, 275, 291, 14, 362, 8, 75, 12, 1015, 29, 1023, 9, 288, 340, 1139, 365, 440, 488, 26, 355, 366, 59, 75, 61, 275 ]
[ 1563, 11977, 1021, 2122, 199, 199, 646, 3598, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 12, 5634, 14357, 3849, 199, 504, 1639, 14, 1208, 14, 2991, 492, 11179, 63, 495, 199, 504, 1639, 14, 1208, 14, 25893, 492, 492, 63, 578, 199, 199, 533, 6378, 4437, 8447, 547, 8, 8499, 10951, 304, 272, 986, 199, 199, 533, 11977, 1197, 3849, 8, 9323, 14357, 3849, 304, 272, 986, 199, 199, 3, 30465, 5245, 1630, 440, 4729, 2883, 8088, 2419, 642, 14, 199, 10293, 8677, 63, 4283, 63, 3078, 63, 9127, 275, 16074, 199, 199, 318, 849, 63, 498, 63, 1532, 8, 498, 12, 790, 63, 1861, 12, 1015, 304, 272, 408, 272, 3758, 805, 370, 3550, 2883, 14, 339, 9215, 83, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 19986, 3198, 272, 314, 658, 498, 63, 1861, 1370, 9301, 63, 15476, 883, 506, 1202, 370, 4165, 376, 18034, 272, 805, 543, 3537, 790, 10663, 5953, 14, 272, 408, 272, 372, 29010, 904, 779, 498, 63, 1861, 12, 620, 8, 1023, 395, 11179, 63, 495, 8, 498, 3948, 199, 199, 318, 664, 63, 498, 63, 1532, 8, 498, 63, 1532, 304, 272, 408, 272, 6801, 370, 19822, 1314, 790, 805, 370, 675, 14, 339, 7827, 370, 1124, 885, 63, 498, 63, 1532, 4345, 272, 408, 272, 340, 790, 63, 1532, 365, 440, 488, 26, 267, 340, 4550, 8, 498, 63, 1532, 304, 288, 372, 790, 63, 1532, 267, 587, 26, 288, 790, 63, 1532, 63, 578, 63, 515, 12, 790, 63, 1532, 63, 354, 275, 790, 63, 1532, 14, 13490, 14078, 413, 9, 288, 790, 63, 1532, 63, 578, 275, 492, 63, 578, 8, 498, 63, 1532, 63, 578, 63, 515, 9, 288, 372, 2519, 8, 498, 63, 1532, 63, 578, 12, 790, 63, 1532, 63, 354, 9, 272, 372, 849, 63, 498, 63, 1532, 199, 199, 533, 3523, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 1862, 304, 267, 2653, 275, 1862, 14, 362, 360, 2593, 297, 1862, 14, 362, 360, 8899, 297, 9601, 430, 267, 862, 26, 288, 2653, 275, 1109, 8, 2593, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 2653, 275, 9601, 267, 291, 14, 885, 63, 2593, 275, 2653, 398, 1511, 275, 1862, 14, 362, 360, 8808, 297, 5009, 267, 1390, 63, 3189, 275, 1862, 14, 362, 360, 988, 63, 3189, 297, 1511, 14, 362, 360, 4283, 63, 1309, 23359, 297, 9601, 430, 267, 862, 26, 288, 291, 423, 988, 63, 3189, 275, 1109, 8, 988, 63, 3189, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 988, 63, 3189, 275, 9601, 398, 286, 979, 63, 11132, 275, 1862, 14, 362, 360, 67, 979, 63, 11132, 297, 1511, 14, 362, 360, 35, 3785, 63, 38, 5255, 17059, 297, 650, 430, 267, 862, 26, 288, 291, 423, 67, 979, 63, 11132, 275, 1109, 8, 67, 979, 63, 11132, 9, 267, 871, 334, 3393, 12, 3146, 304, 288, 291, 423, 67, 979, 63, 11132, 275, 650, 398, 291, 14, 498, 63, 1861, 275, 11179, 63, 495, 8, 1162, 14, 362, 360, 3078, 63, 6351, 297, 12381, 267, 291, 14, 1023, 275, 1862, 14, 362, 360, 4612, 297, 413, 9, 267, 291, 14, 498, 63, 1532, 275, 664, 63, 498, 63, 1532, 8, 1162, 14, 362, 360, 3078, 63, 15476, 297, 488, 430, 339, 347, 1852, 63, 498, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 27943, 314, 790, 1202, 701, 1006, 1163, 3102, 14, 4885, 849, 652, 267, 4440, 314, 790, 63, 1532, 370, 3550, 282, 790, 334, 6777, 12, 701, 849, 12, 267, 19986, 3198, 314, 658, 498, 63, 1861, 7, 436, 283, 1023, 1959, 1626, 3365, 790, 267, 805, 883, 506, 2741, 737, 314, 900, 402, 2581, 14538, 27, 267, 8679, 17330, 12, 1265, 883, 5516, 314, 2581, 4865, 370, 5647, 267, 3537, 790, 10663, 5953, 14, 267, 408, 267, 340, 1015, 365, 488, 26, 288, 1015, 275, 291, 14, 1023, 398, 892, 63, 498, 275, 291, 14, 498, 63, 1532, 8, 498, 12, 291, 14, 498, 63, 1861, 12, 1015, 9, 267, 372, 892, 63, 498, 339, 347, 1050, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 340, 314, 790, 1630, 440, 2575, 2187, 14, 982, 267, 2653, 365, 1627, 12, 626, 2653, 911, 506, 1202, 367, 314, 790, 27, 4257, 267, 314, 849, 2581, 2653, 911, 506, 1202, 14, 398, 1803, 715, 340, 314, 574, 1990, 5489, 12, 756, 4257, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 8, 277, 12, 790, 12, 849, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 1627, 790, 687, 314, 2581, 14, 982, 314, 790, 1630, 440, 2187, 12, 372, 267, 849, 12, 1314, 6337, 4243, 370, 488, 14, 267, 408, 267, 746, 4279, 339, 347, 663, 8, 277, 12, 790, 12, 574, 12, 2653, 29, 403, 12, 1015, 29, 403, 304, 267, 408, 267, 2494, 282, 574, 315, 314, 2581, 14, 982, 2653, 365, 1627, 12, 626, 2653, 911, 506, 267, 1202, 367, 314, 790, 27, 4257, 314, 849, 2581, 2653, 911, 506, 1202, 14, 267, 408, 267, 746, 4279, 339, 347, 3145, 8, 277, 12, 790, 12, 1015, 29, 403, 304, 267, 408, 267, 8496, 282, 790, 687, 314, 2581, 12, 18648, 18030, 14, 267, 408, 267, 746, 4279, 339, 347, 664, 63, 3479, 8, 277, 12, 2883, 12, 1015, 29, 403, 304, 267, 408, 267, 16347, 282, 22219, 402, 2883, 687, 314, 2581, 14, 2104, 9842, 14745, 334, 32567, 12, 267, 299, 458, 1710, 9, 642, 883, 506, 627, 77, 2133, 10, 12930, 1380, 21239, 3663, 1338, 14, 398, 1803, 282, 1211, 4412, 1924, 790, 315, 2883, 370, 2399, 574, 14, 982, 314, 1627, 267, 790, 365, 4124, 12, 652, 911, 506, 4124, 687, 314, 1177, 1211, 14, 267, 408, 267, 366, 275, 1052, 267, 367, 1022, 315, 2883, 26, 288, 1139, 275, 291, 14, 362, 8, 75, 12, 1015, 29, 1023, 9, 288, 340, 1139, 365, 440, 488, 26, 355, 366, 59, 75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 1, 1, 1, 1, 1 ]
Feverup/ansible-modules-extras
monitoring/circonus_annotation.py
76
4976
#!/usr/bin/python # -*- coding: utf-8 -*- # # (c) 2014-2015, Epic Games, Inc. # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. import requests import time import json DOCUMENTATION = ''' --- module: circonus_annotation short_description: create an annotation in circonus description: - Create an annotation event with a given category, title and description. Optionally start, end or durations can be provided author: "Nick Harring (@NickatEpic)" version_added: 2.0 requirements: - urllib3 - requests - time options: api_key: description: - Circonus API key required: true category: description: - Annotation Category required: true description: description: - Description of annotation required: true title: description: - Title of annotation required: true start: description: - Unix timestamp of event start, defaults to now required: false stop: description: - Unix timestamp of event end, defaults to now + duration required: false duration: description: - Duration in seconds of annotation, defaults to 0 required: false ''' EXAMPLES = ''' # Create a simple annotation event with a source, defaults to start and end time of now - circonus_annotation: api_key: XXXXXXXXXXXXXXXXX title: 'App Config Change' description: 'This is a detailed description of the config change' category: 'This category groups like annotations' # Create an annotation with a duration of 5 minutes and a default start time of now - circonus_annotation: api_key: XXXXXXXXXXXXXXXXX title: 'App Config Change' description: 'This is a detailed description of the config change' category: 'This category groups like annotations' duration: 300 # Create an annotation with a start_time and end_time - circonus_annotation: api_key: XXXXXXXXXXXXXXXXX title: 'App Config Change' description: 'This is a detailed description of the config change' category: 'This category groups like annotations' start_time: 1395940006 end_time: 1395954407 ''' def post_annotation(annotation, api_key): ''' Takes annotation dict and api_key string''' base_url = 'https://api.circonus.com/v2' anootate_post_endpoint = '/annotation' resp = requests.post(base_url + anootate_post_endpoint, headers=build_headers(api_key), data=json.dumps(annotation)) resp.raise_for_status() return resp def create_annotation(module): ''' Takes ansible module object ''' annotation = {} if module.params['duration'] != None: duration = module.params['duration'] else: duration = 0 if module.params['start'] != None: start = module.params['start'] else: start = int(time.time()) if module.params['stop'] != None: stop = module.params['stop'] else: stop = int(time.time())+ duration annotation['start'] = int(start) annotation['stop'] = int(stop) annotation['category'] = module.params['category'] annotation['description'] = module.params['description'] annotation['title'] = module.params['title'] return annotation def build_headers(api_token): '''Takes api token, returns headers with it included.''' headers = {'X-Circonus-App-Name': 'ansible', 'Host': 'api.circonus.com', 'X-Circonus-Auth-Token': api_token, 'Accept': 'application/json'} return headers def main(): '''Main function, dispatches logic''' module = AnsibleModule( argument_spec=dict( start=dict(required=False, type='int'), stop=dict(required=False, type='int'), category=dict(required=True), title=dict(required=True), description=dict(required=True), duration=dict(required=False, type='int'), api_key=dict(required=True) ) ) annotation = create_annotation(module) try: resp = post_annotation(annotation, module.params['api_key']) except requests.exceptions.RequestException, err_str: module.fail_json(msg='Request Failed', reason=err_str) module.exit_json(changed=True, annotation=resp.json()) 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, 334, 67, 9, 6927, 13, 7806, 12, 662, 12475, 598, 14015, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 4145, 199, 646, 900, 199, 646, 2022, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 286, 723, 388, 527, 63, 9340, 199, 3612, 63, 1802, 26, 1218, 376, 11262, 315, 286, 723, 388, 527, 199, 1802, 26, 272, 446, 2790, 376, 11262, 1566, 543, 282, 1627, 4637, 12, 2538, 436, 1369, 14, 22383, 1343, 12, 1284, 503, 366, 6556, 883, 506, 2741, 199, 2502, 26, 298, 32172, 869, 5250, 316, 8593, 32172, 292, 37, 12475, 2924, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 7538, 26, 272, 446, 4011, 19, 272, 446, 4145, 272, 446, 900, 199, 1419, 26, 272, 2986, 63, 498, 26, 267, 1369, 26, 1779, 446, 445, 723, 388, 527, 3261, 790, 4960, 1415, 26, 2549, 272, 4637, 26, 267, 1369, 26, 1779, 446, 30793, 13573, 4960, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 11262, 267, 1415, 26, 2549, 272, 2538, 26, 267, 1369, 26, 288, 446, 16881, 402, 11262, 267, 1415, 26, 2549, 272, 1343, 26, 267, 1369, 26, 288, 446, 13074, 4913, 402, 1566, 1343, 12, 4243, 370, 3063, 267, 1415, 26, 3055, 272, 3631, 26, 267, 1369, 26, 288, 446, 13074, 4913, 402, 1566, 1284, 12, 4243, 370, 3063, 435, 7373, 267, 1415, 26, 3055, 272, 7373, 26, 267, 1369, 26, 288, 446, 31836, 315, 4696, 402, 11262, 12, 4243, 370, 378, 267, 1415, 26, 3055, 199, 2344, 199, 8918, 275, 1449, 199, 3, 2790, 282, 3486, 11262, 1566, 543, 282, 1350, 12, 4243, 370, 1343, 436, 1284, 900, 402, 3063, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 199, 3, 2790, 376, 11262, 543, 282, 7373, 402, 959, 9395, 436, 282, 849, 1343, 900, 402, 3063, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 272, 7373, 26, 9601, 199, 3, 2790, 376, 11262, 543, 282, 1343, 63, 521, 436, 1284, 63, 521, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 272, 1343, 63, 521, 26, 22317, 15667, 20965, 272, 1284, 63, 521, 26, 22317, 1427, 1477, 12641, 199, 2344, 199, 318, 2963, 63, 9340, 8, 9340, 12, 2986, 63, 498, 304, 272, 1449, 17415, 11262, 1211, 436, 2986, 63, 498, 1059, 2344, 272, 1300, 63, 633, 275, 283, 2859, 921, 1246, 14, 559, 82, 388, 527, 14, 957, 15, 86, 18, 7, 272, 376, 26974, 323, 63, 1932, 63, 6520, 275, 1994, 9340, 7, 272, 3085, 275, 4145, 14, 1932, 8, 1095, 63, 633, 435, 376, 26974, 323, 63, 1932, 63, 6520, 12, 288, 2323, 29, 1506, 63, 2139, 8, 1246, 63, 498, 395, 666, 29, 1001, 14, 4180, 8, 9340, 430, 272, 3085, 14, 3730, 63, 509, 63, 1205, 342, 272, 372, 3085, 199, 199, 318, 1218, 63, 9340, 8, 578, 304, 272, 1449, 17415, 3242, 859, 909, 1449, 272, 11262, 275, 1052, 272, 340, 859, 14, 1162, 459, 5553, 418, 1137, 488, 26, 267, 7373, 275, 859, 14, 1162, 459, 5553, 418, 272, 587, 26, 267, 7373, 275, 378, 272, 340, 859, 14, 1162, 459, 928, 418, 1137, 488, 26, 267, 1343, 275, 859, 14, 1162, 459, 928, 418, 272, 587, 26, 267, 1343, 275, 1109, 8, 521, 14, 521, 1012, 272, 340, 859, 14, 1162, 459, 2379, 418, 1137, 488, 26, 267, 3631, 275, 859, 14, 1162, 459, 2379, 418, 272, 587, 26, 267, 3631, 275, 1109, 8, 521, 14, 521, 1012, 11, 7373, 272, 11262, 459, 928, 418, 275, 1109, 8, 928, 9, 272, 11262, 459, 2379, 418, 275, 1109, 8, 2379, 9, 272, 11262, 459, 3710, 418, 275, 859, 14, 1162, 459, 3710, 418, 272, 11262, 459, 1802, 418, 275, 859, 14, 1162, 459, 1802, 418, 272, 11262, 459, 1213, 418, 275, 859, 14, 1162, 459, 1213, 418, 272, 372, 11262, 199, 318, 1900, 63, 2139, 8, 1246, 63, 1418, 304, 272, 1449, 32488, 2986, 1526, 12, 2529, 2323, 543, 652, 5120, 10595, 272, 2323, 275, 791, 56, 13, 35, 723, 388, 527, 13, 2640, 13, 985, 356, 283, 4853, 297, 267, 283, 4965, 356, 283, 1246, 14, 559, 82, 388, 527, 14, 957, 297, 283, 56, 13, 35, 723, 388, 527, 13, 2817, 13, 3264, 356, 2986, 63, 1418, 12, 267, 283, 8422, 356, 283, 3578, 15, 1001, 936, 272, 372, 2323, 199, 199, 318, 2446, 837, 272, 1449, 6756, 805, 12, 7634 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 334, 67, 9, 6927, 13, 7806, 12, 662, 12475, 598, 14015, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 646, 4145, 199, 646, 900, 199, 646, 2022, 199, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 286, 723, 388, 527, 63, 9340, 199, 3612, 63, 1802, 26, 1218, 376, 11262, 315, 286, 723, 388, 527, 199, 1802, 26, 272, 446, 2790, 376, 11262, 1566, 543, 282, 1627, 4637, 12, 2538, 436, 1369, 14, 22383, 1343, 12, 1284, 503, 366, 6556, 883, 506, 2741, 199, 2502, 26, 298, 32172, 869, 5250, 316, 8593, 32172, 292, 37, 12475, 2924, 199, 1023, 63, 3270, 26, 499, 14, 16, 199, 7538, 26, 272, 446, 4011, 19, 272, 446, 4145, 272, 446, 900, 199, 1419, 26, 272, 2986, 63, 498, 26, 267, 1369, 26, 1779, 446, 445, 723, 388, 527, 3261, 790, 4960, 1415, 26, 2549, 272, 4637, 26, 267, 1369, 26, 1779, 446, 30793, 13573, 4960, 1415, 26, 2549, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 402, 11262, 267, 1415, 26, 2549, 272, 2538, 26, 267, 1369, 26, 288, 446, 16881, 402, 11262, 267, 1415, 26, 2549, 272, 1343, 26, 267, 1369, 26, 288, 446, 13074, 4913, 402, 1566, 1343, 12, 4243, 370, 3063, 267, 1415, 26, 3055, 272, 3631, 26, 267, 1369, 26, 288, 446, 13074, 4913, 402, 1566, 1284, 12, 4243, 370, 3063, 435, 7373, 267, 1415, 26, 3055, 272, 7373, 26, 267, 1369, 26, 288, 446, 31836, 315, 4696, 402, 11262, 12, 4243, 370, 378, 267, 1415, 26, 3055, 199, 2344, 199, 8918, 275, 1449, 199, 3, 2790, 282, 3486, 11262, 1566, 543, 282, 1350, 12, 4243, 370, 1343, 436, 1284, 900, 402, 3063, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 199, 3, 2790, 376, 11262, 543, 282, 7373, 402, 959, 9395, 436, 282, 849, 1343, 900, 402, 3063, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 272, 7373, 26, 9601, 199, 3, 2790, 376, 11262, 543, 282, 1343, 63, 521, 436, 1284, 63, 521, 199, 13, 286, 723, 388, 527, 63, 9340, 26, 272, 2986, 63, 498, 26, 5787, 13312, 6873, 2483, 272, 2538, 26, 283, 2640, 4094, 7743, 7, 272, 1369, 26, 283, 2765, 365, 282, 16212, 1369, 402, 314, 1101, 1570, 7, 272, 4637, 26, 283, 2765, 4637, 4652, 2839, 15538, 7, 272, 1343, 63, 521, 26, 22317, 15667, 20965, 272, 1284, 63, 521, 26, 22317, 1427, 1477, 12641, 199, 2344, 199, 318, 2963, 63, 9340, 8, 9340, 12, 2986, 63, 498, 304, 272, 1449, 17415, 11262, 1211, 436, 2986, 63, 498, 1059, 2344, 272, 1300, 63, 633, 275, 283, 2859, 921, 1246, 14, 559, 82, 388, 527, 14, 957, 15, 86, 18, 7, 272, 376, 26974, 323, 63, 1932, 63, 6520, 275, 1994, 9340, 7, 272, 3085, 275, 4145, 14, 1932, 8, 1095, 63, 633, 435, 376, 26974, 323, 63, 1932, 63, 6520, 12, 288, 2323, 29, 1506, 63, 2139, 8, 1246, 63, 498, 395, 666, 29, 1001, 14, 4180, 8, 9340, 430, 272, 3085, 14, 3730, 63, 509, 63, 1205, 342, 272, 372, 3085, 199, 199, 318, 1218, 63, 9340, 8, 578, 304, 272, 1449, 17415, 3242, 859, 909, 1449, 272, 11262, 275, 1052, 272, 340, 859, 14, 1162, 459, 5553, 418, 1137, 488, 26, 267, 7373, 275, 859, 14, 1162, 459, 5553, 418, 272, 587, 26, 267, 7373, 275, 378, 272, 340, 859, 14, 1162, 459, 928, 418, 1137, 488, 26, 267, 1343, 275, 859, 14, 1162, 459, 928, 418, 272, 587, 26, 267, 1343, 275, 1109, 8, 521, 14, 521, 1012, 272, 340, 859, 14, 1162, 459, 2379, 418, 1137, 488, 26, 267, 3631, 275, 859, 14, 1162, 459, 2379, 418, 272, 587, 26, 267, 3631, 275, 1109, 8, 521, 14, 521, 1012, 11, 7373, 272, 11262, 459, 928, 418, 275, 1109, 8, 928, 9, 272, 11262, 459, 2379, 418, 275, 1109, 8, 2379, 9, 272, 11262, 459, 3710, 418, 275, 859, 14, 1162, 459, 3710, 418, 272, 11262, 459, 1802, 418, 275, 859, 14, 1162, 459, 1802, 418, 272, 11262, 459, 1213, 418, 275, 859, 14, 1162, 459, 1213, 418, 272, 372, 11262, 199, 318, 1900, 63, 2139, 8, 1246, 63, 1418, 304, 272, 1449, 32488, 2986, 1526, 12, 2529, 2323, 543, 652, 5120, 10595, 272, 2323, 275, 791, 56, 13, 35, 723, 388, 527, 13, 2640, 13, 985, 356, 283, 4853, 297, 267, 283, 4965, 356, 283, 1246, 14, 559, 82, 388, 527, 14, 957, 297, 283, 56, 13, 35, 723, 388, 527, 13, 2817, 13, 3264, 356, 2986, 63, 1418, 12, 267, 283, 8422, 356, 283, 3578, 15, 1001, 936, 272, 372, 2323, 199, 199, 318, 2446, 837, 272, 1449, 6756, 805, 12, 7634, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cg31/tensorflow
tensorflow/contrib/learn/python/learn/learn_runner.py
14
4997
# 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. # ============================================================================== """Runs an Experiment.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.contrib.learn.python.learn.experiment import Experiment from tensorflow.python.platform import tf_logging as logging def run(experiment_fn, output_dir, schedule=None): """Make and run an experiment. It creates an Experiment by calling `experiment_fn`. Then it calls the function named as `schedule` of the Experiment. If schedule is not provided, then the default schedule for the current task type is used. The defaults are as follows: * 'ps' maps to 'serve' * 'worker' maps to 'train' * 'master' maps to 'local_run' If the experiment's config does not include a task type, then an exception is raised. Example: ``` def _create_my_experiment(output_dir): return tf.contrib.learn.Experiment( estimator=my_estimator(model_dir=output_dir), train_input_fn=my_train_input, eval_input_fn=my_eval_input) learn_runner.run( experiment_fn=_create_my_experiment, output_dir="some/output/dir", schedule="train") ``` Args: experiment_fn: A function that creates an `Experiment`. It should accept an argument `output_dir` which should be used to create the `Estimator` (passed as `model_dir` to its constructor). It must return an `Experiment`. output_dir: Base output directory. schedule: The name of the method in the `Experiment` to run. Returns: The return value of function `schedule`. Raises: ValueError: If `output_dir` is empty, `schedule` is None but no task type is set in the built experiment's config, the task type has no default, or `schedule` doesn't reference a member of `Experiment`. TypeError: `schedule` references non-callable member. """ if not output_dir: raise ValueError('Must specify an output directory') if not callable(experiment_fn): raise TypeError('Experiment builder "%s" is not callable.' % experiment_fn) # Call the builder experiment = experiment_fn(output_dir=output_dir) if not isinstance(experiment, Experiment): raise TypeError('Experiment builder did not return an Experiment ' 'instance, got %s instead.' % type(experiment)) # Get the schedule config = experiment.estimator.config schedule = schedule or _get_default_schedule(config) # Execute the schedule if not hasattr(experiment, schedule): logging.error('Schedule references non-existent task %s', schedule) valid_tasks = [x for x in experiment.__dict__ if callable(getattr(experiment, x))] logging.error('Allowed values for this experiment are: %s', valid_tasks) raise ValueError('Schedule references non-existent task %s', schedule) task = getattr(experiment, schedule) if not callable(task): logging.error('Schedule references non-callable member %s', schedule) valid_tasks = [ x for x in experiment.__dict__ if callable(getattr(experiment, x)) and not x.startswith('_') ] logging.error('Allowed values for this experiment are: %s', valid_tasks) raise TypeError('Schedule references non-callable member %s', schedule) return task() def _is_distributed(config): """Returns true if this is a distributed job.""" if not config.cluster_spec: return False # This is considered a distributed job if there is more than one task # in the cluster spec. task_count = 0 for job in config.cluster_spec.jobs: for _ in config.cluster_spec.job_tasks(job): task_count += 1 return task_count > 1 def _get_default_schedule(config): """Returns the default schedule for the provided RunConfig.""" if not config or not _is_distributed(config): return 'train_and_evaluate' if not config.job_name: raise ValueError('Must specify a schedule') if config.job_name == 'master': # TODO(rhaertel): handle the case where there is more than one master # or explicitly disallow such a case. return 'train_and_evaluate' elif config.job_name == 'ps': return 'run_std_server' elif config.job_name == 'worker': return 'train' raise ValueError('No default schedule for task type: %s' % (config.job_name,))
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, 16291, 376, 23997, 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, 4643, 14, 1548, 14, 4643, 14, 10873, 492, 23997, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 421, 199, 318, 1255, 8, 10873, 63, 2324, 12, 1072, 63, 694, 12, 8732, 29, 403, 304, 523, 408, 5483, 436, 1255, 376, 11805, 14, 819, 2779, 8491, 376, 23997, 701, 6358, 658, 10873, 63, 2324, 2313, 9442, 652, 4882, 314, 523, 805, 4310, 465, 658, 7211, 64, 402, 314, 23997, 14, 819, 982, 8732, 365, 440, 2741, 12, 2066, 314, 849, 8732, 367, 314, 1453, 2120, 523, 730, 365, 1202, 14, 710, 4243, 787, 465, 11924, 26, 8410, 627, 283, 1190, 7, 9033, 370, 283, 4909, 7, 2043, 627, 283, 6599, 7, 9033, 370, 283, 2834, 7, 2043, 627, 283, 4133, 7, 9033, 370, 283, 1832, 63, 1065, 7, 819, 982, 314, 11805, 1159, 1101, 1630, 440, 2387, 282, 2120, 730, 12, 2066, 376, 1919, 523, 365, 4915, 14, 819, 5679, 26, 523, 10841, 272, 347, 485, 981, 63, 1662, 63, 10873, 8, 1199, 63, 694, 304, 267, 372, 2833, 14, 2828, 14, 4643, 14, 20781, 8, 881, 8943, 29, 1662, 63, 8627, 8, 1238, 63, 694, 29, 1199, 63, 694, 395, 881, 3560, 63, 1210, 63, 2324, 29, 1662, 63, 2834, 63, 1210, 12, 881, 3468, 63, 1210, 63, 2324, 29, 1662, 63, 2579, 63, 1210, 9, 339, 12537, 63, 5933, 14, 1065, 8, 489, 11805, 63, 2324, 3699, 981, 63, 1662, 63, 10873, 12, 489, 1072, 63, 694, 628, 3972, 15, 1199, 15, 694, 401, 489, 8732, 628, 2834, 531, 523, 10841, 523, 3033, 26, 272, 11805, 63, 2324, 26, 437, 805, 626, 8491, 376, 658, 20781, 2313, 2779, 1077, 4729, 376, 489, 1423, 658, 1199, 63, 694, 64, 1314, 1077, 506, 1202, 370, 1218, 314, 658, 13183, 64, 489, 334, 12070, 465, 658, 1238, 63, 694, 64, 370, 2399, 3787, 680, 2779, 1471, 372, 376, 489, 658, 20781, 2313, 272, 1072, 63, 694, 26, 3523, 1072, 2082, 14, 272, 8732, 26, 710, 536, 402, 314, 221, 1083, 315, 314, 658, 20781, 64, 370, 1255, 14, 819, 1803, 26, 272, 710, 372, 574, 402, 805, 658, 7211, 2313, 819, 6218, 26, 272, 1722, 26, 982, 658, 1199, 63, 694, 64, 365, 2701, 12, 658, 7211, 64, 365, 488, 1325, 949, 2120, 489, 730, 365, 663, 315, 314, 6137, 11805, 1159, 1101, 12, 314, 2120, 730, 965, 949, 489, 849, 12, 503, 658, 7211, 64, 3181, 1133, 3659, 282, 3653, 402, 658, 20781, 2313, 272, 3146, 26, 658, 7211, 64, 6941, 2222, 13, 8296, 3653, 14, 523, 408, 523, 340, 440, 1072, 63, 694, 26, 272, 746, 1722, 360, 13757, 4165, 376, 1072, 2082, 358, 523, 340, 440, 4550, 8, 10873, 63, 2324, 304, 272, 746, 3146, 360, 20781, 6545, 2071, 83, 2, 365, 440, 4550, 3530, 450, 490, 11805, 63, 2324, 9, 819, 327, 6523, 314, 6545, 523, 11805, 275, 11805, 63, 2324, 8, 1199, 63, 694, 29, 1199, 63, 694, 9, 523, 340, 440, 1228, 8, 10873, 12, 23997, 304, 272, 746, 3146, 360, 20781, 6545, 8103, 440, 372, 376, 23997, 283, 490, 283, 842, 12, 4788, 450, 83, 3140, 3530, 450, 730, 8, 10873, 430, 819, 327, 2372, 314, 8732, 523, 1101, 275, 11805, 14, 8627, 14, 888, 523, 8732, 275, 8732, 503, 485, 362, 63, 885, 63, 7211, 8, 888, 9, 819, 327, 17009, 314, 8732, 523, 340, 440, 2688, 8, 10873, 12, 8732, 304, 272, 2050, 14, 705, 360, 15535, 6941, 2222, 13, 15025, 2120, 450, 83, 297, 8732, 9, 272, 1686, 63, 5054, 275, 359, 88, 367, 671, 315, 11805, 855, 807, 363, 673, 340, 4550, 8, 5675, 8, 10873, 12, 671, 10524, 272, 2050, 14, 705, 360, 16070, 1338, 367, 642, 11805, 787, 26, 450, 83, 297, 1686, 63, 5054, 9, 272, 746, 1722, 360, 15535, 6941, 2222, 13, 15025, 2120, 450, 83, 297, 8732, 9, 819, 2120, 275, 2519, 8, 10873, 12, 8732, 9, 523, 340, 440, 4550, 8, 1765, 304, 272, 2050, 14, 705, 360, 15535, 6941, 2222, 13, 8296, 3653, 450, 83, 297, 8732, 9, 272, 1686, 63, 5054, 275, 359, 267, 671, 367, 671, 315, 11805, 855, 807, 363, 267, 340, 4550, 8, 5675, 8, 10873, 12, 671, 430, 436, 440, 671, 14, 2460, 26341, 272, 1622, 272, 2050, 14, 705, 360, 16070, 1338, 367, 642, 11805, 787, 26, 450, 83, 297, 1686, 63, 5054, 9, 272, 746, 3146, 360, 15535, 6941, 2222, 13, 8296, 3653, 450, 83, 297, 8732, 9, 819, 372, 2120, 342, 421, 199, 318, 485, 374, 63, 16832, 8, 888, 304, 523, 408, 3407, 2549, 340, 642, 365, 282, 1854, 3906, 1041, 523, 340, 440, 1101, 14, 4201, 63, 1650, 26, 272, 372, 756, 819, 327, 961, 365, 8652, 282, 1854, 3906, 340, 2337, 365, 1655, 2419, 1373, 2120, 523, 327, 315, 314, 4350, 3158, 14, 523, 2120, 63, 835, 275, 378, 523, 367, 3906, 315, 1101, 14, 4201, 63, 1650, 14, 6920, 26, 272, 367, 485, 315, 1101, 14, 4201, 63, 1650, 14, 2423, 63, 5054, 8, 2423, 304, 489, 2120, 63, 835, 847, 413, 819, 372, 2120, 63, 835 ]
[ 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, 16291, 376, 23997, 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, 4643, 14, 1548, 14, 4643, 14, 10873, 492, 23997, 199, 504, 3228, 14, 1548, 14, 3246, 492, 2833, 63, 4806, 465, 2050, 421, 199, 318, 1255, 8, 10873, 63, 2324, 12, 1072, 63, 694, 12, 8732, 29, 403, 304, 523, 408, 5483, 436, 1255, 376, 11805, 14, 819, 2779, 8491, 376, 23997, 701, 6358, 658, 10873, 63, 2324, 2313, 9442, 652, 4882, 314, 523, 805, 4310, 465, 658, 7211, 64, 402, 314, 23997, 14, 819, 982, 8732, 365, 440, 2741, 12, 2066, 314, 849, 8732, 367, 314, 1453, 2120, 523, 730, 365, 1202, 14, 710, 4243, 787, 465, 11924, 26, 8410, 627, 283, 1190, 7, 9033, 370, 283, 4909, 7, 2043, 627, 283, 6599, 7, 9033, 370, 283, 2834, 7, 2043, 627, 283, 4133, 7, 9033, 370, 283, 1832, 63, 1065, 7, 819, 982, 314, 11805, 1159, 1101, 1630, 440, 2387, 282, 2120, 730, 12, 2066, 376, 1919, 523, 365, 4915, 14, 819, 5679, 26, 523, 10841, 272, 347, 485, 981, 63, 1662, 63, 10873, 8, 1199, 63, 694, 304, 267, 372, 2833, 14, 2828, 14, 4643, 14, 20781, 8, 881, 8943, 29, 1662, 63, 8627, 8, 1238, 63, 694, 29, 1199, 63, 694, 395, 881, 3560, 63, 1210, 63, 2324, 29, 1662, 63, 2834, 63, 1210, 12, 881, 3468, 63, 1210, 63, 2324, 29, 1662, 63, 2579, 63, 1210, 9, 339, 12537, 63, 5933, 14, 1065, 8, 489, 11805, 63, 2324, 3699, 981, 63, 1662, 63, 10873, 12, 489, 1072, 63, 694, 628, 3972, 15, 1199, 15, 694, 401, 489, 8732, 628, 2834, 531, 523, 10841, 523, 3033, 26, 272, 11805, 63, 2324, 26, 437, 805, 626, 8491, 376, 658, 20781, 2313, 2779, 1077, 4729, 376, 489, 1423, 658, 1199, 63, 694, 64, 1314, 1077, 506, 1202, 370, 1218, 314, 658, 13183, 64, 489, 334, 12070, 465, 658, 1238, 63, 694, 64, 370, 2399, 3787, 680, 2779, 1471, 372, 376, 489, 658, 20781, 2313, 272, 1072, 63, 694, 26, 3523, 1072, 2082, 14, 272, 8732, 26, 710, 536, 402, 314, 221, 1083, 315, 314, 658, 20781, 64, 370, 1255, 14, 819, 1803, 26, 272, 710, 372, 574, 402, 805, 658, 7211, 2313, 819, 6218, 26, 272, 1722, 26, 982, 658, 1199, 63, 694, 64, 365, 2701, 12, 658, 7211, 64, 365, 488, 1325, 949, 2120, 489, 730, 365, 663, 315, 314, 6137, 11805, 1159, 1101, 12, 314, 2120, 730, 965, 949, 489, 849, 12, 503, 658, 7211, 64, 3181, 1133, 3659, 282, 3653, 402, 658, 20781, 2313, 272, 3146, 26, 658, 7211, 64, 6941, 2222, 13, 8296, 3653, 14, 523, 408, 523, 340, 440, 1072, 63, 694, 26, 272, 746, 1722, 360, 13757, 4165, 376, 1072, 2082, 358, 523, 340, 440, 4550, 8, 10873, 63, 2324, 304, 272, 746, 3146, 360, 20781, 6545, 2071, 83, 2, 365, 440, 4550, 3530, 450, 490, 11805, 63, 2324, 9, 819, 327, 6523, 314, 6545, 523, 11805, 275, 11805, 63, 2324, 8, 1199, 63, 694, 29, 1199, 63, 694, 9, 523, 340, 440, 1228, 8, 10873, 12, 23997, 304, 272, 746, 3146, 360, 20781, 6545, 8103, 440, 372, 376, 23997, 283, 490, 283, 842, 12, 4788, 450, 83, 3140, 3530, 450, 730, 8, 10873, 430, 819, 327, 2372, 314, 8732, 523, 1101, 275, 11805, 14, 8627, 14, 888, 523, 8732, 275, 8732, 503, 485, 362, 63, 885, 63, 7211, 8, 888, 9, 819, 327, 17009, 314, 8732, 523, 340, 440, 2688, 8, 10873, 12, 8732, 304, 272, 2050, 14, 705, 360, 15535, 6941, 2222, 13, 15025, 2120, 450, 83, 297, 8732, 9, 272, 1686, 63, 5054, 275, 359, 88, 367, 671, 315, 11805, 855, 807, 363, 673, 340, 4550, 8, 5675, 8, 10873, 12, 671, 10524, 272, 2050, 14, 705, 360, 16070, 1338, 367, 642, 11805, 787, 26, 450, 83, 297, 1686, 63, 5054, 9, 272, 746, 1722, 360, 15535, 6941, 2222, 13, 15025, 2120, 450, 83, 297, 8732, 9, 819, 2120, 275, 2519, 8, 10873, 12, 8732, 9, 523, 340, 440, 4550, 8, 1765, 304, 272, 2050, 14, 705, 360, 15535, 6941, 2222, 13, 8296, 3653, 450, 83, 297, 8732, 9, 272, 1686, 63, 5054, 275, 359, 267, 671, 367, 671, 315, 11805, 855, 807, 363, 267, 340, 4550, 8, 5675, 8, 10873, 12, 671, 430, 436, 440, 671, 14, 2460, 26341, 272, 1622, 272, 2050, 14, 705, 360, 16070, 1338, 367, 642, 11805, 787, 26, 450, 83, 297, 1686, 63, 5054, 9, 272, 746, 3146, 360, 15535, 6941, 2222, 13, 8296, 3653, 450, 83, 297, 8732, 9, 819, 372, 2120, 342, 421, 199, 318, 485, 374, 63, 16832, 8, 888, 304, 523, 408, 3407, 2549, 340, 642, 365, 282, 1854, 3906, 1041, 523, 340, 440, 1101, 14, 4201, 63, 1650, 26, 272, 372, 756, 819, 327, 961, 365, 8652, 282, 1854, 3906, 340, 2337, 365, 1655, 2419, 1373, 2120, 523, 327, 315, 314, 4350, 3158, 14, 523, 2120, 63, 835, 275, 378, 523, 367, 3906, 315, 1101, 14, 4201, 63, 1650, 14, 6920, 26, 272, 367, 485, 315, 1101, 14, 4201, 63, 1650, 14, 2423, 63, 5054, 8, 2423, 304, 489, 2120, 63, 835, 847, 413, 819, 372, 2120, 63, 835, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
40223101/w17test
static/Brython3.1.0-20150301-090019/Lib/errno.py
624
4096
""" This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value, e.g., on most systems, errno.ENOENT equals the integer 2. The dictionary errno.errorcode maps numeric codes to symbol names, e.g., errno.errorcode[2] could be the string 'ENOENT'. Symbols that are not relevant to the underlying system are not defined. To map error codes to error messages, use the function os.strerror(), e.g. os.strerror(2) could return 'No such file or directory'. """ errorcode= {1: 'EPERM', 2: 'ENOENT', 3: 'ESRCH', 4: 'EINTR', 5: 'EIO', 6: 'ENXIO', 7: 'E2BIG', 8: 'ENOEXEC', 9: 'EBADF', 10: 'ECHILD', 11: 'EAGAIN', 12: 'ENOMEM', 13: 'EACCES', 14: 'EFAULT', 15: 'ENOTBLK', 16: 'EBUSY', 17: 'EEXIST', 18: 'EXDEV', 19: 'ENODEV', 20: 'ENOTDIR', 21: 'EISDIR', 22: 'EINVAL', 23: 'ENFILE', 24: 'EMFILE', 25: 'ENOTTY', 26: 'ETXTBSY', 27: 'EFBIG', 28: 'ENOSPC', 29: 'ESPIPE', 30: 'EROFS', 31: 'EMLINK', 32: 'EPIPE', 33: 'EDOM', 34: 'ERANGE', 35: 'EDEADLOCK', 36: 'ENAMETOOLONG', 37: 'ENOLCK', 38: 'ENOSYS', 39: 'ENOTEMPTY', 40: 'ELOOP', 42: 'ENOMSG', 43: 'EIDRM', 44: 'ECHRNG', 45: 'EL2NSYNC', 46: 'EL3HLT', 47: 'EL3RST', 48: 'ELNRNG', 49: 'EUNATCH', 50: 'ENOCSI', 51: 'EL2HLT', 52: 'EBADE', 53: 'EBADR', 54: 'EXFULL', 55: 'ENOANO', 56: 'EBADRQC', 57: 'EBADSLT', 59: 'EBFONT', 60: 'ENOSTR', 61: 'ENODATA', 62: 'ETIME', 63: 'ENOSR', 64: 'ENONET', 65: 'ENOPKG', 66: 'EREMOTE', 67: 'ENOLINK', 68: 'EADV', 69: 'ESRMNT', 70: 'ECOMM', 71: 'EPROTO', 72: 'EMULTIHOP', 73: 'EDOTDOT', 74: 'EBADMSG', 75: 'EOVERFLOW', 76: 'ENOTUNIQ', 77: 'EBADFD', 78: 'EREMCHG', 79: 'ELIBACC', 80: 'ELIBBAD', 81: 'ELIBSCN', 82: 'ELIBMAX', 83: 'ELIBEXEC', 84: 'EILSEQ', 85: 'ERESTART', 86: 'ESTRPIPE', 87: 'EUSERS', 88: 'ENOTSOCK', 89: 'EDESTADDRREQ', 90: 'EMSGSIZE', 91: 'EPROTOTYPE', 92: 'ENOPROTOOPT', 93: 'EPROTONOSUPPORT', 94: 'ESOCKTNOSUPPORT', 95: 'ENOTSUP', 96: 'EPFNOSUPPORT', 97: 'EAFNOSUPPORT', 98: 'EADDRINUSE', 99: 'EADDRNOTAVAIL', 100: 'ENETDOWN', 101: 'ENETUNREACH', 102: 'ENETRESET', 103: 'ECONNABORTED', 104: 'ECONNRESET', 105: 'ENOBUFS', 106: 'EISCONN', 107: 'ENOTCONN', 108: 'ESHUTDOWN', 109: 'ETOOMANYREFS', 110: 'ETIMEDOUT', 111: 'ECONNREFUSED', 112: 'EHOSTDOWN', 113: 'EHOSTUNREACH', 114: 'EALREADY', 115: 'EINPROGRESS', 116: 'ESTALE', 117: 'EUCLEAN', 118: 'ENOTNAM', 119: 'ENAVAIL', 120: 'EISNAM', 121: 'EREMOTEIO', 122: 'EDQUOT', 123: 'ENOMEDIUM', 124: 'EMEDIUMTYPE', 125: 'ECANCELED', 126: 'ENOKEY', 127: 'EKEYEXPIRED', 128: 'EKEYREVOKED', 129: 'EKEYREJECTED', 130: 'EOWNERDEAD', 131: 'ENOTRECOVERABLE', 132: 'ERFKILL'} EPERM=1 ENOENT=2 ESRCH=3 EINTR=4 EIO=5 ENXIO=6 E2BIG=7 ENOEXEC=8 EBADF=9 ECHILD=10 EAGAIN=11 ENOMEM=12 EACCES=13 EFAULT=14 ENOTBLK=15 EBUSY=16 EEXIST=17 EXDEV=18 ENODEV=19 ENOTDIR=20 EISDIR=21 EINVAL=22 ENFILE=23 EMFILE=24 ENOTTY=25 ETXTBSY=26 EFBIG=27 ENOSPC=28 ESPIPE=29 EROFS=30 EMLINK=31 EPIPE=32 EDOM=33 ERANGE=34 EDEADLOCK=35 ENAMETOOLONG=36 ENOLCK=37 ENOSYS=38 ENOTEMPTY=39 ELOOP=40 ENOMSG=42 EIDRM=43 ECHRNG=44 EL2NSYNC=45 EL3HLT=46 EL3RST=47 ELNRNG=48 EUNATCH=49 ENOCSI=50 EL2HLT=51 EBADE=52 EBADR=53 EXFULL=54 ENOANO=55 EBADRQC=56 EBADSLT=57 EBFONT=59 ENOSTR=60 ENODATA=61 ETIME=62 ENOSR=63 ENONET=64 ENOPKG=65 EREMOTE=66 ENOLINK=67 EADV=68 ESRMNT=69 ECOMM=70 EPROTO=71 EMULTIHOP=72 EDOTDOT=73 EBADMSG=74 EOVERFLOW=75 ENOTUNIQ=76 EBADFD=77 EREMCHG=78 ELIBACC=79 ELIBBAD=80 ELIBSCN=81 ELIBMAX=82 ELIBEXEC=83 EILSEQ=84 ERESTART=85 ESTRPIPE=86 EUSERS=87 ENOTSOCK=88 EDESTADDRREQ=89 EMSGSIZE=90 EPROTOTYPE=91 ENOPROTOOPT=92 EPROTONOSUPPORT=93 ESOCKTNOSUPPORT=94 ENOTSUP=95 EPFNOSUPPORT=96 EAFNOSUPPORT=97 EADDRINUSE=98 EADDRNOTAVAIL=99 ENETDOWN=100 ENETUNREACH=101 ENETRESET=102 ECONNABORTED=103 ECONNRESET=104 ENOBUFS=105 EISCONN=106 ENOTCONN=107 ESHUTDOWN=108 ETOOMANYREFS=109 ETIMEDOUT=110 ECONNREFUSED=111 EHOSTDOWN=112 EHOSTUNREACH=113 EALREADY=114 EINPROGRESS=115 ESTALE=116 EUCLEAN=117 ENOTNAM=118 ENAVAIL=119 EISNAM=120 EREMOTEIO=121 EDQUOT=122 ENOMEDIUM=123 EMEDIUMTYPE=124 ECANCELED=125 ENOKEY=126 EKEYEXPIRED=127 EKEYREVOKED=128 EKEYREJECTED=129 EOWNERDEAD=130 ENOTRECOVERABLE=131 ERFKILL=132
gpl-3.0
[ 624, 199, 2765, 859, 7704, 2808, 4465, 7554, 2656, 6698, 14, 199, 1918, 574, 402, 1924, 5272, 365, 314, 5226, 3000, 574, 12, 199, 69, 14, 71, 2020, 641, 4750, 10460, 12, 7554, 14, 20465, 18527, 314, 3000, 499, 14, 199, 1918, 2600, 7554, 14, 28857, 9033, 8950, 9479, 370, 5272, 1561, 12, 199, 69, 14, 71, 2020, 7554, 14, 28857, 59, 18, 61, 4293, 506, 314, 1059, 283, 20465, 1370, 199, 199, 20574, 626, 787, 440, 12082, 370, 314, 8793, 2656, 787, 440, 3247, 14, 199, 199, 1378, 2341, 1125, 9479, 370, 1125, 3788, 12, 675, 314, 805, 747, 14, 20395, 1062, 199, 69, 14, 71, 14, 747, 14, 20395, 8, 18, 9, 4293, 372, 283, 1944, 4066, 570, 503, 2082, 1370, 199, 624, 199, 199, 28857, 29, 469, 17, 26, 283, 37, 29065, 297, 499, 26, 283, 20465, 297, 650, 26, 283, 654, 50, 1244, 297, 841, 26, 283, 37, 19652, 297, 959, 26, 283, 37, 2090, 297, 221, 199, 22, 26, 283, 742, 56, 2090, 297, 1520, 26, 283, 37, 18, 18643, 297, 1695, 26, 283, 15577, 10276, 297, 1749, 26, 283, 37, 9439, 38, 297, 1616, 26, 283, 25126, 6853, 297, 4119, 26, 283, 37, 1254, 9021, 297, 221, 199, 713, 26, 283, 742, 7474, 2769, 297, 4944, 26, 283, 37, 7372, 654, 297, 4329, 26, 283, 37, 2794, 297, 4114, 26, 283, 32710, 7847, 43, 297, 3193, 26, 283, 14138, 1668, 57, 297, 221, 199, 1196, 26, 283, 28596, 297, 6155, 26, 283, 1438, 13260, 297, 5851, 26, 283, 742, 9125, 54, 297, 3388, 26, 283, 32710, 3022, 297, 7829, 26, 283, 37, 1311, 3022, 297, 221, 199, 1081, 26, 283, 29510, 297, 6546, 26, 283, 742, 3817, 297, 5504, 26, 283, 2769, 3817, 297, 5661, 26, 283, 32710, 2099, 297, 7875, 26, 283, 775, 18926, 34, 4669, 297, 221, 199, 1465, 26, 283, 37, 8223, 1277, 297, 7294, 26, 283, 742, 3100, 4222, 297, 7349, 26, 283, 654, 6089, 297, 4233, 26, 283, 540, 3359, 51, 297, 7105, 26, 283, 37, 1698, 12394, 297, 221, 199, 708, 26, 283, 37, 6089, 297, 9404, 26, 283, 1149, 7474, 297, 8177, 26, 283, 540, 9011, 297, 8685, 26, 283, 37, 29031, 4406, 297, 8780, 26, 283, 742, 1156, 26614, 2228, 7770, 297, 221, 199, 1401, 26, 283, 742, 2228, 2504, 297, 10448, 26, 283, 742, 3100, 20238, 297, 10551, 26, 283, 742, 9407, 9800, 297, 6335, 26, 283, 37, 26573, 297, 5685, 26, 283, 15577, 9740, 297, 221, 199, 2824, 26, 283, 37, 998, 11026, 297, 10868, 26, 283, 25126, 50, 12259, 297, 10416, 26, 283, 2901, 18, 2709, 57, 6389, 297, 12426, 26, 283, 2901, 19, 40, 17090, 297, 10954, 26, 283, 2901, 19, 10171, 297, 221, 199, 2006, 26, 283, 2901, 17774, 12259, 297, 12260, 26, 283, 37, 1734, 8078, 297, 5238, 26, 283, 15577, 35, 2684, 297, 8026, 26, 283, 2901, 18, 40, 17090, 297, 14589, 26, 283, 37, 4134, 1093, 297, 221, 199, 2481, 26, 283, 37, 9439, 50, 297, 13470, 26, 283, 1438, 14742, 297, 12766, 26, 283, 15577, 879, 47, 297, 12001, 26, 283, 37, 9439, 50, 49, 35, 297, 12699, 26, 283, 37, 9439, 4929, 52, 297, 221, 199, 1427, 26, 283, 37, 12659, 5994, 297, 5212, 26, 283, 15577, 3027, 297, 17017, 26, 283, 15577, 3998, 297, 16202, 26, 283, 10931, 297, 13668, 26, 283, 742, 3100, 50, 297, 221, 199, 772, 26, 283, 742, 615, 775, 297, 11738, 26, 283, 742, 1938, 14634, 297, 14157, 26, 283, 540, 2769, 9407, 297, 13296, 26, 283, 742, 2228, 12394, 297, 10851, 26, 283, 37, 1554, 54, 297, 221, 199, 1876, 26, 283, 654, 11026, 12460, 297, 10045, 26, 283, 37, 5378, 297, 17245, 26, 283, 37, 7459, 297, 15323, 26, 283, 2769, 2233, 19824, 1938, 297, 18525, 26, 283, 1149, 1387, 13203, 297, 221, 199, 1342, 26, 283, 37, 9439, 9740, 297, 13098, 26, 283, 37, 14336, 17114, 297, 14646, 26, 283, 32710, 15134, 49, 297, 8375, 26, 283, 37, 9439, 7902, 297, 14679, 26, 283, 540, 2769, 1244, 39, 297, 221, 199, 1965, 26, 283, 2901, 2100, 7372, 297, 5939, 26, 283, 2901, 2100, 9439, 297, 19071, 26, 283, 2901, 2100, 5153, 46, 297, 18051, 26, 283, 2901, 2100, 4283, 297, 20582, 26, 283, 2901, 2100, 10276, 297, 221, 199, 1349, 26, 283, 37, 1193, 28674, 297, 16412, 26, 283, 540, 1719, 2294, 297, 10300, 26, 283, 1719, 50, 6089, 297, 10513, 26, 283, 37, 28164, 297, 10523, 26, 283, 32710, 9469, 297, 221, 199, 1407, 26, 283, 1149, 1719, 7803, 14583, 297, 9137, 26, 283, 2769, 4254, 4305, 297, 21358, 26, 283, 37, 2514, 14261, 4948, 297, 20140, 26, 283, 742, 1938, 1092, 2566, 5123, 297, 221, 199, 3129, 26, 283, 37, 2514, 12143, 3100, 2160, 3657, 297, 18729, 26, 283, 654, 47, 2504, 52, 2826, 10640, 297, 16102, 26, 283, 32710, 7380, 297, 221, 199, 2534, 26, 283, 6102, 38, 2826, 10640, 297, 15997, 26, 283, 37, 5699, 2826, 10640, 297, 16096, 26, 283, 37, 7803, 568, 4701, 297, 221, 199, 1020, 26, 283, 37, 7803, 4609, 15004, 297, 2948, 26, 283, 742, 775, 8819, 297, 14313, 26, 283, 742, 775, 1734, 24345, 1244, 297, 12996, 26, 283, 742, 775, 18066, 297, 221, 199, 8845, 26, 283, 37, 17489, 27113, 1149, 297, 21083, 26, 283, 37, 17489, 18066, 297, 20462, 26, 283, 15577, 2910, 7079, 297, 23746, 26, 283, 37, 1311, 17489, 297, 221, 199, 7555, 26, 283, 32710, 17489, 297, 24579, 26, 283, 654, 40, 934, 8819, 297, 24058, 26, 283, 775, 5757, 6588, 57, 907, 7079, 297, 16814, 26, 283, 775, 1469, 1149, 1877, 297, 221, 199, 6673, 26, 283, 37, 17489, 8279, 8558, 297, 20240, 26, 283, 37, 5449, 8819, 297, 24073, 26, 283, 37, 5449, 1734, 24345, 1244, 297, 23510, 26, 283, 37, 32687, 297, 221, 199, 7680, 26, 283, 25652, 24547, 297, 25186, 26, 283, 1719, 28553, 297, 26189, 26, 283, 23539, 28663, 297, 25760, 26, 283, 32710, 7335, 297, 221, 199, 7119, 26, 283, 742, 15004, 297, 13960, 26, 283, 37, 1311, 7335, 297, 26228, 26, 283, 540, 2769, 9407, 2090, 297, 24557, 26, 283, 1149, 18654, 297, 221, 199, 4288, 26, 283, 742 ]
[ 199, 2765, 859, 7704, 2808, 4465, 7554, 2656, 6698, 14, 199, 1918, 574, 402, 1924, 5272, 365, 314, 5226, 3000, 574, 12, 199, 69, 14, 71, 2020, 641, 4750, 10460, 12, 7554, 14, 20465, 18527, 314, 3000, 499, 14, 199, 1918, 2600, 7554, 14, 28857, 9033, 8950, 9479, 370, 5272, 1561, 12, 199, 69, 14, 71, 2020, 7554, 14, 28857, 59, 18, 61, 4293, 506, 314, 1059, 283, 20465, 1370, 199, 199, 20574, 626, 787, 440, 12082, 370, 314, 8793, 2656, 787, 440, 3247, 14, 199, 199, 1378, 2341, 1125, 9479, 370, 1125, 3788, 12, 675, 314, 805, 747, 14, 20395, 1062, 199, 69, 14, 71, 14, 747, 14, 20395, 8, 18, 9, 4293, 372, 283, 1944, 4066, 570, 503, 2082, 1370, 199, 624, 199, 199, 28857, 29, 469, 17, 26, 283, 37, 29065, 297, 499, 26, 283, 20465, 297, 650, 26, 283, 654, 50, 1244, 297, 841, 26, 283, 37, 19652, 297, 959, 26, 283, 37, 2090, 297, 221, 199, 22, 26, 283, 742, 56, 2090, 297, 1520, 26, 283, 37, 18, 18643, 297, 1695, 26, 283, 15577, 10276, 297, 1749, 26, 283, 37, 9439, 38, 297, 1616, 26, 283, 25126, 6853, 297, 4119, 26, 283, 37, 1254, 9021, 297, 221, 199, 713, 26, 283, 742, 7474, 2769, 297, 4944, 26, 283, 37, 7372, 654, 297, 4329, 26, 283, 37, 2794, 297, 4114, 26, 283, 32710, 7847, 43, 297, 3193, 26, 283, 14138, 1668, 57, 297, 221, 199, 1196, 26, 283, 28596, 297, 6155, 26, 283, 1438, 13260, 297, 5851, 26, 283, 742, 9125, 54, 297, 3388, 26, 283, 32710, 3022, 297, 7829, 26, 283, 37, 1311, 3022, 297, 221, 199, 1081, 26, 283, 29510, 297, 6546, 26, 283, 742, 3817, 297, 5504, 26, 283, 2769, 3817, 297, 5661, 26, 283, 32710, 2099, 297, 7875, 26, 283, 775, 18926, 34, 4669, 297, 221, 199, 1465, 26, 283, 37, 8223, 1277, 297, 7294, 26, 283, 742, 3100, 4222, 297, 7349, 26, 283, 654, 6089, 297, 4233, 26, 283, 540, 3359, 51, 297, 7105, 26, 283, 37, 1698, 12394, 297, 221, 199, 708, 26, 283, 37, 6089, 297, 9404, 26, 283, 1149, 7474, 297, 8177, 26, 283, 540, 9011, 297, 8685, 26, 283, 37, 29031, 4406, 297, 8780, 26, 283, 742, 1156, 26614, 2228, 7770, 297, 221, 199, 1401, 26, 283, 742, 2228, 2504, 297, 10448, 26, 283, 742, 3100, 20238, 297, 10551, 26, 283, 742, 9407, 9800, 297, 6335, 26, 283, 37, 26573, 297, 5685, 26, 283, 15577, 9740, 297, 221, 199, 2824, 26, 283, 37, 998, 11026, 297, 10868, 26, 283, 25126, 50, 12259, 297, 10416, 26, 283, 2901, 18, 2709, 57, 6389, 297, 12426, 26, 283, 2901, 19, 40, 17090, 297, 10954, 26, 283, 2901, 19, 10171, 297, 221, 199, 2006, 26, 283, 2901, 17774, 12259, 297, 12260, 26, 283, 37, 1734, 8078, 297, 5238, 26, 283, 15577, 35, 2684, 297, 8026, 26, 283, 2901, 18, 40, 17090, 297, 14589, 26, 283, 37, 4134, 1093, 297, 221, 199, 2481, 26, 283, 37, 9439, 50, 297, 13470, 26, 283, 1438, 14742, 297, 12766, 26, 283, 15577, 879, 47, 297, 12001, 26, 283, 37, 9439, 50, 49, 35, 297, 12699, 26, 283, 37, 9439, 4929, 52, 297, 221, 199, 1427, 26, 283, 37, 12659, 5994, 297, 5212, 26, 283, 15577, 3027, 297, 17017, 26, 283, 15577, 3998, 297, 16202, 26, 283, 10931, 297, 13668, 26, 283, 742, 3100, 50, 297, 221, 199, 772, 26, 283, 742, 615, 775, 297, 11738, 26, 283, 742, 1938, 14634, 297, 14157, 26, 283, 540, 2769, 9407, 297, 13296, 26, 283, 742, 2228, 12394, 297, 10851, 26, 283, 37, 1554, 54, 297, 221, 199, 1876, 26, 283, 654, 11026, 12460, 297, 10045, 26, 283, 37, 5378, 297, 17245, 26, 283, 37, 7459, 297, 15323, 26, 283, 2769, 2233, 19824, 1938, 297, 18525, 26, 283, 1149, 1387, 13203, 297, 221, 199, 1342, 26, 283, 37, 9439, 9740, 297, 13098, 26, 283, 37, 14336, 17114, 297, 14646, 26, 283, 32710, 15134, 49, 297, 8375, 26, 283, 37, 9439, 7902, 297, 14679, 26, 283, 540, 2769, 1244, 39, 297, 221, 199, 1965, 26, 283, 2901, 2100, 7372, 297, 5939, 26, 283, 2901, 2100, 9439, 297, 19071, 26, 283, 2901, 2100, 5153, 46, 297, 18051, 26, 283, 2901, 2100, 4283, 297, 20582, 26, 283, 2901, 2100, 10276, 297, 221, 199, 1349, 26, 283, 37, 1193, 28674, 297, 16412, 26, 283, 540, 1719, 2294, 297, 10300, 26, 283, 1719, 50, 6089, 297, 10513, 26, 283, 37, 28164, 297, 10523, 26, 283, 32710, 9469, 297, 221, 199, 1407, 26, 283, 1149, 1719, 7803, 14583, 297, 9137, 26, 283, 2769, 4254, 4305, 297, 21358, 26, 283, 37, 2514, 14261, 4948, 297, 20140, 26, 283, 742, 1938, 1092, 2566, 5123, 297, 221, 199, 3129, 26, 283, 37, 2514, 12143, 3100, 2160, 3657, 297, 18729, 26, 283, 654, 47, 2504, 52, 2826, 10640, 297, 16102, 26, 283, 32710, 7380, 297, 221, 199, 2534, 26, 283, 6102, 38, 2826, 10640, 297, 15997, 26, 283, 37, 5699, 2826, 10640, 297, 16096, 26, 283, 37, 7803, 568, 4701, 297, 221, 199, 1020, 26, 283, 37, 7803, 4609, 15004, 297, 2948, 26, 283, 742, 775, 8819, 297, 14313, 26, 283, 742, 775, 1734, 24345, 1244, 297, 12996, 26, 283, 742, 775, 18066, 297, 221, 199, 8845, 26, 283, 37, 17489, 27113, 1149, 297, 21083, 26, 283, 37, 17489, 18066, 297, 20462, 26, 283, 15577, 2910, 7079, 297, 23746, 26, 283, 37, 1311, 17489, 297, 221, 199, 7555, 26, 283, 32710, 17489, 297, 24579, 26, 283, 654, 40, 934, 8819, 297, 24058, 26, 283, 775, 5757, 6588, 57, 907, 7079, 297, 16814, 26, 283, 775, 1469, 1149, 1877, 297, 221, 199, 6673, 26, 283, 37, 17489, 8279, 8558, 297, 20240, 26, 283, 37, 5449, 8819, 297, 24073, 26, 283, 37, 5449, 1734, 24345, 1244, 297, 23510, 26, 283, 37, 32687, 297, 221, 199, 7680, 26, 283, 25652, 24547, 297, 25186, 26, 283, 1719, 28553, 297, 26189, 26, 283, 23539, 28663, 297, 25760, 26, 283, 32710, 7335, 297, 221, 199, 7119, 26, 283, 742, 15004, 297, 13960, 26, 283, 37, 1311, 7335, 297, 26228, 26, 283, 540, 2769, 9407, 2090, 297, 24557, 26, 283, 1149, 18654, 297, 221, 199, 4288, 26, 283, 742, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
itaymendel/taurus
tests/modules/test_cloudProvisioning.py
1
53218
import json import os import shutil import tempfile import time import yaml from bzt import TaurusConfigError, TaurusException from bzt.bza import Master, Test, MultiTest from bzt.engine import ScenarioExecutor, ManualShutdown, Service from bzt.modules.aggregator import ConsolidatingAggregator, DataPoint, KPISet from bzt.modules.blazemeter import CloudProvisioning, ResultsFromBZA, ServiceStubCaptureHAR from bzt.modules.blazemeter import CloudTaurusTest, CloudCollectionTest from bzt.utils import get_full_path from tests import BZTestCase, __dir__ from tests.mocks import EngineEmul, ModuleMock, RecordingHandler from tests.modules.test_blazemeter import BZMock class TestCloudProvisioning(BZTestCase): @staticmethod def __get_user_info(): with open(__dir__() + "/../json/blazemeter-api-user.json") as fhd: return json.loads(fhd.read()) def setUp(self): engine = EngineEmul() engine.aggregator = ConsolidatingAggregator() self.obj = CloudProvisioning() self.obj.settings.merge({'delete-test-files': False}) self.obj.engine = engine self.obj.browser_open = False self.mock = BZMock(self.obj.user) self.mock.mock_post.update({ 'https://a.blazemeter.com/api/v4/projects': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/tests': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/tests/1/files': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/tests/1/start': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/masters/1/stop': {"result": True}, }) def configure(self, engine_cfg=None, get=None, post=None, patch=None, add_config=True, add_settings=True): if engine_cfg is None: engine_cfg = {} self.obj.engine.config.merge(engine_cfg) if add_settings: self.obj.settings["token"] = "FakeToken" self.obj.settings["browser-open"] = False self.obj.settings['default-location'] = "us-east-1" if add_config: self.obj.engine.config.merge({ "modules": {"mock": ModuleMock.__module__ + "." + ModuleMock.__name__}, "provisioning": "mock"}) self.obj.parameters = self.obj.engine.config.get('execution') if isinstance(self.obj.parameters, list): self.obj.parameters = self.obj.parameters[0] self.mock.mock_get.update(get if get else {}) self.mock.mock_post.update(post if post else {}) self.mock.mock_patch.update(patch if patch else {}) self.mock.mock_patch.update({'https://a.blazemeter.com/api/v4/tests/1': {"result": {}}}) def test_simple(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 2}}}, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": []}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {}}, }, post={ } ) # terminate self.obj.prepare() self.assertEquals(1, self.obj.executors[0].execution['locations']['us-east-1']) self.assertEquals(2, self.obj.executors[0].execution['locations']['us-west']) self.obj.startup() self.obj.check() self.obj.shutdown() self.obj.post_process() def test_no_results(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 2}}}, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": []}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {"sessions": [{ "errors": [ { "code": 70404, "message": "Session ended without load report data", "details": None } ], }]}}, }, post={ } ) # terminate self.obj.prepare() self.assertEquals(1, self.obj.executors[0].execution['locations']['us-east-1']) self.assertEquals(2, self.obj.executors[0].execution['locations']['us-west']) self.obj.startup() self.obj.check() self.obj.shutdown() self.assertRaises(TaurusException, self.obj.post_process) def test_detach(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 55, "locations": { "us-east-1": 1, "us-west": 2}}}, get={ 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {}}, } ) self.obj.settings["detach"] = True self.obj.prepare() self.assertEqual(11, len(self.mock.requests)) self.obj.startup() self.assertEqual(12, len(self.mock.requests)) self.obj.check() self.obj.shutdown() self.obj.post_process() def test_no_settings(self): self.configure(engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, ) self.obj.prepare() self.assertEquals(1, self.obj.executors[0].execution['locations']['us-east-1']) def test_skip_reporting(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", }, "modules": { "blazemeter": ModuleMock.__module__ + "." + ModuleMock.__name__, "second_reporter": ModuleMock.__module__ + "." + ModuleMock.__name__, "third_reporter": ModuleMock.__module__ + "." + ModuleMock.__name__, }, "reporting": ["blazemeter", {"module": "blazemeter", "option": "value"}, "second_reporter", {"module": "third_reporter"}] }, ) self.obj.prepare() modules = [reporter['module'] for reporter in self.obj.engine.config['reporting']] self.assertEquals(modules, ['second_reporter', 'third_reporter']) def test_widget_cloud_test(self): test = Test(self.obj.user, {"id": 1, 'name': 'testname'}) self.obj.router = CloudTaurusTest(self.obj.user, test, None, None, None, self.obj.log) self.configure(get={ 'https://a.blazemeter.com/api/v4/masters/1/sessions': [ {"result": {"sessions": []}}, {"result": {"sessions": [{ "name": "executor/scenario/location", "configuration": { "location": "loc-name", "serversCount": "10"}}]}} ] }) self.obj.startup() widget = self.obj.get_widget() widget.update() widget.update() self.assertEqual("testname #1\n executor scenario:\n Agents in loc-name: 10\n", widget.text.get_text()[0]) def test_widget_cloud_collection(self): test = MultiTest(self.obj.user, {"id": 1, 'name': 'testname'}) self.obj.router = CloudCollectionTest(self.obj.user, test, None, None, None, self.obj.log) self.configure(post={ 'https://a.blazemeter.com/api/v4/multi-tests/1/start?delayedStart=true': {"result": { "id": 1, "sessions": [{ "id": "session-id", "locationId": "loc-name", "readyStatus": {"servers": ["server" for _ in range(10)]}}]}} }, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': {"result": {"status": "CREATED", "sessions": [{ "id": "session-id", "locationId": "loc-name", "readyStatus": {"servers": ["server" for _ in range(10)]}, "name": "loc-name/scenario", "configuration": {}}]}}, 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": { "sessions": [{ "id": "session-id", "name": "loc-name/scenario", "configuration": {}}]}} }) self.obj.startup() self.obj.router.get_master_status() widget = self.obj.get_widget() widget.update() self.assertEqual("testname #1\n scenario:\n Agents in loc-name: 10\n", widget.text.get_text()[0]) def test_delete_test_files(self): self.configure( engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ 'https://a.blazemeter.com/api/v4/web/elfinder/1?cmd=open&target=s1_Lw': {"files": [ { "hash": "hash1", "name": "file1" }, { "hash": "hash1", "name": "file2"}] }, 'https://a.blazemeter.com/api/v4/web/elfinder/1?target=s1_Lw&cmd=open': {"files": [ { "hash": "hash1", "name": "file1" }, { "hash": "hash1", "name": "file2"}] }, # deleting files with GET - ...! 'https://a.blazemeter.com/api/v4/web/elfinder/1?cmd=rm&targets[]=hash1&targets[]=hash1': { "removed": ["hash1", "hash2"] } } ) self.obj.settings.merge({'delete-test-files': True}) self.obj.prepare() self.obj.log.info("Made requests: %s", self.mock.requests) self.assertEquals('https://a.blazemeter.com/api/v4/web/elfinder/1?cmd=rm&targets[]=hash1&targets[]=hash1', self.mock.requests[10]['url']) def test_cloud_config_cleanup(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "concurrency": { "local": 1, "cloud": 10}, "locations": { "us-east-1": 1, "us-west": 2}}}, ) self.obj.router = CloudTaurusTest(self.obj.user, None, None, "name", None, self.obj.log) cloud_config = self.obj.router.prepare_cloud_config(self.obj.engine.config) execution = cloud_config["execution"][0] self.assertNotIn("throughput", execution) self.assertNotIn("ramp-up", execution) self.assertNotIn("hold-for", execution) self.assertNotIn("steps", execution) def test_default_test_type_cloud(self): self.configure(engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, ) self.obj.prepare() self.assertIsInstance(self.obj.router, CloudTaurusTest) def test_type_forced(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ 'https://a.blazemeter.com/api/v4/projects?workspaceId=1&limit=99999': {'result': [{'id': 1}]}, 'https://a.blazemeter.com/api/v4/multi-tests?workspaceId=1&name=Taurus+Cloud+Test': {"result": [{ "id": 1, "projectId": 1, "name": "Taurus Cloud Test", "configuration": {"type": "taurus"}}]} }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, }, patch={ 'https://a.blazemeter.com/api/v4/multi-tests/1': {} } ) self.obj.prepare() self.assertIsInstance(self.obj.router, CloudCollectionTest) def test_detect_test_type_collection(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ 'https://a.blazemeter.com/api/v4/projects?workspaceId=1&limit=99999': {'result': [{'id': 1}]}, 'https://a.blazemeter.com/api/v4/multi-tests?workspaceId=1&name=Taurus+Cloud+Test': {"result": [{ "id": 1, "projectId": 1, "name": "Taurus Cloud Test", "configuration": {"type": "taurus"}}]} }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, }, patch={ 'https://a.blazemeter.com/api/v4/multi-tests/1': {} } ) self.obj.prepare() self.assertIsInstance(self.obj.router, CloudCollectionTest) def test_detect_test_type_cloud(self): self.configure(engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, ) self.obj.prepare() self.assertIsInstance(self.obj.router, CloudTaurusTest) def test_full_collection(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 2}} }, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': {"result": {"status": "CREATED"}}, 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": {"sessions": []}}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {}}, }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/multi-tests/1/start?delayedStart=true': {"result": {"id": 1}} } ) self.obj.settings["use-deprecated-api"] = False self.obj.prepare() self.assertEquals(1, self.obj.executors[0].execution['locations']['us-east-1']) self.assertEquals(2, self.obj.executors[0].execution['locations']['us-west']) self.obj.startup() self.obj.check() self.obj.shutdown() self.obj.post_process() def test_create_project(self): self.configure(engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, ) self.obj.settings.merge({"delete-test-files": False, "project": "myproject"}) self.obj.prepare() self.assertEquals('https://a.blazemeter.com/api/v4/projects', self.mock.requests[5]['url']) self.assertEquals('POST', self.mock.requests[5]['method']) def test_create_project_test_exists(self): self.configure(engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ 'https://a.blazemeter.com/api/v4/tests?workspaceId=1&name=Taurus+Cloud+Test': {"result": [ {"id": 1, 'projectId': 1, 'name': 'Taurus Cloud Test', 'configuration': {'type': 'taurus'}} ]}, 'https://a.blazemeter.com/api/v4/projects?workspaceId=1&limit=99999': [ {'result': []}, {'result': [{'id': 1}]} ], 'https://a.blazemeter.com/api/v4/multi-tests?projectId=1&name=Taurus+Cloud+Test': {'result': []}, 'https://a.blazemeter.com/api/v4/tests?projectId=1&name=Taurus+Cloud+Test': {'result': []}, }) self.obj.settings.merge({"delete-test-files": False, "project": "myproject"}) self.obj.prepare() self.assertEquals('https://a.blazemeter.com/api/v4/projects', self.mock.requests[5]['url']) self.assertEquals('POST', self.mock.requests[5]['method']) self.assertEquals('https://a.blazemeter.com/api/v4/tests', self.mock.requests[7]['url']) self.assertEquals('POST', self.mock.requests[7]['method']) def test_reuse_project(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ "https://a.blazemeter.com/api/v4/projects?workspaceId=1&limit=99999": { "result": [{"id": 1, "name": "myproject"}]}, 'https://a.blazemeter.com/api/v4/multi-tests?projectId=1&name=Taurus+Cloud+Test': {"result": [{ "id": 1, "projectId": 1, "name": "Taurus Cloud Test", "configuration": {"type": "taurus"}}]} }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, }, patch={ 'https://a.blazemeter.com/api/v4/multi-tests/1': {} } ) self.obj.settings.merge({"delete-test-files": False, "project": "myproject"}) self.obj.prepare() self.assertEquals('https://a.blazemeter.com/api/v4/multi-tests?projectId=1&name=Taurus+Cloud+Test', self.mock.requests[3]['url']) def test_reuse_project_id(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, get={ "https://a.blazemeter.com/api/v4/projects?workspaceId=1&limit=99999": { "result": [{"id": 1, "name": "myproject"}]}, 'https://a.blazemeter.com/api/v4/multi-tests?projectId=1&name=Taurus+Cloud+Test': { "result": [{"id": 1, "name": "Taurus Cloud Test"}] } }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, }, patch={ 'https://a.blazemeter.com/api/v4/multi-tests/1': {} } ) self.obj.settings.merge({"delete-test-files": False, "project": 1}) self.obj.prepare() for request in self.mock.requests: self.assertFalse( request['url'] == 'https://a.blazemeter.com/api/v4/projects' and request['method'] == 'POST') def test_create_collection(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {}} } ) self.obj.settings.merge({"delete-test-files": False, "use-deprecated-api": False}) self.obj.prepare() self.assertIsInstance(self.obj.router, CloudCollectionTest) def test_toplevel_locations(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500}, "locations": { "us-east-1": 1, "us-west": 2}, "locations-weighted": True}, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {}} } ) self.obj.settings["use-deprecated-api"] = False self.obj.prepare() conf = yaml.load(open(os.path.join(self.obj.engine.artifacts_dir, "cloud.yml"))) self.assertIn('locations', conf) self.assertIn('locations-weighted', conf) self.assertEqual(conf['locations']['us-east-1'], 1) self.assertEqual(conf['locations']['us-west'], 2) self.assertNotIn('locations', conf['execution'][0]) def test_nonexistent_location(self): self.configure( engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock", }, "locations": {"us-not-found": 1}}, ) self.obj.settings["use-deprecated-api"] = False self.assertRaises(TaurusConfigError, self.obj.prepare) def test_sandbox_default_location(self): self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock"}}, ) self.obj.user.token = "key" self.obj.prepare() exec_locations = self.obj.executors[0].execution['locations'] self.assertEquals(1, exec_locations['non-harbor-sandbox']) def test_collection_defloc_sandbox(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ScenarioExecutor.EXEC: {"executor": "mock", }}, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {}} } ) self.obj.settings["use-deprecated-api"] = False self.obj.prepare() exec_locations = self.obj.executors[0].execution['locations'] expected_location = 'harbor-sandbox' self.assertIn(expected_location, exec_locations) self.assertEquals(1, exec_locations[expected_location]) def test_locations_on_both_levels(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: [{ "executor": "mock", "concurrency": 5500, "locations": {"us-east-1": 1}}], "locations": {"aws": 1}}, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {}} } ) log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.obj.settings["use-deprecated-api"] = False self.obj.prepare() cloud_config = yaml.load(open(os.path.join(self.obj.engine.artifacts_dir, "cloud.yml"))) self.assertNotIn("locations", cloud_config) for execution in cloud_config["execution"]: self.assertIn("locations", execution) log_buff = log_recorder.warn_buff.getvalue() self.assertIn("Each execution has locations specified, global locations won't have any effect", log_buff) def test_collection_simultaneous_start(self): self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 1}}}, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': [ {"result": { "id": id(self.obj), "sessions": [ {"id": "s1", "status": "JMETER_CONSOLE_INIT"}, {"id": "s2", "status": "INIT_SCRIPT"}]}}, {"result": { "id": id(self.obj), "sessions": [ {"id": "s1", "status": "JMETER_CONSOLE_INIT"}, {"id": "s2", "status": "JMETER_CONSOLE_INIT"}]}}, {"result": { "id": id(self.obj), "sessions": [ {"id": "s1", "status": "JMETER_CONSOLE_INIT"}, {"id": "s2", "status": "JMETER_CONSOLE_INIT"}]}}, {"result": { "id": id(self.obj), "status": "ENDED", "sessions": [ {"id": "s1", "status": "JMETER_CONSOLE_INIT"}, {"id": "s2", "status": "JMETER_CONSOLE_INIT"}]}}, ], 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": {"sessions": []}}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {"sessions": []}}, }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/multi-tests/1/start?delayedStart=true': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/masters/1/force-start': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/multi-tests/1/stop': {"result": {"id": 1}} } ) self.obj.settings["check-interval"] = "0ms" # do not skip checks self.obj.settings["use-deprecated-api"] = False self.obj.prepare() self.obj.startup() self.obj.check() self.obj.check() # this one should trigger force start self.obj.check() self.obj.shutdown() self.obj.post_process() self.assertIn('masters/1/force-start', ''.join([x['url'] for x in self.mock.requests])) def test_terminate_only(self): """ test is terminated only when it was started and didn't finished """ self.obj.user.token = object() self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 1}}}, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': [ {"result": { "id": id(self.obj), "sessions": [ {"id": "s1", "status": "JMETER_CONSOLE_INIT", "locationId": "some"}, {"id": "s2", "status": "JMETER_CONSOLE_INIT"}]}}, {"result": {"progress": 120, "status": "ENDED"}}, # status should trigger shutdown ], 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": {"sessions": [{'id': "s1"}]}}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": { "note": "msg", "sessions": [{'id': "s1"}]} }, 'https://a.blazemeter.com/api/v4/masters/1': {"result": {"id": 1, "note": "msg"}}, 'https://a.blazemeter.com/api/v4/sessions/s1/reports/logs': {"result": {"data": [ { 'filename': "artifacts.zip", 'dataUrl': "file://" + __dir__() + '/../data/artifacts-1.zip' } ]}} }, post={ 'https://a.blazemeter.com/api/v4/web/elfinder/taurus_%s' % id(self.obj.user.token): {}, 'https://a.blazemeter.com/api/v4/multi-tests/taurus-import': {"result": { "name": "Taurus Collection", "items": [] }}, 'https://a.blazemeter.com/api/v4/multi-tests/1': {}, 'https://a.blazemeter.com/api/v4/multi-tests': {"result": {'id': 1, 'name': 'testname'}}, 'https://a.blazemeter.com/api/v4/multi-tests/1/start?delayedStart=true': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/masters/1/force-start': {"result": {"id": 1}}, 'https://a.blazemeter.com/api/v4/multi-tests/1/stop': {"result": {"id": 1}} } ) self.obj.settings["check-interval"] = "0ms" # do not skip checks self.obj.settings["use-deprecated-api"] = False cls = ServiceStubCaptureHAR.__module__ + "." + ServiceStubCaptureHAR.__name__ self.obj.engine.config.get("modules").get('capturehar')['class'] = cls self.obj.engine.config.get(Service.SERV, []).append('capturehar') log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.obj.prepare() self.obj.startup() self.obj.check() # this one should trigger force start self.assertTrue(self.obj.check()) self.obj.shutdown() self.obj.post_process() self.assertEqual(18, len(self.mock.requests)) self.assertIn("Cloud test has probably failed with message: msg", log_recorder.warn_buff.getvalue()) def test_cloud_paths(self): """ Test different executor/path combinations for correct return values of get_resources_files """ self.configure( add_config=False, add_settings=False, ) # upload files # FIXME: refactor this method! log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.obj.engine.configure([ __dir__() + '/../../bzt/10-base.json', __dir__() + '/../yaml/resource_files.yml'], read_config_files=False) self.obj.settings = self.obj.engine.config['modules']['cloud'] self.obj.settings.merge({'delete-test-files': False}) # list of existing files in $HOME pref = 'file-in-home-' files_in_home = ['00.jmx', '01.csv', '02.res', '03.java', '04.scala', '05.jar', '06.py', '07.properties', '08.py', '09.siege', '10.xml', '11.ds', '12.xml', '13.src'] files_in_home = [pref + _file for _file in files_in_home] back_home = os.environ.get('HOME', '') temp_home = tempfile.mkdtemp() try: os.environ['HOME'] = temp_home files_in_home = [{'shortname': os.path.join('~', _file), 'fullname': get_full_path(os.path.join('~', _file))} for _file in files_in_home] shutil.copyfile(__dir__() + '/../jmeter/jmx/dummy.jmx', files_in_home[0]['fullname']) dir_path = get_full_path(os.path.join('~', 'example-of-directory')) os.mkdir(dir_path) for _file in files_in_home[1:]: open(_file['fullname'], 'a').close() self.obj.engine.file_search_paths = ['tests'] # config not in cwd # 'files' are treated similar in all executors so check only one self.obj.engine.config[ScenarioExecutor.EXEC][0]['files'] = [ os.path.join(os.getcwd(), 'tests', 'test_CLI.py'), # full path files_in_home[2]['shortname'], # path from ~ os.path.join('jmeter', 'jmeter-loader.bat'), # relative path 'mocks.py', # only basename (look at file_search_paths) '~/example-of-directory'] # dir self.obj.prepare() debug = log_recorder.debug_buff.getvalue().split('\n') str_files = [line for line in debug if 'Replace file names in config' in line] self.assertEqual(1, len(str_files)) res_files = [_file for _file in str_files[0].split('\'')[1::2]] half = int(len(res_files) / 2) old_names = res_files[:half] new_names = res_files[half:] names = list(zip(old_names, new_names)) with open(self.obj.engine.artifacts_dir + '/cloud.yml') as cl_file: str_cfg = cl_file.read() archive_found = False for old_name, new_name in names: if new_name.endswith('.zip'): archive_found = True # all resources on the disk, dir has been packed path_to_file = get_full_path(self.obj.engine.find_file(old_name)) msg = 'File %s (%s) not found on disk' % (old_name, path_to_file) self.assertTrue(os.path.exists(path_to_file), msg) msg = 'Short name %s not found in modified config' % new_name self.assertIn(new_name, str_cfg, msg) # all short names in config if new_name != old_name: msg = 'Long name %s found in config' % old_name self.assertNotIn(old_name, str_cfg, msg) # no one long name in config self.assertTrue(archive_found) self.assertEqual(set(new_names), { # source: 'dummy.jmx', # execution 0 (script) 'test_CLI.py', 'file-in-home-02.res', # 0 (files) 'jmeter-loader.bat', 'mocks.py', # 0 (files) 'example-of-directory.zip', # 0 (files) 'files_paths.jmx', # 1 (script) 'file-in-home-01.csv', 'body-file.dat', # 1 (from jmx) 'BlazeDemo.java', # 2 (script) 'file-in-home-05.jar', 'dummy.jar', # 2 (additional-classpath) 'testng.xml', # 2 (testng-xml) 'file-in-home-03.java', # 3 (script) 'file-in-home-12.xml', # 3 (testng-xml) 'BasicSimulation.scala', # 4 (script) 'file-in-home-04.scala', # 5 (script) 'helloworld.py', # 6 (script) 'grinder.base.properties', # 6 (properties-file) 'file-in-home-06.py', # 7 (script) 'file-in-home-07.properties', # 7 (properties-file) 'simple.py', # 8 (script) 'file-in-home-08.py', # 9 (script) 'jmeter-loader.bat', # 10 (data-sources) 'file-in-home-11.ds', # 10 (data-sources) 'url-file', # 11 (script) 'file-in-home-09.siege', # 12 (script) 'http_simple.xml', # 13 (script) 'file-in-home-10.xml', # 14 (script) 'pbench.src', # 15 (script) 'file-in-home-13.src', # 16 (script) 'file-in-home-00.jmx' # 17 (script) }) finally: os.environ['HOME'] = back_home shutil.rmtree(temp_home) def test_check_interval(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: {"executor": "mock", }}, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': [ {"result": {"id": id(self.obj)}}, {"result": {"id": id(self.obj), 'progress': 100}}, ], 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": []}, 'https://a.blazemeter.com/api/v4/data/labels?master_id=1': {"result": [ {"id": "ALL", "name": "ALL"}, {"id": "e843ff89a5737891a10251cbb0db08e5", "name": "http://blazedemo.com/"} ]}, 'https://a.blazemeter.com/api/v4/data/kpis?interval=1&from=0&master_ids%5B%5D=1&kpis%5B%5D=t&kpis%5B%5D=lt&kpis%5B%5D=by&kpis%5B%5D=n&kpis%5B%5D=ec&kpis%5B%5D=ts&kpis%5B%5D=na&labels%5B%5D=ALL&labels%5B%5D=e843ff89a5737891a10251cbb0db08e5': { "api_version": 2, "error": None, "result": [ { "labelId": "ALL", "labelName": "ALL", "label": "ALL", "kpis": [ { "n": 15, "na": 2, "ec": 0, "ts": 1442497724, "t_avg": 558, "lt_avg": 25.7, "by_avg": 0, "n_avg": 15, "ec_avg": 0 }, { "n": 7, "na": 4, "ec": 0, "ts": 1442497725, "t_avg": 88.1, "lt_avg": 11.9, "by_avg": 0, "n_avg": 7, "ec_avg": 0 }] }, { "labelId": "e843ff89a5737891a10251cbb0db08e5", "labelName": "http://blazedemo.com/", "label": "http://blazedemo.com/", "kpis": [ { "n": 15, "na": 2, "ec": 0, "ts": 1442497724, "t_avg": 558, "lt_avg": 25.7, "by_avg": 0, "n_avg": 15, "ec_avg": 0 }, { "n": 7, "na": 4, "ec": 0, "ts": 1442497725, "t_avg": 88.1, "lt_avg": 11.9, "by_avg": 0, "n_avg": 7, "ec_avg": 0 }]}]}, 'https://a.blazemeter.com/api/v4/masters/1/reports/aggregatereport/data': { "api_version": 2, "error": None, "result": [ { "labelId": "ALL", "labelName": "ALL", "samples": 152, "avgResponseTime": 786, "90line": 836, "95line": 912, "99line": 1050, "minResponseTime": 531, "maxResponseTime": 1148, "avgLatency": 81, "geoMeanResponseTime": None, "stDev": 108, "duration": 119, "avgBytes": 0, "avgThroughput": 1.2773109243697, "medianResponseTime": 0, "errorsCount": 0, "errorsRate": 0, "hasLabelPassedThresholds": None }, { "labelId": "e843ff89a5737891a10251cbb0db08e5", "labelName": "http://blazedemo.com/", "samples": 152, "avgResponseTime": 786, "90line": 836, "95line": 912, "99line": 1050, "minResponseTime": 531, "maxResponseTime": 1148, "avgLatency": 81, "geoMeanResponseTime": None, "stDev": 108, "duration": 119, "avgBytes": 0, "avgThroughput": 1.2773109243697, "medianResponseTime": 0, "errorsCount": 0, "errorsRate": 0, "hasLabelPassedThresholds": None }]} } ) self.obj.settings["check-interval"] = "1s" self.obj.prepare() self.obj.startup() self.obj.check() # this one should work self.obj.engine.aggregator.check() self.obj.check() # this one should be skipped self.obj.engine.aggregator.check() time.sleep(1.5) self.obj.check() # this one should work self.obj.engine.aggregator.check() self.obj.check() # this one should skip self.obj.results_reader.min_ts = 0 # to make it request same URL self.obj.engine.aggregator.check() self.assertEqual(22, len(self.mock.requests)) def test_dump_locations(self): self.configure() log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.obj.settings["dump-locations"] = True self.obj.settings["use-deprecated-api"] = True self.assertRaises(ManualShutdown, self.obj.prepare) warnings = log_recorder.warn_buff.getvalue() self.assertIn("Dumping available locations instead of running the test", warnings) info = log_recorder.info_buff.getvalue() self.assertIn("Location: us-west\tDallas (Rackspace)", info) self.assertIn("Location: us-east-1\tEast", info) self.assertNotIn("Location: harbor-sandbox\tSandbox", info) self.obj.post_process() def test_dump_locations_new_style(self): log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.configure() self.obj.settings["dump-locations"] = True self.obj.settings["use-deprecated-api"] = False self.assertRaises(ManualShutdown, self.obj.prepare) warnings = log_recorder.warn_buff.getvalue() self.assertIn("Dumping available locations instead of running the test", warnings) info = log_recorder.info_buff.getvalue() self.assertIn("Location: us-west\tDallas (Rackspace)", info) self.assertIn("Location: us-east-1\tEast", info) self.assertIn("Location: harbor-sandbox\tSandbox", info) self.obj.post_process() def test_settings_from_blazemeter_mod(self): self.configure( add_settings=False, engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 5500, "locations": { "us-east-1": 1, "us-west": 1}}, "modules": { "blazemeter": { "class": ModuleMock.__module__ + "." + ModuleMock.__name__, "token": "bmtoken", "detach": True, "browser-open": None, "check-interval": 10.0}}}, ) # upload files # these should override 'blazemeter' settings self.obj.settings["check-interval"] = 20.0 self.obj.settings["browser-open"] = "both" self.obj.prepare() self.assertEqual(self.obj.detach, True) self.assertEqual(self.obj.browser_open, "both") self.assertEqual(self.obj.user.token, "bmtoken") self.assertEqual(self.obj.check_interval, 20.0) self.assertEqual(11, len(self.mock.requests)) def test_public_report(self): self.configure( engine_cfg={ ScenarioExecutor.EXEC: { "executor": "mock", "concurrency": 1, "locations": { "us-west": 2 }}}, post={ 'https://a.blazemeter.com/api/v4/masters/1/public-token': {"result": {"publicToken": "publicToken"}} }, get={ 'https://a.blazemeter.com/api/v4/masters/1/status': {"result": {"status": "CREATED"}}, 'https://a.blazemeter.com/api/v4/masters/1/sessions': {"result": {"sessions": []}}, 'https://a.blazemeter.com/api/v4/masters/1/full': {"result": {}}, } ) log_recorder = RecordingHandler() self.obj.log.addHandler(log_recorder) self.obj.settings['public-report'] = True self.obj.prepare() self.obj.startup() self.obj.check() self.obj.shutdown() self.obj.post_process() log_buff = log_recorder.info_buff.getvalue() log_line = "Public report link: https://a.blazemeter.com/app/?public-token=publicToken#/masters/1/summary" self.assertIn(log_line, log_buff) class TestCloudTaurusTest(BZTestCase): def test_defaults_clean(self): conf = {"execution": [{"concurrency": {"local": None}}]} res = CloudTaurusTest.cleanup_defaults(conf) self.assertEqual({"execution": [{}]}, res) class TestResultsFromBZA(BZTestCase): def test_simple(self): mock = BZMock() mock.mock_get.update({ 'https://a.blazemeter.com/api/v4/data/labels?master_id=1': {"result": [ {"id": "ALL", "name": "ALL"}, {"id": "e843ff89a5737891a10251cbb0db08e5", "name": "http://blazedemo.com/"} ]}, 'https://a.blazemeter.com/api/v4/data/kpis?interval=1&from=0&master_ids%5B%5D=1&kpis%5B%5D=t&kpis%5B%5D=lt&kpis%5B%5D=by&kpis%5B%5D=n&kpis%5B%5D=ec&kpis%5B%5D=ts&kpis%5B%5D=na&labels%5B%5D=ALL&labels%5B%5D=e843ff89a5737891a10251cbb0db08e5': { "api_version": 2, "error": None, "result": [ { "labelId": "ALL", "labelName": "ALL", "label": "ALL", "kpis": [ { "n": 15, "na": 2, "ec": 0, "ts": 1442497724, "t_avg": 558, "lt_avg": 25.7, "by_avg": 0, "n_avg": 15, "ec_avg": 0 }, { "n": 7, "na": 4, "ec": 0, "ts": 1442497725, "t_avg": 88.1, "lt_avg": 11.9, "by_avg": 0, "n_avg": 7, "ec_avg": 0 }] }, { "labelId": "e843ff89a5737891a10251cbb0db08e5", "labelName": "http://blazedemo.com/", "label": "http://blazedemo.com/", "kpis": [ { "n": 15, "na": 2, "ec": 0, "ts": 1442497724, "t_avg": 558, "lt_avg": 25.7, "by_avg": 0, "n_avg": 15, "ec_avg": 0 }, { "n": 7, "na": 4, "ec": 0, "ts": 1442497725, "t_avg": 88.1, "lt_avg": 11.9, "by_avg": 0, "n_avg": 7, "ec_avg": 0 }]}]}, 'https://a.blazemeter.com/api/v4/masters/1/reports/aggregatereport/data': { "api_version": 2, "error": None, "result": [ { "labelId": "ALL", "labelName": "ALL", "samples": 152, "avgResponseTime": 786, "90line": 836, "95line": 912, "99line": 1050, "minResponseTime": 531, "maxResponseTime": 1148, "avgLatency": 81, "geoMeanResponseTime": None, "stDev": 108, "duration": 119, "avgBytes": 0, "avgThroughput": 1.2773109243697, "medianResponseTime": 0, "errorsCount": 0, "errorsRate": 0, "hasLabelPassedThresholds": None }, { "labelId": "e843ff89a5737891a10251cbb0db08e5", "labelName": "http://blazedemo.com/", "samples": 152, "avgResponseTime": 786, "90line": 836, "95line": 912, "99line": 1050, "minResponseTime": 531, "maxResponseTime": 1148, "avgLatency": 81, "geoMeanResponseTime": None, "stDev": 108, "duration": 119, "avgBytes": 0, "avgThroughput": 1.2773109243697, "medianResponseTime": 0, "errorsCount": 0, "errorsRate": 0, "hasLabelPassedThresholds": None }]} }) obj = ResultsFromBZA() obj.master = Master(data={'id': 1}) mock.apply(obj.master) results = [x for x in obj.datapoints(True)] self.assertEquals(2, len(results)) cumulative = results[-1][DataPoint.CUMULATIVE][''] self.assertTrue(0 <= cumulative[KPISet.AVG_LATENCY] < 1) self.assertEqual(cumulative[KPISet.CONCURRENCY], 4) self.assertEqual(cumulative[KPISet.PERCENTILES]['90.0'], .836) self.assertEqual(cumulative[KPISet.PERCENTILES]['95.0'], .912) self.assertEqual(cumulative[KPISet.PERCENTILES]['99.0'], 1.050)
apache-2.0
[ 646, 2022, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 900, 199, 199, 646, 8864, 199, 199, 504, 15055, 84, 492, 32316, 300, 527, 2028, 547, 12, 32316, 300, 527, 1726, 199, 504, 15055, 84, 14, 66, 8076, 492, 26728, 12, 1379, 12, 6879, 774, 199, 504, 15055, 84, 14, 3908, 492, 22840, 16752, 12, 30247, 20043, 12, 7591, 199, 504, 15055, 84, 14, 3112, 14, 27562, 492, 1448, 18533, 1958, 23933, 12, 3918, 3428, 12, 1804, 2252, 1084, 199, 504, 15055, 84, 14, 3112, 14, 21244, 806, 10011, 492, 8142, 27653, 316, 12, 24288, 2532, 21338, 33, 12, 7591, 8067, 16640, 30958, 199, 504, 15055, 84, 14, 3112, 14, 21244, 806, 10011, 492, 8142, 22620, 300, 527, 774, 12, 8142, 7768, 774, 199, 504, 15055, 84, 14, 1208, 492, 664, 63, 2861, 63, 515, 199, 504, 2295, 492, 32402, 1746, 12, 636, 694, 363, 199, 504, 2295, 14, 25191, 492, 12580, 37, 3703, 12, 5673, 3346, 12, 799, 5422, 2461, 199, 504, 2295, 14, 3112, 14, 396, 63, 21244, 806, 10011, 492, 32402, 3346, 421, 199, 533, 1379, 9089, 27653, 316, 8, 21338, 1746, 304, 272, 768, 4639, 272, 347, 636, 362, 63, 751, 63, 815, 837, 267, 543, 1551, 3460, 694, 4533, 435, 3286, 5093, 1001, 15, 21244, 806, 10011, 13, 1246, 13, 751, 14, 1001, 531, 465, 289, 7952, 26, 288, 372, 2022, 14, 3640, 8, 70, 7952, 14, 739, 1012, 339, 347, 3613, 8, 277, 304, 267, 6869, 275, 12580, 37, 3703, 342, 267, 6869, 14, 27562, 275, 1448, 18533, 1958, 23933, 342, 267, 291, 14, 1113, 275, 8142, 27653, 316, 342, 267, 291, 14, 1113, 14, 1751, 14, 5628, 3252, 1807, 13, 396, 13, 1725, 356, 756, 1552, 267, 291, 14, 1113, 14, 3908, 275, 6869, 267, 291, 14, 1113, 14, 5750, 63, 1490, 275, 756, 267, 291, 14, 1805, 275, 32402, 3346, 8, 277, 14, 1113, 14, 751, 9, 267, 291, 14, 1805, 14, 1805, 63, 1932, 14, 873, 2561, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 6776, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 15, 1725, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 15, 928, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 2379, 356, 2420, 1099, 582, 715, 1386, 267, 3828, 339, 347, 7908, 8, 277, 12, 6869, 63, 4128, 29, 403, 12, 664, 29, 403, 12, 2963, 29, 403, 12, 3371, 29, 403, 12, 1050, 63, 888, 29, 549, 12, 1050, 63, 1751, 29, 549, 304, 267, 340, 6869, 63, 4128, 365, 488, 26, 288, 6869, 63, 4128, 275, 1052, 267, 291, 14, 1113, 14, 3908, 14, 888, 14, 5628, 8, 3908, 63, 4128, 9, 398, 340, 1050, 63, 1751, 26, 288, 291, 14, 1113, 14, 1751, 905, 1418, 937, 275, 298, 8249, 3264, 2, 288, 291, 14, 1113, 14, 1751, 905, 5750, 13, 1490, 937, 275, 756, 288, 291, 14, 1113, 14, 1751, 459, 885, 13, 1985, 418, 275, 298, 527, 13, 14346, 13, 17, 2, 398, 340, 1050, 63, 888, 26, 288, 291, 14, 1113, 14, 3908, 14, 888, 14, 5628, 2561, 355, 298, 3112, 582, 2420, 1805, 582, 5673, 3346, 855, 578, 363, 435, 14530, 435, 5673, 3346, 855, 354, 363, 1386, 355, 298, 19639, 582, 298, 1805, 5984, 953, 291, 14, 1113, 14, 3214, 275, 291, 14, 1113, 14, 3908, 14, 888, 14, 362, 360, 9416, 358, 398, 340, 1228, 8, 277, 14, 1113, 14, 3214, 12, 769, 304, 288, 291, 14, 1113, 14, 3214, 275, 291, 14, 1113, 14, 3214, 59, 16, 61, 398, 291, 14, 1805, 14, 1805, 63, 362, 14, 873, 8, 362, 340, 664, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 1932, 14, 873, 8, 1932, 340, 2963, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 2068, 14, 873, 8, 2068, 340, 3371, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 2068, 14, 873, 3252, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 356, 2420, 1099, 582, 1052, 19575, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 291, 14, 6472, 8, 288, 6869, 63, 4128, 3126, 355, 22840, 16752, 14, 10276, 26, 469, 490, 298, 13471, 582, 298, 1805, 401, 490, 298, 27518, 582, 959, 5783, 12, 490, 298, 8022, 582, 469, 717, 298, 527, 13, 14346, 13, 17, 582, 413, 12, 717, 298, 527, 13, 19082, 582, 499, 4863, 1386, 953, 664, 3126, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 1205, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 11676, 356, 2420, 1099, 582, 28657, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 2861, 356, 2420, 1099, 582, 20715, 288, 1660, 288, 2963, 3126, 288, 789, 267, 776, 221, 327, 15095, 398, 291, 14, 1113, 14, 6726, 342, 267, 291, 14, 2947, 8, 17, 12, 291, 14, 1113, 14, 1628, 6622, 59, 16, 1055, 9416, 459, 8022, 2545, 527, 13, 14346, 13, 17, 1105, 267, 291, 14, 2947, 8, 18, 12, 291, 14, 1113, 14, 1628, 6622, 59, 16, 1055, 9416, 459, 8022, 2545, 527, 13, 19082, 1105, 398, 291, 14, 1113, 14, 16480, 342, 267, 291, 14, 1113, 14, 1074, 342, 267, 291, 14, 1113, 14, 8831, 342, 267, 291, 14, 1113, 14, 1932, 63, 1412, 342, 339, 347, 511, 63 ]
[ 2022, 199, 646, 747, 199, 646, 5145, 199, 646, 5549, 199, 646, 900, 199, 199, 646, 8864, 199, 199, 504, 15055, 84, 492, 32316, 300, 527, 2028, 547, 12, 32316, 300, 527, 1726, 199, 504, 15055, 84, 14, 66, 8076, 492, 26728, 12, 1379, 12, 6879, 774, 199, 504, 15055, 84, 14, 3908, 492, 22840, 16752, 12, 30247, 20043, 12, 7591, 199, 504, 15055, 84, 14, 3112, 14, 27562, 492, 1448, 18533, 1958, 23933, 12, 3918, 3428, 12, 1804, 2252, 1084, 199, 504, 15055, 84, 14, 3112, 14, 21244, 806, 10011, 492, 8142, 27653, 316, 12, 24288, 2532, 21338, 33, 12, 7591, 8067, 16640, 30958, 199, 504, 15055, 84, 14, 3112, 14, 21244, 806, 10011, 492, 8142, 22620, 300, 527, 774, 12, 8142, 7768, 774, 199, 504, 15055, 84, 14, 1208, 492, 664, 63, 2861, 63, 515, 199, 504, 2295, 492, 32402, 1746, 12, 636, 694, 363, 199, 504, 2295, 14, 25191, 492, 12580, 37, 3703, 12, 5673, 3346, 12, 799, 5422, 2461, 199, 504, 2295, 14, 3112, 14, 396, 63, 21244, 806, 10011, 492, 32402, 3346, 421, 199, 533, 1379, 9089, 27653, 316, 8, 21338, 1746, 304, 272, 768, 4639, 272, 347, 636, 362, 63, 751, 63, 815, 837, 267, 543, 1551, 3460, 694, 4533, 435, 3286, 5093, 1001, 15, 21244, 806, 10011, 13, 1246, 13, 751, 14, 1001, 531, 465, 289, 7952, 26, 288, 372, 2022, 14, 3640, 8, 70, 7952, 14, 739, 1012, 339, 347, 3613, 8, 277, 304, 267, 6869, 275, 12580, 37, 3703, 342, 267, 6869, 14, 27562, 275, 1448, 18533, 1958, 23933, 342, 267, 291, 14, 1113, 275, 8142, 27653, 316, 342, 267, 291, 14, 1113, 14, 1751, 14, 5628, 3252, 1807, 13, 396, 13, 1725, 356, 756, 1552, 267, 291, 14, 1113, 14, 3908, 275, 6869, 267, 291, 14, 1113, 14, 5750, 63, 1490, 275, 756, 267, 291, 14, 1805, 275, 32402, 3346, 8, 277, 14, 1113, 14, 751, 9, 267, 291, 14, 1805, 14, 1805, 63, 1932, 14, 873, 2561, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 6776, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 15, 1725, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 15, 928, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 288, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 2379, 356, 2420, 1099, 582, 715, 1386, 267, 3828, 339, 347, 7908, 8, 277, 12, 6869, 63, 4128, 29, 403, 12, 664, 29, 403, 12, 2963, 29, 403, 12, 3371, 29, 403, 12, 1050, 63, 888, 29, 549, 12, 1050, 63, 1751, 29, 549, 304, 267, 340, 6869, 63, 4128, 365, 488, 26, 288, 6869, 63, 4128, 275, 1052, 267, 291, 14, 1113, 14, 3908, 14, 888, 14, 5628, 8, 3908, 63, 4128, 9, 398, 340, 1050, 63, 1751, 26, 288, 291, 14, 1113, 14, 1751, 905, 1418, 937, 275, 298, 8249, 3264, 2, 288, 291, 14, 1113, 14, 1751, 905, 5750, 13, 1490, 937, 275, 756, 288, 291, 14, 1113, 14, 1751, 459, 885, 13, 1985, 418, 275, 298, 527, 13, 14346, 13, 17, 2, 398, 340, 1050, 63, 888, 26, 288, 291, 14, 1113, 14, 3908, 14, 888, 14, 5628, 2561, 355, 298, 3112, 582, 2420, 1805, 582, 5673, 3346, 855, 578, 363, 435, 14530, 435, 5673, 3346, 855, 354, 363, 1386, 355, 298, 19639, 582, 298, 1805, 5984, 953, 291, 14, 1113, 14, 3214, 275, 291, 14, 1113, 14, 3908, 14, 888, 14, 362, 360, 9416, 358, 398, 340, 1228, 8, 277, 14, 1113, 14, 3214, 12, 769, 304, 288, 291, 14, 1113, 14, 3214, 275, 291, 14, 1113, 14, 3214, 59, 16, 61, 398, 291, 14, 1805, 14, 1805, 63, 362, 14, 873, 8, 362, 340, 664, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 1932, 14, 873, 8, 1932, 340, 2963, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 2068, 14, 873, 8, 2068, 340, 3371, 587, 5009, 267, 291, 14, 1805, 14, 1805, 63, 2068, 14, 873, 3252, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 2219, 15, 17, 356, 2420, 1099, 582, 1052, 19575, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 291, 14, 6472, 8, 288, 6869, 63, 4128, 3126, 355, 22840, 16752, 14, 10276, 26, 469, 490, 298, 13471, 582, 298, 1805, 401, 490, 298, 27518, 582, 959, 5783, 12, 490, 298, 8022, 582, 469, 717, 298, 527, 13, 14346, 13, 17, 582, 413, 12, 717, 298, 527, 13, 19082, 582, 499, 4863, 1386, 953, 664, 3126, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 1205, 356, 2420, 1099, 582, 2420, 344, 582, 413, 13459, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 11676, 356, 2420, 1099, 582, 28657, 355, 283, 2859, 921, 65, 14, 21244, 806, 10011, 14, 957, 15, 1246, 15, 86, 20, 15, 5892, 878, 15, 17, 15, 2861, 356, 2420, 1099, 582, 20715, 288, 1660, 288, 2963, 3126, 288, 789, 267, 776, 221, 327, 15095, 398, 291, 14, 1113, 14, 6726, 342, 267, 291, 14, 2947, 8, 17, 12, 291, 14, 1113, 14, 1628, 6622, 59, 16, 1055, 9416, 459, 8022, 2545, 527, 13, 14346, 13, 17, 1105, 267, 291, 14, 2947, 8, 18, 12, 291, 14, 1113, 14, 1628, 6622, 59, 16, 1055, 9416, 459, 8022, 2545, 527, 13, 19082, 1105, 398, 291, 14, 1113, 14, 16480, 342, 267, 291, 14, 1113, 14, 1074, 342, 267, 291, 14, 1113, 14, 8831, 342, 267, 291, 14, 1113, 14, 1932, 63, 1412, 342, 339, 347, 511, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
waytai/odoo
openerp/addons/base/tests/test_ir_actions.py
291
20121
import unittest2 from openerp.osv.orm import except_orm import openerp.tests.common as common from openerp.tools import mute_logger class TestServerActionsBase(common.TransactionCase): def setUp(self): super(TestServerActionsBase, self).setUp() cr, uid = self.cr, self.uid # Models self.ir_actions_server = self.registry('ir.actions.server') self.ir_actions_client = self.registry('ir.actions.client') self.ir_values = self.registry('ir.values') self.ir_model = self.registry('ir.model') self.ir_model_fields = self.registry('ir.model.fields') self.res_partner = self.registry('res.partner') self.res_country = self.registry('res.country') # Data on which we will run the server action self.test_country_id = self.res_country.create(cr, uid, { 'name': 'TestingCountry', 'code': 'TY', 'address_format': 'SuperFormat', }) self.test_country = self.res_country.browse(cr, uid, self.test_country_id) self.test_partner_id = self.res_partner.create(cr, uid, { 'name': 'TestingPartner', 'city': 'OrigCity', 'country_id': self.test_country_id, }) self.test_partner = self.res_partner.browse(cr, uid, self.test_partner_id) self.context = { 'active_id': self.test_partner_id, 'active_model': 'res.partner', } # Model data self.res_partner_model_id = self.ir_model.search(cr, uid, [('model', '=', 'res.partner')])[0] self.res_partner_name_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.partner'), ('name', '=', 'name')])[0] self.res_partner_city_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.partner'), ('name', '=', 'city')])[0] self.res_partner_country_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.partner'), ('name', '=', 'country_id')])[0] self.res_partner_parent_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.partner'), ('name', '=', 'parent_id')])[0] self.res_country_model_id = self.ir_model.search(cr, uid, [('model', '=', 'res.country')])[0] self.res_country_name_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.country'), ('name', '=', 'name')])[0] self.res_country_code_field_id = self.ir_model_fields.search(cr, uid, [('model', '=', 'res.country'), ('name', '=', 'code')])[0] # create server action to self.act_id = self.ir_actions_server.create(cr, uid, { 'name': 'TestAction', 'condition': 'True', 'model_id': self.res_partner_model_id, 'state': 'code', 'code': 'obj.write({"comment": "MyComment"})', }) class TestServerActions(TestServerActionsBase): def test_00_action(self): cr, uid = self.cr, self.uid # Do: eval 'True' condition self.ir_actions_server.run(cr, uid, [self.act_id], self.context) self.test_partner.refresh() self.assertEqual(self.test_partner.comment, 'MyComment', 'ir_actions_server: invalid condition check') self.test_partner.write({'comment': False}) # Do: eval False condition, that should be considered as True (void = True) self.ir_actions_server.write(cr, uid, [self.act_id], {'condition': False}) self.ir_actions_server.run(cr, uid, [self.act_id], self.context) self.test_partner.refresh() self.assertEqual(self.test_partner.comment, 'MyComment', 'ir_actions_server: invalid condition check') # Do: create contextual action self.ir_actions_server.create_action(cr, uid, [self.act_id]) # Test: ir_values created ir_values_ids = self.ir_values.search(cr, uid, [('name', '=', 'Run TestAction')]) self.assertEqual(len(ir_values_ids), 1, 'ir_actions_server: create_action should have created an entry in ir_values') ir_value = self.ir_values.browse(cr, uid, ir_values_ids[0]) self.assertEqual(ir_value.value, 'ir.actions.server,%s' % self.act_id, 'ir_actions_server: created ir_values should reference the server action') self.assertEqual(ir_value.model, 'res.partner', 'ir_actions_server: created ir_values should be linked to the action base model') # Do: remove contextual action self.ir_actions_server.unlink_action(cr, uid, [self.act_id]) # Test: ir_values removed ir_values_ids = self.ir_values.search(cr, uid, [('name', '=', 'Run TestAction')]) self.assertEqual(len(ir_values_ids), 0, 'ir_actions_server: unlink_action should remove the ir_values record') def test_10_code(self): cr, uid = self.cr, self.uid self.ir_actions_server.write(cr, uid, self.act_id, { 'state': 'code', 'code': """partner_name = obj.name + '_code' self.pool["res.partner"].create(cr, uid, {"name": partner_name}, context=context) workflow""" }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: code server action correctly finished should return False') pids = self.res_partner.search(cr, uid, [('name', 'ilike', 'TestingPartner_code')]) self.assertEqual(len(pids), 1, 'ir_actions_server: 1 new partner should have been created') def test_20_trigger(self): cr, uid = self.cr, self.uid # Data: code server action (at this point code-based actions should work) act_id2 = self.ir_actions_server.create(cr, uid, { 'name': 'TestAction2', 'type': 'ir.actions.server', 'condition': 'True', 'model_id': self.res_partner_model_id, 'state': 'code', 'code': 'obj.write({"comment": "MyComment"})', }) act_id3 = self.ir_actions_server.create(cr, uid, { 'name': 'TestAction3', 'type': 'ir.actions.server', 'condition': 'True', 'model_id': self.res_country_model_id, 'state': 'code', 'code': 'obj.write({"code": "ZZ"})', }) # Data: create workflows partner_wf_id = self.registry('workflow').create(cr, uid, { 'name': 'TestWorkflow', 'osv': 'res.partner', 'on_create': True, }) partner_act1_id = self.registry('workflow.activity').create(cr, uid, { 'name': 'PartnerStart', 'wkf_id': partner_wf_id, 'flow_start': True }) partner_act2_id = self.registry('workflow.activity').create(cr, uid, { 'name': 'PartnerTwo', 'wkf_id': partner_wf_id, 'kind': 'function', 'action': 'True', 'action_id': act_id2, }) partner_trs1_id = self.registry('workflow.transition').create(cr, uid, { 'signal': 'partner_trans', 'act_from': partner_act1_id, 'act_to': partner_act2_id }) country_wf_id = self.registry('workflow').create(cr, uid, { 'name': 'TestWorkflow', 'osv': 'res.country', 'on_create': True, }) country_act1_id = self.registry('workflow.activity').create(cr, uid, { 'name': 'CountryStart', 'wkf_id': country_wf_id, 'flow_start': True }) country_act2_id = self.registry('workflow.activity').create(cr, uid, { 'name': 'CountryTwo', 'wkf_id': country_wf_id, 'kind': 'function', 'action': 'True', 'action_id': act_id3, }) country_trs1_id = self.registry('workflow.transition').create(cr, uid, { 'signal': 'country_trans', 'act_from': country_act1_id, 'act_to': country_act2_id }) # Data: re-create country and partner to benefit from the workflows self.test_country_id = self.res_country.create(cr, uid, { 'name': 'TestingCountry2', 'code': 'T2', }) self.test_country = self.res_country.browse(cr, uid, self.test_country_id) self.test_partner_id = self.res_partner.create(cr, uid, { 'name': 'TestingPartner2', 'country_id': self.test_country_id, }) self.test_partner = self.res_partner.browse(cr, uid, self.test_partner_id) self.context = { 'active_id': self.test_partner_id, 'active_model': 'res.partner', } # Run the action on partner object itself ('base') self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'trigger', 'use_relational_model': 'base', 'wkf_model_id': self.res_partner_model_id, 'wkf_model_name': 'res.partner', 'wkf_transition_id': partner_trs1_id, }) self.ir_actions_server.run(cr, uid, [self.act_id], self.context) self.test_partner.refresh() self.assertEqual(self.test_partner.comment, 'MyComment', 'ir_actions_server: incorrect signal trigger') # Run the action on related country object ('relational') self.ir_actions_server.write(cr, uid, [self.act_id], { 'use_relational_model': 'relational', 'wkf_model_id': self.res_country_model_id, 'wkf_model_name': 'res.country', 'wkf_field_id': self.res_partner_country_field_id, 'wkf_transition_id': country_trs1_id, }) self.ir_actions_server.run(cr, uid, [self.act_id], self.context) self.test_country.refresh() self.assertEqual(self.test_country.code, 'ZZ', 'ir_actions_server: incorrect signal trigger') # Clear workflow cache, otherwise openerp will try to create workflows even if it has been deleted from openerp.workflow import clear_cache clear_cache(cr, uid) def test_30_client(self): cr, uid = self.cr, self.uid client_action_id = self.registry('ir.actions.client').create(cr, uid, { 'name': 'TestAction2', 'tag': 'Test', }) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'client_action', 'action_id': client_action_id, }) res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertEqual(res['name'], 'TestAction2', 'ir_actions_server: incorrect return result for a client action') def test_40_crud_create(self): cr, uid = self.cr, self.uid _city = 'TestCity' _name = 'TestNew' # Do: create a new record in the same model and link it self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'object_create', 'use_create': 'new', 'link_new_record': True, 'link_field_id': self.res_partner_parent_field_id, 'fields_lines': [(0, 0, {'col1': self.res_partner_name_field_id, 'value': _name}), (0, 0, {'col1': self.res_partner_city_field_id, 'value': _city})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new partner created pids = self.res_partner.search(cr, uid, [('name', 'ilike', _name)]) self.assertEqual(len(pids), 1, 'ir_actions_server: TODO') partner = self.res_partner.browse(cr, uid, pids[0]) self.assertEqual(partner.city, _city, 'ir_actions_server: TODO') # Test: new partner linked self.test_partner.refresh() self.assertEqual(self.test_partner.parent_id.id, pids[0], 'ir_actions_server: TODO') # Do: copy current record self.ir_actions_server.write(cr, uid, [self.act_id], {'fields_lines': [[5]]}) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'object_create', 'use_create': 'copy_current', 'link_new_record': False, 'fields_lines': [(0, 0, {'col1': self.res_partner_name_field_id, 'value': 'TestCopyCurrent'}), (0, 0, {'col1': self.res_partner_city_field_id, 'value': 'TestCity'})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new partner created pids = self.res_partner.search(cr, uid, [('name', 'ilike', 'TestingPartner (copy)')]) # currently res_partner overrides default['name'] whatever its value self.assertEqual(len(pids), 1, 'ir_actions_server: TODO') partner = self.res_partner.browse(cr, uid, pids[0]) self.assertEqual(partner.city, 'TestCity', 'ir_actions_server: TODO') self.assertEqual(partner.country_id.id, self.test_partner.country_id.id, 'ir_actions_server: TODO') # Do: create a new record in another model self.ir_actions_server.write(cr, uid, [self.act_id], {'fields_lines': [[5]]}) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'object_create', 'use_create': 'new_other', 'crud_model_id': self.res_country_model_id, 'link_new_record': False, 'fields_lines': [(0, 0, {'col1': self.res_country_name_field_id, 'value': 'obj.name', 'type': 'equation'}), (0, 0, {'col1': self.res_country_code_field_id, 'value': 'obj.name[0:2]', 'type': 'equation'})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new country created cids = self.res_country.search(cr, uid, [('name', 'ilike', 'TestingPartner')]) self.assertEqual(len(cids), 1, 'ir_actions_server: TODO') country = self.res_country.browse(cr, uid, cids[0]) self.assertEqual(country.code, 'TE', 'ir_actions_server: TODO') # Do: copy a record in another model self.ir_actions_server.write(cr, uid, [self.act_id], {'fields_lines': [[5]]}) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'object_create', 'use_create': 'copy_other', 'crud_model_id': self.res_country_model_id, 'link_new_record': False, 'ref_object': 'res.country,%s' % self.test_country_id, 'fields_lines': [(0, 0, {'col1': self.res_country_name_field_id, 'value': 'NewCountry', 'type': 'value'}), (0, 0, {'col1': self.res_country_code_field_id, 'value': 'NY', 'type': 'value'})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new country created cids = self.res_country.search(cr, uid, [('name', 'ilike', 'NewCountry')]) self.assertEqual(len(cids), 1, 'ir_actions_server: TODO') country = self.res_country.browse(cr, uid, cids[0]) self.assertEqual(country.code, 'NY', 'ir_actions_server: TODO') self.assertEqual(country.address_format, 'SuperFormat', 'ir_actions_server: TODO') def test_50_crud_write(self): cr, uid = self.cr, self.uid _name = 'TestNew' # Do: create a new record in the same model and link it self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'object_write', 'use_write': 'current', 'fields_lines': [(0, 0, {'col1': self.res_partner_name_field_id, 'value': _name})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new partner created pids = self.res_partner.search(cr, uid, [('name', 'ilike', _name)]) self.assertEqual(len(pids), 1, 'ir_actions_server: TODO') partner = self.res_partner.browse(cr, uid, pids[0]) self.assertEqual(partner.city, 'OrigCity', 'ir_actions_server: TODO') # Do: copy current record self.ir_actions_server.write(cr, uid, [self.act_id], {'fields_lines': [[5]]}) self.ir_actions_server.write(cr, uid, [self.act_id], { 'use_write': 'other', 'crud_model_id': self.res_country_model_id, 'ref_object': 'res.country,%s' % self.test_country_id, 'fields_lines': [(0, 0, {'col1': self.res_country_name_field_id, 'value': 'obj.name', 'type': 'equation'})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new country created cids = self.res_country.search(cr, uid, [('name', 'ilike', 'TestNew')]) self.assertEqual(len(cids), 1, 'ir_actions_server: TODO') # Do: copy a record in another model self.ir_actions_server.write(cr, uid, [self.act_id], {'fields_lines': [[5]]}) self.ir_actions_server.write(cr, uid, [self.act_id], { 'use_write': 'expression', 'crud_model_id': self.res_country_model_id, 'write_expression': 'object.country_id', 'fields_lines': [(0, 0, {'col1': self.res_country_name_field_id, 'value': 'NewCountry', 'type': 'value'})], }) run_res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) self.assertFalse(run_res, 'ir_actions_server: create record action correctly finished should return False') # Test: new country created cids = self.res_country.search(cr, uid, [('name', 'ilike', 'NewCountry')]) self.assertEqual(len(cids), 1, 'ir_actions_server: TODO') @mute_logger('openerp.addons.base.ir.ir_model', 'openerp.models') def test_60_multi(self): cr, uid = self.cr, self.uid # Data: 2 server actions that will be nested act1_id = self.ir_actions_server.create(cr, uid, { 'name': 'Subaction1', 'sequence': 1, 'model_id': self.res_partner_model_id, 'state': 'code', 'code': 'action = {"type": "ir.actions.act_window"}', }) act2_id = self.ir_actions_server.create(cr, uid, { 'name': 'Subaction2', 'sequence': 2, 'model_id': self.res_partner_model_id, 'state': 'object_create', 'use_create': 'copy_current', }) act3_id = self.ir_actions_server.create(cr, uid, { 'name': 'Subaction3', 'sequence': 3, 'model_id': self.res_partner_model_id, 'state': 'code', 'code': 'action = {"type": "ir.actions.act_url"}', }) self.ir_actions_server.write(cr, uid, [self.act_id], { 'state': 'multi', 'child_ids': [(6, 0, [act1_id, act2_id, act3_id])], }) # Do: run the action res = self.ir_actions_server.run(cr, uid, [self.act_id], context=self.context) # Test: new partner created pids = self.res_partner.search(cr, uid, [('name', 'ilike', 'TestingPartner (copy)')]) # currently res_partner overrides default['name'] whatever its value self.assertEqual(len(pids), 1, 'ir_actions_server: TODO') # Test: action returned self.assertEqual(res.get('type'), 'ir.actions.act_url') # Test loops with self.assertRaises(except_orm): self.ir_actions_server.write(cr, uid, [self.act_id], { 'child_ids': [(6, 0, [self.act_id])] }) if __name__ == '__main__': unittest2.main()
agpl-3.0
[ 646, 2882, 18, 199, 199, 504, 5166, 14, 4795, 14, 1025, 492, 871, 63, 1025, 199, 646, 5166, 14, 2219, 14, 2330, 465, 2863, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 1379, 3120, 9303, 1563, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3120, 9303, 1563, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 29941, 267, 291, 14, 723, 63, 3723, 63, 1000, 275, 291, 14, 5189, 360, 723, 14, 3723, 14, 1000, 358, 267, 291, 14, 723, 63, 3723, 63, 1258, 275, 291, 14, 5189, 360, 723, 14, 3723, 14, 1258, 358, 267, 291, 14, 723, 63, 1459, 275, 291, 14, 5189, 360, 723, 14, 1459, 358, 267, 291, 14, 723, 63, 1238, 275, 291, 14, 5189, 360, 723, 14, 1238, 358, 267, 291, 14, 723, 63, 1238, 63, 955, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 955, 358, 267, 291, 14, 470, 63, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 470, 63, 6063, 275, 291, 14, 5189, 360, 470, 14, 6063, 358, 398, 327, 3918, 641, 1314, 781, 911, 1255, 314, 1654, 1595, 267, 291, 14, 396, 63, 6063, 63, 344, 275, 291, 14, 470, 63, 6063, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 9029, 17393, 297, 288, 283, 600, 356, 283, 2099, 297, 288, 283, 1562, 63, 908, 356, 283, 11823, 3484, 297, 267, 3828, 267, 291, 14, 396, 63, 6063, 275, 291, 14, 470, 63, 6063, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 396, 63, 6063, 63, 344, 9, 267, 291, 14, 396, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 9029, 24120, 297, 288, 283, 3690, 356, 283, 29698, 17024, 297, 288, 283, 6063, 63, 344, 356, 291, 14, 396, 63, 6063, 63, 344, 12, 267, 3828, 267, 291, 14, 396, 63, 3899, 275, 291, 14, 470, 63, 3899, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 396, 63, 3899, 63, 344, 9, 267, 291, 14, 1100, 275, 469, 288, 283, 2682, 63, 344, 356, 291, 14, 396, 63, 3899, 63, 344, 12, 288, 283, 2682, 63, 1238, 356, 283, 470, 14, 3899, 297, 267, 789, 398, 327, 5822, 666, 267, 291, 14, 470, 63, 3899, 63, 1238, 63, 344, 275, 291, 14, 723, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 354, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 354, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 3690, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 3690, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 6063, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 6063, 63, 344, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 1708, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 1708, 63, 344, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 1238, 63, 344, 275, 291, 14, 723, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 354, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 659, 661, 354, 297, 6291, 283, 354, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 600, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 659, 661, 354, 297, 6291, 283, 600, 2023, 59, 16, 61, 398, 327, 1218, 1654, 1595, 370, 267, 291, 14, 2442, 63, 344, 275, 291, 14, 723, 63, 3723, 63, 1000, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 774, 3310, 297, 288, 283, 5394, 356, 283, 549, 297, 288, 283, 1238, 63, 344, 356, 291, 14, 470, 63, 3899, 63, 1238, 63, 344, 12, 288, 283, 929, 356, 283, 600, 297, 288, 283, 600, 356, 283, 1113, 14, 952, 6333, 3349, 582, 298, 5713, 7488, 5984, 297, 267, 3828, 421, 199, 533, 1379, 3120, 9303, 8, 774, 3120, 9303, 1563, 304, 339, 347, 511, 63, 383, 63, 1287, 8, 277, 304, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 4226, 26, 3468, 283, 549, 7, 5558, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 1065, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 291, 14, 1100, 9, 267, 291, 14, 396, 63, 3899, 14, 6635, 342, 267, 291, 14, 629, 8, 277, 14, 396, 63, 3899, 14, 3349, 12, 283, 5713, 7488, 297, 283, 723, 63, 3723, 63, 1000, 26, 3866, 5558, 1104, 358, 267, 291, 14, 396, 63, 3899, 14, 952, 3252, 3349, 356, 756, 1552, 398, 327, 4226, 26, 3468, 756, 5558, 12, 626, 1077, 506, 8652, 465, 715, 334, 1647, 275, 715, 9, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 952, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 791, 5394, 356, 756, 1552, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 1065, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 291 ]
[ 2882, 18, 199, 199, 504, 5166, 14, 4795, 14, 1025, 492, 871, 63, 1025, 199, 646, 5166, 14, 2219, 14, 2330, 465, 2863, 199, 504, 5166, 14, 2537, 492, 333, 938, 63, 2921, 421, 199, 533, 1379, 3120, 9303, 1563, 8, 2330, 14, 10161, 1538, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 774, 3120, 9303, 1563, 12, 291, 680, 5996, 342, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 29941, 267, 291, 14, 723, 63, 3723, 63, 1000, 275, 291, 14, 5189, 360, 723, 14, 3723, 14, 1000, 358, 267, 291, 14, 723, 63, 3723, 63, 1258, 275, 291, 14, 5189, 360, 723, 14, 3723, 14, 1258, 358, 267, 291, 14, 723, 63, 1459, 275, 291, 14, 5189, 360, 723, 14, 1459, 358, 267, 291, 14, 723, 63, 1238, 275, 291, 14, 5189, 360, 723, 14, 1238, 358, 267, 291, 14, 723, 63, 1238, 63, 955, 275, 291, 14, 5189, 360, 723, 14, 1238, 14, 955, 358, 267, 291, 14, 470, 63, 3899, 275, 291, 14, 5189, 360, 470, 14, 3899, 358, 267, 291, 14, 470, 63, 6063, 275, 291, 14, 5189, 360, 470, 14, 6063, 358, 398, 327, 3918, 641, 1314, 781, 911, 1255, 314, 1654, 1595, 267, 291, 14, 396, 63, 6063, 63, 344, 275, 291, 14, 470, 63, 6063, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 9029, 17393, 297, 288, 283, 600, 356, 283, 2099, 297, 288, 283, 1562, 63, 908, 356, 283, 11823, 3484, 297, 267, 3828, 267, 291, 14, 396, 63, 6063, 275, 291, 14, 470, 63, 6063, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 396, 63, 6063, 63, 344, 9, 267, 291, 14, 396, 63, 3899, 63, 344, 275, 291, 14, 470, 63, 3899, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 9029, 24120, 297, 288, 283, 3690, 356, 283, 29698, 17024, 297, 288, 283, 6063, 63, 344, 356, 291, 14, 396, 63, 6063, 63, 344, 12, 267, 3828, 267, 291, 14, 396, 63, 3899, 275, 291, 14, 470, 63, 3899, 14, 4570, 8, 1556, 12, 1747, 12, 291, 14, 396, 63, 3899, 63, 344, 9, 267, 291, 14, 1100, 275, 469, 288, 283, 2682, 63, 344, 356, 291, 14, 396, 63, 3899, 63, 344, 12, 288, 283, 2682, 63, 1238, 356, 283, 470, 14, 3899, 297, 267, 789, 398, 327, 5822, 666, 267, 291, 14, 470, 63, 3899, 63, 1238, 63, 344, 275, 291, 14, 723, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 354, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 354, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 3690, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 3690, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 6063, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 6063, 63, 344, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 3899, 63, 1708, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 3899, 659, 661, 354, 297, 6291, 283, 1708, 63, 344, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 1238, 63, 344, 275, 291, 14, 723, 63, 1238, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 354, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 659, 661, 354, 297, 6291, 283, 354, 2023, 59, 16, 61, 267, 291, 14, 470, 63, 6063, 63, 600, 63, 698, 63, 344, 275, 291, 14, 723, 63, 1238, 63, 955, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 1238, 297, 6291, 283, 470, 14, 6063, 659, 661, 354, 297, 6291, 283, 600, 2023, 59, 16, 61, 398, 327, 1218, 1654, 1595, 370, 267, 291, 14, 2442, 63, 344, 275, 291, 14, 723, 63, 3723, 63, 1000, 14, 981, 8, 1556, 12, 1747, 12, 469, 288, 283, 354, 356, 283, 774, 3310, 297, 288, 283, 5394, 356, 283, 549, 297, 288, 283, 1238, 63, 344, 356, 291, 14, 470, 63, 3899, 63, 1238, 63, 344, 12, 288, 283, 929, 356, 283, 600, 297, 288, 283, 600, 356, 283, 1113, 14, 952, 6333, 3349, 582, 298, 5713, 7488, 5984, 297, 267, 3828, 421, 199, 533, 1379, 3120, 9303, 8, 774, 3120, 9303, 1563, 304, 339, 347, 511, 63, 383, 63, 1287, 8, 277, 304, 267, 2467, 12, 1747, 275, 291, 14, 1556, 12, 291, 14, 1535, 398, 327, 4226, 26, 3468, 283, 549, 7, 5558, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 1065, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 291, 14, 1100, 9, 267, 291, 14, 396, 63, 3899, 14, 6635, 342, 267, 291, 14, 629, 8, 277, 14, 396, 63, 3899, 14, 3349, 12, 283, 5713, 7488, 297, 283, 723, 63, 3723, 63, 1000, 26, 3866, 5558, 1104, 358, 267, 291, 14, 396, 63, 3899, 14, 952, 3252, 3349, 356, 756, 1552, 398, 327, 4226, 26, 3468, 756, 5558, 12, 626, 1077, 506, 8652, 465, 715, 334, 1647, 275, 715, 9, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 952, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 791, 5394, 356, 756, 1552, 267, 291, 14, 723, 63, 3723, 63, 1000, 14, 1065, 8, 1556, 12, 1747, 12, 359, 277, 14, 2442, 63, 344, 467, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
boyuegame/kbengine
kbe/res/scripts/common/Lib/site-packages/pip/commands/wheel.py
328
7320
# -*- coding: utf-8 -*- from __future__ import absolute_import import os import sys from pip.basecommand import Command from pip.index import PackageFinder from pip.log import logger from pip.exceptions import CommandError, PreviousBuildDirError from pip.req import InstallRequirement, RequirementSet, parse_requirements from pip.util import normalize_path from pip.wheel import WheelBuilder from pip import cmdoptions DEFAULT_WHEEL_DIR = os.path.join(normalize_path(os.curdir), 'wheelhouse') class WheelCommand(Command): """ Build Wheel archives for your requirements and dependencies. Wheel is a built-package format, and offers the advantage of not recompiling your software during every install. For more details, see the wheel docs: http://wheel.readthedocs.org/en/latest. Requirements: setuptools>=0.8, and wheel. 'pip wheel' uses the bdist_wheel setuptools extension from the wheel package to build individual wheels. """ name = 'wheel' usage = """ %prog [options] <requirement specifier> ... %prog [options] -r <requirements file> ... %prog [options] <vcs project url> ... %prog [options] <local project path> ... %prog [options] <archive url/path> ...""" summary = 'Build wheels from your requirements.' def __init__(self, *args, **kw): super(WheelCommand, self).__init__(*args, **kw) cmd_opts = self.cmd_opts cmd_opts.add_option( '-w', '--wheel-dir', dest='wheel_dir', metavar='dir', default=DEFAULT_WHEEL_DIR, help="Build wheels into <dir>, where the default is '<cwd>/wheelhouse'.") cmd_opts.add_option(cmdoptions.use_wheel.make()) cmd_opts.add_option(cmdoptions.no_use_wheel.make()) cmd_opts.add_option( '--build-option', dest='build_options', metavar='options', action='append', help="Extra arguments to be supplied to 'setup.py bdist_wheel'.") cmd_opts.add_option(cmdoptions.requirements.make()) cmd_opts.add_option(cmdoptions.download_cache.make()) cmd_opts.add_option(cmdoptions.no_deps.make()) cmd_opts.add_option(cmdoptions.build_dir.make()) cmd_opts.add_option( '--global-option', dest='global_options', action='append', metavar='options', help="Extra global options to be supplied to the setup.py " "call before the 'bdist_wheel' command.") cmd_opts.add_option( '--pre', action='store_true', default=False, help="Include pre-release and development versions. By default, pip only finds stable versions.") cmd_opts.add_option(cmdoptions.no_clean.make()) index_opts = cmdoptions.make_option_group(cmdoptions.index_group, self.parser) self.parser.insert_option_group(0, index_opts) self.parser.insert_option_group(0, cmd_opts) def run(self, options, args): # confirm requirements try: import wheel.bdist_wheel except ImportError: raise CommandError("'pip wheel' requires the 'wheel' package. To fix this, run: pip install wheel") try: import pkg_resources except ImportError: raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info support." " To fix this, run: pip install --upgrade setuptools" ) else: if not hasattr(pkg_resources, 'DistInfoDistribution'): raise CommandError( "'pip wheel' requires setuptools >= 0.8 for dist-info " "support. To fix this, run: pip install --upgrade " "setuptools" ) index_urls = [options.index_url] + options.extra_index_urls if options.no_index: logger.notify('Ignoring indexes: %s' % ','.join(index_urls)) index_urls = [] if options.use_mirrors: logger.deprecated("1.7", "--use-mirrors has been deprecated and will be removed" " in the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") if options.mirrors: logger.deprecated("1.7", "--mirrors has been deprecated and will be removed in " " the future. Explicit uses of --index-url and/or " "--extra-index-url is suggested.") index_urls += options.mirrors session = self._build_session(options) finder = PackageFinder(find_links=options.find_links, index_urls=index_urls, use_wheel=options.use_wheel, allow_external=options.allow_external, allow_unverified=options.allow_unverified, allow_all_external=options.allow_all_external, allow_all_prereleases=options.pre, process_dependency_links= options.process_dependency_links, session=session, ) options.build_dir = os.path.abspath(options.build_dir) requirement_set = RequirementSet( build_dir=options.build_dir, src_dir=None, download_dir=None, download_cache=options.download_cache, ignore_dependencies=options.ignore_dependencies, ignore_installed=True, session=session, wheel_download_dir=options.wheel_dir ) # make the wheelhouse if not os.path.exists(options.wheel_dir): os.makedirs(options.wheel_dir) #parse args and/or requirements files for name in args: requirement_set.add_requirement( InstallRequirement.from_line(name, None)) for filename in options.requirements: for req in parse_requirements( filename, finder=finder, options=options, session=session): if req.editable: logger.notify("ignoring %s" % req.url) continue requirement_set.add_requirement(req) #fail if no requirements if not requirement_set.has_requirements: opts = {'name': self.name} msg = ('You must give at least one requirement ' 'to %(name)s (see "pip help %(name)s")' % opts) logger.error(msg) return try: #build wheels wb = WheelBuilder( requirement_set, finder, options.wheel_dir, build_options = options.build_options or [], global_options = options.global_options or [] ) wb.build() except PreviousBuildDirError: options.no_clean = True raise finally: if not options.no_clean: requirement_set.cleanup_files()
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 984, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 199, 504, 7305, 14, 1080, 492, 15665, 11791, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 14, 3924, 492, 14393, 12, 26902, 3425, 3567, 547, 199, 504, 7305, 14, 2103, 492, 13276, 17947, 12, 25013, 1084, 12, 2198, 63, 7538, 199, 504, 7305, 14, 1974, 492, 7666, 63, 515, 199, 504, 7305, 14, 11798, 492, 26161, 6437, 199, 504, 7305, 492, 2088, 1419, 199, 199, 3472, 63, 31588, 2901, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 7721, 63, 515, 8, 736, 14, 15594, 395, 283, 11798, 6740, 358, 199, 199, 533, 26161, 3110, 8, 3110, 304, 272, 408, 272, 6516, 26161, 25993, 367, 2195, 9760, 436, 5124, 14, 339, 26161, 365, 282, 6137, 13, 2491, 1475, 12, 436, 32563, 314, 30268, 402, 440, 295, 863, 5662, 2195, 2032, 5309, 4036, 3907, 14, 272, 2104, 1655, 2436, 12, 1937, 314, 9989, 9149, 26, 1455, 921, 11798, 14, 25085, 14, 1308, 15, 287, 15, 7410, 14, 339, 18513, 1470, 26, 9116, 8119, 16, 14, 24, 12, 436, 9989, 14, 339, 283, 9983, 9989, 7, 4440, 314, 26308, 63, 11798, 9116, 3329, 687, 314, 9989, 2559, 370, 1900, 8212, 28300, 14, 339, 408, 339, 536, 275, 283, 11798, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 12434, 16628, 30, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 15525, 2199, 1166, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 1832, 2199, 931, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 6404, 1166, 15, 515, 30, 2508, 1041, 339, 6212, 275, 283, 3425, 28300, 687, 2195, 9760, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 25663, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 398, 2088, 63, 3291, 275, 291, 14, 1760, 63, 3291, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 87, 297, 2850, 11798, 13, 694, 297, 288, 2053, 534, 11798, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 3472, 63, 31588, 2901, 63, 3022, 12, 288, 1720, 628, 3425, 28300, 1901, 665, 694, 6244, 2382, 314, 849, 365, 2650, 6525, 12202, 11798, 6740, 29435, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1180, 63, 11798, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 1180, 63, 11798, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 1506, 13, 1422, 297, 288, 2053, 534, 1506, 63, 1419, 297, 288, 8214, 534, 1419, 297, 288, 1595, 534, 740, 297, 288, 1720, 628, 7426, 2368, 370, 506, 6841, 370, 283, 2758, 14, 647, 26308, 63, 11798, 29435, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 7538, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 4249, 63, 1637, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 5846, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1506, 63, 694, 14, 1875, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 2966, 13, 1422, 297, 288, 2053, 534, 2966, 63, 1419, 297, 288, 1595, 534, 740, 297, 288, 8214, 534, 1419, 297, 288, 1720, 628, 7426, 2288, 1511, 370, 506, 6841, 370, 314, 3272, 14, 647, 298, 288, 298, 1250, 2544, 314, 283, 17403, 63, 11798, 7, 1414, 2685, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 657, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 849, 29, 797, 12, 288, 1720, 628, 7826, 876, 13, 3221, 436, 16367, 5459, 14, 4885, 849, 12, 7305, 1454, 17651, 17830, 5459, 2685, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 3118, 14, 1875, 1012, 398, 1478, 63, 3291, 275, 2088, 1419, 14, 1875, 63, 1422, 63, 923, 8, 1760, 1419, 14, 1080, 63, 923, 12, 291, 14, 2087, 9, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 1478, 63, 3291, 9, 267, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 2088, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 398, 327, 12679, 9760, 267, 862, 26, 288, 492, 9989, 14, 17403, 63, 11798, 267, 871, 3545, 26, 288, 746, 14393, 15587, 9983, 9989, 7, 5074, 314, 283, 11798, 7, 2559, 14, 4005, 5325, 642, 12, 1255, 26, 221, 7305, 3907, 9989, 531, 398, 862, 26, 288, 492, 5496, 63, 4435, 267, 871, 3545, 26, 288, 746, 14393, 8, 355, 3546, 9983, 9989, 7, 5074, 9116, 2356, 378, 14, 24, 367, 2917, 13, 815, 2291, 2122, 355, 298, 4005, 5325, 642, 12, 1255, 26, 7305, 3907, 1553, 9375, 9116, 2, 288, 776, 267, 587, 26, 288, 340, 440, 2688, 8, 4600, 63, 4435, 12, 283, 12012, 2354, 8580, 735, 355, 746, 14393, 8, 490, 3546, 9983, 9989, 7, 5074, 9116, 2356, 378, 14, 24, 367, 2917, 13, 815, 298, 490, 298, 4058, 14, 4005, 5325, 642, 12, 1255, 26, 7305, 3907, 1553, 9375, 298, 490, 298, 13623, 2, 355, 776, 398, 1478, 63, 3603, 275, 359, 1419, 14, 1080, 63, 633, 61, 435, 1511, 14, 2911, 63, 1080, 63, 3603, 267, 340, 1511, 14, 889, 63, 1080, 26, 288, 2512, 14, 6814, 360, 32390, 10507, 26, 450, 83, 7, 450, 12814, 904, 8, 1080, 63, 3603, 430, 288, 1478, 63, 3603, 275, 942, 398, 340, 1511, 14, 1180, 63, 12324, 83, 26, 288, 2512, 14, 6667, 480, 17, 14, 23, 401, 717, 4320, 1180, 13, 12324, 83, 965, 2757, 5906, 436, 911, 506, 4829, 2, 717, 298, 315, 314, 6466, 14, 23872, 4440, 402, 1553, 1080, 13, 633, 436, 15, 269, 298, 717, 4320, 2911, 13, 1080, 13, 633, 365, 25697, 2685, 398, 340, 1511, 14, 12324, 83, 26, 288, 2512 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 747, 199, 646, 984, 199, 504, 7305, 14, 1095, 1531, 492, 5817, 199, 504, 7305, 14, 1080, 492, 15665, 11791, 199, 504, 7305, 14, 793, 492, 2512, 199, 504, 7305, 14, 3924, 492, 14393, 12, 26902, 3425, 3567, 547, 199, 504, 7305, 14, 2103, 492, 13276, 17947, 12, 25013, 1084, 12, 2198, 63, 7538, 199, 504, 7305, 14, 1974, 492, 7666, 63, 515, 199, 504, 7305, 14, 11798, 492, 26161, 6437, 199, 504, 7305, 492, 2088, 1419, 199, 199, 3472, 63, 31588, 2901, 63, 3022, 275, 747, 14, 515, 14, 904, 8, 7721, 63, 515, 8, 736, 14, 15594, 395, 283, 11798, 6740, 358, 199, 199, 533, 26161, 3110, 8, 3110, 304, 272, 408, 272, 6516, 26161, 25993, 367, 2195, 9760, 436, 5124, 14, 339, 26161, 365, 282, 6137, 13, 2491, 1475, 12, 436, 32563, 314, 30268, 402, 440, 295, 863, 5662, 2195, 2032, 5309, 4036, 3907, 14, 272, 2104, 1655, 2436, 12, 1937, 314, 9989, 9149, 26, 1455, 921, 11798, 14, 25085, 14, 1308, 15, 287, 15, 7410, 14, 339, 18513, 1470, 26, 9116, 8119, 16, 14, 24, 12, 436, 9989, 14, 339, 283, 9983, 9989, 7, 4440, 314, 26308, 63, 11798, 9116, 3329, 687, 314, 9989, 2559, 370, 1900, 8212, 28300, 14, 339, 408, 339, 536, 275, 283, 11798, 7, 272, 4503, 275, 408, 489, 450, 6595, 359, 1419, 61, 665, 12434, 16628, 30, 2263, 489, 450, 6595, 359, 1419, 61, 446, 82, 665, 7538, 570, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 15525, 2199, 1166, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 1832, 2199, 931, 30, 2263, 489, 450, 6595, 359, 1419, 61, 665, 6404, 1166, 15, 515, 30, 2508, 1041, 339, 6212, 275, 283, 3425, 28300, 687, 2195, 9760, 3530, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 829, 304, 267, 1613, 8, 25663, 3110, 12, 291, 2843, 826, 9308, 589, 12, 1011, 829, 9, 398, 2088, 63, 3291, 275, 291, 14, 1760, 63, 3291, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2475, 87, 297, 2850, 11798, 13, 694, 297, 288, 2053, 534, 11798, 63, 694, 297, 288, 8214, 534, 694, 297, 288, 849, 29, 3472, 63, 31588, 2901, 63, 3022, 12, 288, 1720, 628, 3425, 28300, 1901, 665, 694, 6244, 2382, 314, 849, 365, 2650, 6525, 12202, 11798, 6740, 29435, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1180, 63, 11798, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 1180, 63, 11798, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 1506, 13, 1422, 297, 288, 2053, 534, 1506, 63, 1419, 297, 288, 8214, 534, 1419, 297, 288, 1595, 534, 740, 297, 288, 1720, 628, 7426, 2368, 370, 506, 6841, 370, 283, 2758, 14, 647, 26308, 63, 11798, 29435, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 7538, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 4249, 63, 1637, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 5846, 14, 1875, 1012, 267, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 1506, 63, 694, 14, 1875, 1012, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 2966, 13, 1422, 297, 288, 2053, 534, 2966, 63, 1419, 297, 288, 1595, 534, 740, 297, 288, 8214, 534, 1419, 297, 288, 1720, 628, 7426, 2288, 1511, 370, 506, 6841, 370, 314, 3272, 14, 647, 298, 288, 298, 1250, 2544, 314, 283, 17403, 63, 11798, 7, 1414, 2685, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 288, 2850, 657, 297, 288, 1595, 534, 1617, 63, 2052, 297, 288, 849, 29, 797, 12, 288, 1720, 628, 7826, 876, 13, 3221, 436, 16367, 5459, 14, 4885, 849, 12, 7305, 1454, 17651, 17830, 5459, 2685, 398, 2088, 63, 3291, 14, 525, 63, 1422, 8, 1760, 1419, 14, 889, 63, 3118, 14, 1875, 1012, 398, 1478, 63, 3291, 275, 2088, 1419, 14, 1875, 63, 1422, 63, 923, 8, 1760, 1419, 14, 1080, 63, 923, 12, 291, 14, 2087, 9, 398, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 1478, 63, 3291, 9, 267, 291, 14, 2087, 14, 3176, 63, 1422, 63, 923, 8, 16, 12, 2088, 63, 3291, 9, 339, 347, 1255, 8, 277, 12, 1511, 12, 1249, 304, 398, 327, 12679, 9760, 267, 862, 26, 288, 492, 9989, 14, 17403, 63, 11798, 267, 871, 3545, 26, 288, 746, 14393, 15587, 9983, 9989, 7, 5074, 314, 283, 11798, 7, 2559, 14, 4005, 5325, 642, 12, 1255, 26, 221, 7305, 3907, 9989, 531, 398, 862, 26, 288, 492, 5496, 63, 4435, 267, 871, 3545, 26, 288, 746, 14393, 8, 355, 3546, 9983, 9989, 7, 5074, 9116, 2356, 378, 14, 24, 367, 2917, 13, 815, 2291, 2122, 355, 298, 4005, 5325, 642, 12, 1255, 26, 7305, 3907, 1553, 9375, 9116, 2, 288, 776, 267, 587, 26, 288, 340, 440, 2688, 8, 4600, 63, 4435, 12, 283, 12012, 2354, 8580, 735, 355, 746, 14393, 8, 490, 3546, 9983, 9989, 7, 5074, 9116, 2356, 378, 14, 24, 367, 2917, 13, 815, 298, 490, 298, 4058, 14, 4005, 5325, 642, 12, 1255, 26, 7305, 3907, 1553, 9375, 298, 490, 298, 13623, 2, 355, 776, 398, 1478, 63, 3603, 275, 359, 1419, 14, 1080, 63, 633, 61, 435, 1511, 14, 2911, 63, 1080, 63, 3603, 267, 340, 1511, 14, 889, 63, 1080, 26, 288, 2512, 14, 6814, 360, 32390, 10507, 26, 450, 83, 7, 450, 12814, 904, 8, 1080, 63, 3603, 430, 288, 1478, 63, 3603, 275, 942, 398, 340, 1511, 14, 1180, 63, 12324, 83, 26, 288, 2512, 14, 6667, 480, 17, 14, 23, 401, 717, 4320, 1180, 13, 12324, 83, 965, 2757, 5906, 436, 911, 506, 4829, 2, 717, 298, 315, 314, 6466, 14, 23872, 4440, 402, 1553, 1080, 13, 633, 436, 15, 269, 298, 717, 4320, 2911, 13, 1080, 13, 633, 365, 25697, 2685, 398, 340, 1511, 14, 12324, 83, 26, 288, 2512, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
apache/incubator-airflow
tests/providers/amazon/aws/transfers/test_google_api_to_s3_system.py
10
2670
# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # import pytest from airflow.providers.amazon.aws.example_dags.example_google_api_to_s3_transfer_advanced import ( S3_DESTINATION_KEY as ADVANCED_S3_DESTINATION_KEY, ) from airflow.providers.amazon.aws.example_dags.example_google_api_to_s3_transfer_basic import ( S3_DESTINATION_KEY as BASIC_S3_DESTINATION_KEY, ) from airflow.providers.amazon.aws.hooks.s3 import S3Hook from tests.providers.google.cloud.utils.gcp_authenticator import GMP_KEY from tests.test_utils.amazon_system_helpers import ( AWS_DAG_FOLDER, AmazonSystemTest, provide_aws_context, provide_aws_s3_bucket, ) from tests.test_utils.gcp_system_helpers import GoogleSystemTest, provide_gcp_context BASIC_BUCKET, _ = S3Hook.parse_s3_url(BASIC_S3_DESTINATION_KEY) ADVANCED_BUCKET, _ = S3Hook.parse_s3_url(ADVANCED_S3_DESTINATION_KEY) @pytest.fixture def provide_s3_bucket_basic(): with provide_aws_s3_bucket(BASIC_BUCKET): yield @pytest.fixture def provide_s3_bucket_advanced(): with provide_aws_s3_bucket(ADVANCED_BUCKET): yield @pytest.mark.backend("mysql", "postgres") @pytest.mark.credential_file(GMP_KEY) class GoogleApiToS3TransferExampleDagsSystemTest(GoogleSystemTest, AmazonSystemTest): @pytest.mark.usefixtures("provide_s3_bucket_basic") @provide_aws_context() @provide_gcp_context(GMP_KEY, scopes=['https://www.googleapis.com/auth/spreadsheets.readonly']) def test_run_example_dag_google_api_to_s3_transfer_basic(self): self.run_dag('example_google_api_to_s3_transfer_basic', AWS_DAG_FOLDER) @pytest.mark.usefixtures("provide_s3_bucket_advanced") @provide_aws_context() @provide_gcp_context(GMP_KEY, scopes=['https://www.googleapis.com/auth/youtube.readonly']) def test_run_example_dag_google_api_to_s3_transfer_advanced(self): self.run_dag('example_google_api_to_s3_transfer_advanced', AWS_DAG_FOLDER)
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 4613, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 2694, 63, 32137, 14, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 492, 334, 272, 428, 19, 63, 19374, 568, 2594, 63, 3078, 465, 9521, 879, 25927, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 12, 199, 9, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 2694, 63, 32137, 14, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 492, 334, 272, 428, 19, 63, 19374, 568, 2594, 63, 3078, 465, 4147, 948, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 12, 199, 9, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 83, 19, 492, 428, 19, 8481, 199, 504, 2295, 14, 9710, 14, 3098, 14, 4091, 14, 1208, 14, 20622, 63, 1178, 21345, 492, 598, 1658, 63, 3078, 199, 504, 2295, 14, 396, 63, 1208, 14, 15144, 63, 2253, 63, 7546, 492, 334, 272, 10168, 63, 28211, 63, 19041, 12, 272, 14347, 3989, 774, 12, 272, 5647, 63, 7231, 63, 1100, 12, 272, 5647, 63, 7231, 63, 83, 19, 63, 4623, 12, 199, 9, 199, 504, 2295, 14, 396, 63, 1208, 14, 20622, 63, 2253, 63, 7546, 492, 4475, 3989, 774, 12, 5647, 63, 20622, 63, 1100, 199, 199, 27271, 63, 20156, 12, 485, 275, 428, 19, 8481, 14, 1122, 63, 83, 19, 63, 633, 8, 27271, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 9, 199, 1554, 54, 879, 25927, 63, 20156, 12, 485, 275, 428, 19, 8481, 14, 1122, 63, 83, 19, 63, 633, 8, 1554, 54, 879, 25927, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 5647, 63, 83, 19, 63, 4623, 63, 4316, 837, 272, 543, 5647, 63, 7231, 63, 83, 19, 63, 4623, 8, 27271, 63, 20156, 304, 267, 1995, 421, 199, 32, 4462, 14, 5997, 199, 318, 5647, 63, 83, 19, 63, 4623, 63, 14652, 837, 272, 543, 5647, 63, 7231, 63, 83, 19, 63, 4623, 8, 1554, 54, 879, 25927, 63, 20156, 304, 267, 1995, 421, 199, 32, 4462, 14, 1657, 14, 4620, 480, 8644, 401, 298, 10675, 531, 199, 32, 4462, 14, 1657, 14, 15591, 63, 493, 8, 39, 1658, 63, 3078, 9, 199, 533, 4475, 7394, 1378, 51, 19, 11761, 9846, 36, 7391, 3989, 774, 8, 13266, 3989, 774, 12, 14347, 3989, 774, 304, 272, 768, 4462, 14, 1657, 14, 1180, 8769, 480, 20824, 63, 83, 19, 63, 4623, 63, 4316, 531, 272, 768, 20824, 63, 7231, 63, 1100, 342, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 1658, 63, 3078, 12, 14570, 2968, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 19930, 83, 14, 6753, 1105, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 297, 10168, 63, 28211, 63, 19041, 9, 339, 768, 4462, 14, 1657, 14, 1180, 8769, 480, 20824, 63, 83, 19, 63, 4623, 63, 14652, 531, 272, 768, 20824, 63, 7231, 63, 1100, 342, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 1658, 63, 3078, 12, 14570, 2968, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 9788, 14, 6753, 1105, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 297, 10168, 63, 28211, 63, 19041, 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 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 3, 199, 199, 646, 4613, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 2694, 63, 32137, 14, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 492, 334, 272, 428, 19, 63, 19374, 568, 2594, 63, 3078, 465, 9521, 879, 25927, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 12, 199, 9, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 2694, 63, 32137, 14, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 492, 334, 272, 428, 19, 63, 19374, 568, 2594, 63, 3078, 465, 4147, 948, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 12, 199, 9, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 83, 19, 492, 428, 19, 8481, 199, 504, 2295, 14, 9710, 14, 3098, 14, 4091, 14, 1208, 14, 20622, 63, 1178, 21345, 492, 598, 1658, 63, 3078, 199, 504, 2295, 14, 396, 63, 1208, 14, 15144, 63, 2253, 63, 7546, 492, 334, 272, 10168, 63, 28211, 63, 19041, 12, 272, 14347, 3989, 774, 12, 272, 5647, 63, 7231, 63, 1100, 12, 272, 5647, 63, 7231, 63, 83, 19, 63, 4623, 12, 199, 9, 199, 504, 2295, 14, 396, 63, 1208, 14, 20622, 63, 2253, 63, 7546, 492, 4475, 3989, 774, 12, 5647, 63, 20622, 63, 1100, 199, 199, 27271, 63, 20156, 12, 485, 275, 428, 19, 8481, 14, 1122, 63, 83, 19, 63, 633, 8, 27271, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 9, 199, 1554, 54, 879, 25927, 63, 20156, 12, 485, 275, 428, 19, 8481, 14, 1122, 63, 83, 19, 63, 633, 8, 1554, 54, 879, 25927, 63, 51, 19, 63, 19374, 568, 2594, 63, 3078, 9, 421, 199, 32, 4462, 14, 5997, 199, 318, 5647, 63, 83, 19, 63, 4623, 63, 4316, 837, 272, 543, 5647, 63, 7231, 63, 83, 19, 63, 4623, 8, 27271, 63, 20156, 304, 267, 1995, 421, 199, 32, 4462, 14, 5997, 199, 318, 5647, 63, 83, 19, 63, 4623, 63, 14652, 837, 272, 543, 5647, 63, 7231, 63, 83, 19, 63, 4623, 8, 1554, 54, 879, 25927, 63, 20156, 304, 267, 1995, 421, 199, 32, 4462, 14, 1657, 14, 4620, 480, 8644, 401, 298, 10675, 531, 199, 32, 4462, 14, 1657, 14, 15591, 63, 493, 8, 39, 1658, 63, 3078, 9, 199, 533, 4475, 7394, 1378, 51, 19, 11761, 9846, 36, 7391, 3989, 774, 8, 13266, 3989, 774, 12, 14347, 3989, 774, 304, 272, 768, 4462, 14, 1657, 14, 1180, 8769, 480, 20824, 63, 83, 19, 63, 4623, 63, 4316, 531, 272, 768, 20824, 63, 7231, 63, 1100, 342, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 1658, 63, 3078, 12, 14570, 2968, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 19930, 83, 14, 6753, 1105, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 4316, 297, 10168, 63, 28211, 63, 19041, 9, 339, 768, 4462, 14, 1657, 14, 1180, 8769, 480, 20824, 63, 83, 19, 63, 4623, 63, 14652, 531, 272, 768, 20824, 63, 7231, 63, 1100, 342, 272, 768, 20824, 63, 20622, 63, 1100, 8, 39, 1658, 63, 3078, 12, 14570, 2968, 2859, 921, 1544, 14, 17533, 14, 957, 15, 1178, 15, 9788, 14, 6753, 1105, 272, 347, 511, 63, 1065, 63, 2694, 63, 7406, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 8, 277, 304, 267, 291, 14, 1065, 63, 7406, 360, 2694, 63, 3098, 63, 1246, 63, 475, 63, 83, 19, 63, 9609, 63, 14652, 297, 10168, 63, 28211, 63, 19041, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
odubno/microblog
flask/lib/python2.7/site-packages/openid/extensions/ax.py
166
26382
# -*- test-case-name: openid.test.test_ax -*- """Implements the OpenID Attribute Exchange specification, version 1.0. @since: 2.1.0 """ __all__ = [ 'AttributeRequest', 'FetchRequest', 'FetchResponse', 'StoreRequest', 'StoreResponse', ] from openid import extension from openid.server.trustroot import TrustRoot from openid.message import NamespaceMap, OPENID_NS # Use this as the 'count' value for an attribute in a FetchRequest to # ask for as many values as the OP can provide. UNLIMITED_VALUES = "unlimited" # Minimum supported alias length in characters. Here for # completeness. MINIMUM_SUPPORTED_ALIAS_LENGTH = 32 def checkAlias(alias): """ Check an alias for invalid characters; raise AXError if any are found. Return None if the alias is valid. """ if ',' in alias: raise AXError("Alias %r must not contain comma" % (alias,)) if '.' in alias: raise AXError("Alias %r must not contain period" % (alias,)) class AXError(ValueError): """Results from data that does not meet the attribute exchange 1.0 specification""" class NotAXMessage(AXError): """Raised when there is no Attribute Exchange mode in the message.""" def __repr__(self): return self.__class__.__name__ def __str__(self): return self.__class__.__name__ class AXMessage(extension.Extension): """Abstract class containing common code for attribute exchange messages @cvar ns_alias: The preferred namespace alias for attribute exchange messages @cvar mode: The type of this attribute exchange message. This must be overridden in subclasses. """ # This class is abstract, so it's OK that it doesn't override the # abstract method in Extension: # #pylint:disable-msg=W0223 ns_alias = 'ax' mode = None ns_uri = 'http://openid.net/srv/ax/1.0' def _checkMode(self, ax_args): """Raise an exception if the mode in the attribute exchange arguments does not match what is expected for this class. @raises NotAXMessage: When there is no mode value in ax_args at all. @raises AXError: When mode does not match. """ mode = ax_args.get('mode') if mode != self.mode: if not mode: raise NotAXMessage() else: raise AXError( 'Expected mode %r; got %r' % (self.mode, mode)) def _newArgs(self): """Return a set of attribute exchange arguments containing the basic information that must be in every attribute exchange message. """ return {'mode':self.mode} class AttrInfo(object): """Represents a single attribute in an attribute exchange request. This should be added to an AXRequest object in order to request the attribute. @ivar required: Whether the attribute will be marked as required when presented to the subject of the attribute exchange request. @type required: bool @ivar count: How many values of this type to request from the subject. Defaults to one. @type count: int @ivar type_uri: The identifier that determines what the attribute represents and how it is serialized. For example, one type URI representing dates could represent a Unix timestamp in base 10 and another could represent a human-readable string. @type type_uri: str @ivar alias: The name that should be given to this alias in the request. If it is not supplied, a generic name will be assigned. For example, if you want to call a Unix timestamp value 'tstamp', set its alias to that value. If two attributes in the same message request to use the same alias, the request will fail to be generated. @type alias: str or NoneType """ # It's OK that this class doesn't have public methods (it's just a # holder for a bunch of attributes): # #pylint:disable-msg=R0903 def __init__(self, type_uri, count=1, required=False, alias=None): self.required = required self.count = count self.type_uri = type_uri self.alias = alias if self.alias is not None: checkAlias(self.alias) def wantsUnlimitedValues(self): """ When processing a request for this attribute, the OP should call this method to determine whether all available attribute values were requested. If self.count == UNLIMITED_VALUES, this returns True. Otherwise this returns False, in which case self.count is an integer. """ return self.count == UNLIMITED_VALUES def toTypeURIs(namespace_map, alias_list_s): """Given a namespace mapping and a string containing a comma-separated list of namespace aliases, return a list of type URIs that correspond to those aliases. @param namespace_map: The mapping from namespace URI to alias @type namespace_map: openid.message.NamespaceMap @param alias_list_s: The string containing the comma-separated list of aliases. May also be None for convenience. @type alias_list_s: str or NoneType @returns: The list of namespace URIs that corresponds to the supplied list of aliases. If the string was zero-length or None, an empty list will be returned. @raise KeyError: If an alias is present in the list of aliases but is not present in the namespace map. """ uris = [] if alias_list_s: for alias in alias_list_s.split(','): type_uri = namespace_map.getNamespaceURI(alias) if type_uri is None: raise KeyError( 'No type is defined for attribute name %r' % (alias,)) else: uris.append(type_uri) return uris class FetchRequest(AXMessage): """An attribute exchange 'fetch_request' message. This message is sent by a relying party when it wishes to obtain attributes about the subject of an OpenID authentication request. @ivar requested_attributes: The attributes that have been requested thus far, indexed by the type URI. @type requested_attributes: {str:AttrInfo} @ivar update_url: A URL that will accept responses for this attribute exchange request, even in the absence of the user who made this request. """ mode = 'fetch_request' def __init__(self, update_url=None): AXMessage.__init__(self) self.requested_attributes = {} self.update_url = update_url def add(self, attribute): """Add an attribute to this attribute exchange request. @param attribute: The attribute that is being requested @type attribute: C{L{AttrInfo}} @returns: None @raise KeyError: when the requested attribute is already present in this fetch request. """ if attribute.type_uri in self.requested_attributes: raise KeyError('The attribute %r has already been requested' % (attribute.type_uri,)) self.requested_attributes[attribute.type_uri] = attribute def getExtensionArgs(self): """Get the serialized form of this attribute fetch request. @returns: The fetch request message parameters @rtype: {unicode:unicode} """ aliases = NamespaceMap() required = [] if_available = [] ax_args = self._newArgs() for type_uri, attribute in self.requested_attributes.iteritems(): if attribute.alias is None: alias = aliases.add(type_uri) else: # This will raise an exception when the second # attribute with the same alias is added. I think it # would be better to complain at the time that the # attribute is added to this object so that the code # that is adding it is identified in the stack trace, # but it's more work to do so, and it won't be 100% # accurate anyway, since the attributes are # mutable. So for now, just live with the fact that # we'll learn about the error later. # # The other possible approach is to hide the error and # generate a new alias on the fly. I think that would # probably be bad. alias = aliases.addAlias(type_uri, attribute.alias) if attribute.required: required.append(alias) else: if_available.append(alias) if attribute.count != 1: ax_args['count.' + alias] = str(attribute.count) ax_args['type.' + alias] = type_uri if required: ax_args['required'] = ','.join(required) if if_available: ax_args['if_available'] = ','.join(if_available) return ax_args def getRequiredAttrs(self): """Get the type URIs for all attributes that have been marked as required. @returns: A list of the type URIs for attributes that have been marked as required. @rtype: [str] """ required = [] for type_uri, attribute in self.requested_attributes.iteritems(): if attribute.required: required.append(type_uri) return required def fromOpenIDRequest(cls, openid_request): """Extract a FetchRequest from an OpenID message @param openid_request: The OpenID authentication request containing the attribute fetch request @type openid_request: C{L{openid.server.server.CheckIDRequest}} @rtype: C{L{FetchRequest}} or C{None} @returns: The FetchRequest extracted from the message or None, if the message contained no AX extension. @raises KeyError: if the AuthRequest is not consistent in its use of namespace aliases. @raises AXError: When parseExtensionArgs would raise same. @see: L{parseExtensionArgs} """ message = openid_request.message ax_args = message.getArgs(cls.ns_uri) self = cls() try: self.parseExtensionArgs(ax_args) except NotAXMessage, err: return None if self.update_url: # Update URL must match the openid.realm of the underlying # OpenID 2 message. realm = message.getArg(OPENID_NS, 'realm', message.getArg(OPENID_NS, 'return_to')) if not realm: raise AXError(("Cannot validate update_url %r " + "against absent realm") % (self.update_url,)) tr = TrustRoot.parse(realm) if not tr.validateURL(self.update_url): raise AXError("Update URL %r failed validation against realm %r" % (self.update_url, realm,)) return self fromOpenIDRequest = classmethod(fromOpenIDRequest) def parseExtensionArgs(self, ax_args): """Given attribute exchange arguments, populate this FetchRequest. @param ax_args: Attribute Exchange arguments from the request. As returned from L{Message.getArgs<openid.message.Message.getArgs>}. @type ax_args: dict @raises KeyError: if the message is not consistent in its use of namespace aliases. @raises NotAXMessage: If ax_args does not include an Attribute Exchange mode. @raises AXError: If the data to be parsed does not follow the attribute exchange specification. At least when 'if_available' or 'required' is not specified for a particular attribute type. """ # Raises an exception if the mode is not the expected value self._checkMode(ax_args) aliases = NamespaceMap() for key, value in ax_args.iteritems(): if key.startswith('type.'): alias = key[5:] type_uri = value aliases.addAlias(type_uri, alias) count_key = 'count.' + alias count_s = ax_args.get(count_key) if count_s: try: count = int(count_s) if count <= 0: raise AXError("Count %r must be greater than zero, got %r" % (count_key, count_s,)) except ValueError: if count_s != UNLIMITED_VALUES: raise AXError("Invalid count value for %r: %r" % (count_key, count_s,)) count = count_s else: count = 1 self.add(AttrInfo(type_uri, alias=alias, count=count)) required = toTypeURIs(aliases, ax_args.get('required')) for type_uri in required: self.requested_attributes[type_uri].required = True if_available = toTypeURIs(aliases, ax_args.get('if_available')) all_type_uris = required + if_available for type_uri in aliases.iterNamespaceURIs(): if type_uri not in all_type_uris: raise AXError( 'Type URI %r was in the request but not ' 'present in "required" or "if_available"' % (type_uri,)) self.update_url = ax_args.get('update_url') def iterAttrs(self): """Iterate over the AttrInfo objects that are contained in this fetch_request. """ return self.requested_attributes.itervalues() def __iter__(self): """Iterate over the attribute type URIs in this fetch_request """ return iter(self.requested_attributes) def has_key(self, type_uri): """Is the given type URI present in this fetch_request? """ return type_uri in self.requested_attributes __contains__ = has_key class AXKeyValueMessage(AXMessage): """An abstract class that implements a message that has attribute keys and values. It contains the common code between fetch_response and store_request. """ # This class is abstract, so it's OK that it doesn't override the # abstract method in Extension: # #pylint:disable-msg=W0223 def __init__(self): AXMessage.__init__(self) self.data = {} def addValue(self, type_uri, value): """Add a single value for the given attribute type to the message. If there are already values specified for this type, this value will be sent in addition to the values already specified. @param type_uri: The URI for the attribute @param value: The value to add to the response to the relying party for this attribute @type value: unicode @returns: None """ try: values = self.data[type_uri] except KeyError: values = self.data[type_uri] = [] values.append(value) def setValues(self, type_uri, values): """Set the values for the given attribute type. This replaces any values that have already been set for this attribute. @param type_uri: The URI for the attribute @param values: A list of values to send for this attribute. @type values: [unicode] """ self.data[type_uri] = values def _getExtensionKVArgs(self, aliases=None): """Get the extension arguments for the key/value pairs contained in this message. @param aliases: An alias mapping. Set to None if you don't care about the aliases for this request. """ if aliases is None: aliases = NamespaceMap() ax_args = {} for type_uri, values in self.data.iteritems(): alias = aliases.add(type_uri) ax_args['type.' + alias] = type_uri ax_args['count.' + alias] = str(len(values)) for i, value in enumerate(values): key = 'value.%s.%d' % (alias, i + 1) ax_args[key] = value return ax_args def parseExtensionArgs(self, ax_args): """Parse attribute exchange key/value arguments into this object. @param ax_args: The attribute exchange fetch_response arguments, with namespacing removed. @type ax_args: {unicode:unicode} @returns: None @raises ValueError: If the message has bad values for particular fields @raises KeyError: If the namespace mapping is bad or required arguments are missing """ self._checkMode(ax_args) aliases = NamespaceMap() for key, value in ax_args.iteritems(): if key.startswith('type.'): type_uri = value alias = key[5:] checkAlias(alias) aliases.addAlias(type_uri, alias) for type_uri, alias in aliases.iteritems(): try: count_s = ax_args['count.' + alias] except KeyError: value = ax_args['value.' + alias] if value == u'': values = [] else: values = [value] else: count = int(count_s) values = [] for i in range(1, count + 1): value_key = 'value.%s.%d' % (alias, i) value = ax_args[value_key] values.append(value) self.data[type_uri] = values def getSingle(self, type_uri, default=None): """Get a single value for an attribute. If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail. @type type_uri: str @param type_uri: The URI for the attribute @param default: The value to return if the attribute was not sent in the fetch_response. @returns: The value of the attribute in the fetch_response message, or the default supplied @rtype: unicode or NoneType @raises ValueError: If there is more than one value for this parameter in the fetch_response message. @raises KeyError: If the attribute was not sent in this response """ values = self.data.get(type_uri) if not values: return default elif len(values) == 1: return values[0] else: raise AXError( 'More than one value present for %r' % (type_uri,)) def get(self, type_uri): """Get the list of values for this attribute in the fetch_response. XXX: what to do if the values are not present? default parameter? this is funny because it's always supposed to return a list, so the default may break that, though it's provided by the user's code, so it might be okay. If no default is supplied, should the return be None or []? @param type_uri: The URI of the attribute @returns: The list of values for this attribute in the response. May be an empty list. @rtype: [unicode] @raises KeyError: If the attribute was not sent in the response """ return self.data[type_uri] def count(self, type_uri): """Get the number of responses for a particular attribute in this fetch_response message. @param type_uri: The URI of the attribute @returns: The number of values sent for this attribute @raises KeyError: If the attribute was not sent in the response. KeyError will not be raised if the number of values was zero. """ return len(self.get(type_uri)) class FetchResponse(AXKeyValueMessage): """A fetch_response attribute exchange message """ mode = 'fetch_response' def __init__(self, request=None, update_url=None): """ @param request: When supplied, I will use namespace aliases that match those in this request. I will also check to make sure I do not respond with attributes that were not requested. @type request: L{FetchRequest} @param update_url: By default, C{update_url} is taken from the request. But if you do not supply the request, you may set the C{update_url} here. @type update_url: str """ AXKeyValueMessage.__init__(self) self.update_url = update_url self.request = request def getExtensionArgs(self): """Serialize this object into arguments in the attribute exchange namespace @returns: The dictionary of unqualified attribute exchange arguments that represent this fetch_response. @rtype: {unicode;unicode} """ aliases = NamespaceMap() zero_value_types = [] if self.request is not None: # Validate the data in the context of the request (the # same attributes should be present in each, and the # counts in the response must be no more than the counts # in the request) for type_uri in self.data: if type_uri not in self.request: raise KeyError( 'Response attribute not present in request: %r' % (type_uri,)) for attr_info in self.request.iterAttrs(): # Copy the aliases from the request so that reading # the response in light of the request is easier if attr_info.alias is None: aliases.add(attr_info.type_uri) else: aliases.addAlias(attr_info.type_uri, attr_info.alias) try: values = self.data[attr_info.type_uri] except KeyError: values = [] zero_value_types.append(attr_info) if (attr_info.count != UNLIMITED_VALUES) and \ (attr_info.count < len(values)): raise AXError( 'More than the number of requested values were ' 'specified for %r' % (attr_info.type_uri,)) kv_args = self._getExtensionKVArgs(aliases) # Add the KV args into the response with the args that are # unique to the fetch_response ax_args = self._newArgs() # For each requested attribute, put its type/alias and count # into the response even if no data were returned. for attr_info in zero_value_types: alias = aliases.getAlias(attr_info.type_uri) kv_args['type.' + alias] = attr_info.type_uri kv_args['count.' + alias] = '0' update_url = ((self.request and self.request.update_url) or self.update_url) if update_url: ax_args['update_url'] = update_url ax_args.update(kv_args) return ax_args def parseExtensionArgs(self, ax_args): """@see: {Extension.parseExtensionArgs<openid.extension.Extension.parseExtensionArgs>}""" super(FetchResponse, self).parseExtensionArgs(ax_args) self.update_url = ax_args.get('update_url') def fromSuccessResponse(cls, success_response, signed=True): """Construct a FetchResponse object from an OpenID library SuccessResponse object. @param success_response: A successful id_res response object @type success_response: openid.consumer.consumer.SuccessResponse @param signed: Whether non-signed args should be processsed. If True (the default), only signed arguments will be processsed. @type signed: bool @returns: A FetchResponse containing the data from the OpenID message, or None if the SuccessResponse did not contain AX extension data. @raises AXError: when the AX data cannot be parsed. """ self = cls() ax_args = success_response.extensionResponse(self.ns_uri, signed) try: self.parseExtensionArgs(ax_args) except NotAXMessage, err: return None else: return self fromSuccessResponse = classmethod(fromSuccessResponse) class StoreRequest(AXKeyValueMessage): """A store request attribute exchange message representation """ mode = 'store_request' def __init__(self, aliases=None): """ @param aliases: The namespace aliases to use when making this store request. Leave as None to use defaults. """ super(StoreRequest, self).__init__() self.aliases = aliases def getExtensionArgs(self): """ @see: L{Extension.getExtensionArgs<openid.extension.Extension.getExtensionArgs>} """ ax_args = self._newArgs() kv_args = self._getExtensionKVArgs(self.aliases) ax_args.update(kv_args) return ax_args class StoreResponse(AXMessage): """An indication that the store request was processed along with this OpenID transaction. """ SUCCESS_MODE = 'store_response_success' FAILURE_MODE = 'store_response_failure' def __init__(self, succeeded=True, error_message=None): AXMessage.__init__(self) if succeeded and error_message is not None: raise AXError('An error message may only be included in a ' 'failing fetch response') if succeeded: self.mode = self.SUCCESS_MODE else: self.mode = self.FAILURE_MODE self.error_message = error_message def succeeded(self): """Was this response a success response?""" return self.mode == self.SUCCESS_MODE def getExtensionArgs(self): """@see: {Extension.getExtensionArgs<openid.extension.Extension.getExtensionArgs>}""" ax_args = self._newArgs() if not self.succeeded() and self.error_message: ax_args['error'] = self.error_message return ax_args
bsd-3-clause
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 24494, 14, 396, 14, 396, 63, 1219, 1882, 199, 624, 29452, 314, 25463, 3882, 25655, 8929, 12, 1015, 413, 14, 16, 14, 199, 199, 32, 8585, 26, 499, 14, 17, 14, 16, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1646, 2017, 297, 272, 283, 11135, 2017, 297, 272, 283, 11135, 2364, 297, 272, 283, 5502, 2017, 297, 272, 283, 5502, 2364, 297, 272, 1622, 199, 199, 504, 24494, 492, 3329, 199, 504, 24494, 14, 1000, 14, 15756, 1231, 492, 377, 19622, 6405, 199, 504, 24494, 14, 1188, 492, 19317, 2956, 12, 24164, 998, 63, 2709, 199, 199, 3, 3645, 642, 465, 314, 283, 835, 7, 574, 367, 376, 2225, 315, 282, 16347, 2017, 370, 199, 3, 7198, 367, 465, 5002, 1338, 465, 314, 9827, 883, 5647, 14, 199, 1734, 13387, 1149, 63, 15514, 275, 298, 324, 14136, 2, 199, 199, 3, 22466, 3748, 5162, 2582, 315, 4110, 14, 221, 11842, 367, 199, 3, 4890, 4171, 14, 199, 4896, 27078, 63, 15925, 63, 12644, 63, 9127, 275, 4337, 199, 199, 318, 1104, 14149, 8, 3620, 304, 272, 408, 272, 2670, 376, 5162, 367, 3866, 4110, 27, 746, 437, 29356, 340, 1263, 787, 272, 1911, 14, 221, 1432, 488, 340, 314, 5162, 365, 1686, 14, 272, 408, 272, 340, 13647, 315, 5162, 26, 267, 746, 437, 29356, 480, 14149, 450, 82, 1471, 440, 1395, 10029, 2, 450, 334, 3620, 4641, 272, 340, 7815, 315, 5162, 26, 267, 746, 437, 29356, 480, 14149, 450, 82, 1471, 440, 1395, 6247, 2, 450, 334, 3620, 4641, 421, 199, 533, 437, 29356, 8, 3393, 304, 272, 408, 6579, 687, 666, 626, 1630, 440, 26743, 314, 2225, 15343, 413, 14, 16, 272, 8929, 624, 421, 199, 533, 2832, 9839, 2209, 8, 9839, 547, 304, 272, 408, 16894, 1380, 2337, 365, 949, 3882, 25655, 818, 315, 314, 1245, 1041, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 533, 4914, 354, 363, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 855, 533, 4914, 354, 363, 421, 199, 533, 437, 56, 2209, 8, 3435, 14, 6382, 304, 272, 408, 8458, 1021, 3035, 2863, 1233, 367, 2225, 15343, 3788, 339, 768, 26781, 700, 63, 3620, 26, 710, 14388, 3231, 5162, 367, 2225, 267, 15343, 3788, 339, 768, 26781, 818, 26, 710, 730, 402, 642, 2225, 15343, 1245, 14, 961, 1471, 267, 506, 10087, 315, 9180, 14, 272, 408, 339, 327, 961, 1021, 365, 9006, 12, 880, 652, 1159, 9949, 626, 652, 3181, 1133, 4278, 314, 272, 327, 9006, 1083, 315, 13282, 26, 272, 327, 272, 327, 26324, 26, 5993, 13, 1328, 29, 55, 996, 1789, 339, 700, 63, 3620, 275, 283, 1219, 7, 272, 818, 275, 488, 272, 700, 63, 2302, 275, 283, 1014, 921, 15403, 14, 846, 15, 15165, 15, 1219, 15, 17, 14, 16, 7, 339, 347, 485, 1074, 1385, 8, 277, 12, 2185, 63, 589, 304, 267, 408, 18111, 376, 1919, 340, 314, 818, 315, 314, 2225, 15343, 267, 2368, 1630, 440, 1336, 4052, 365, 1420, 367, 642, 1021, 14, 398, 768, 3536, 2832, 9839, 2209, 26, 3979, 2337, 365, 949, 818, 574, 315, 2185, 63, 589, 737, 1006, 14, 398, 768, 3536, 437, 29356, 26, 3979, 818, 1630, 440, 1336, 14, 267, 408, 267, 818, 275, 2185, 63, 589, 14, 362, 360, 632, 358, 267, 340, 818, 1137, 291, 14, 632, 26, 288, 340, 440, 818, 26, 355, 746, 2832, 9839, 2209, 342, 288, 587, 26, 355, 746, 437, 29356, 8, 490, 283, 6964, 818, 450, 82, 27, 4788, 450, 82, 7, 450, 334, 277, 14, 632, 12, 818, 430, 339, 347, 485, 1222, 6213, 8, 277, 304, 267, 408, 1767, 282, 663, 402, 2225, 15343, 2368, 3035, 314, 267, 5678, 2556, 626, 1471, 506, 315, 4036, 2225, 15343, 267, 1245, 14, 267, 408, 267, 372, 791, 632, 356, 277, 14, 632, 93, 421, 199, 533, 20516, 2354, 8, 785, 304, 272, 408, 18089, 282, 2849, 2225, 315, 376, 2225, 15343, 272, 1056, 14, 961, 1077, 506, 3483, 370, 376, 437, 56, 2017, 909, 315, 1865, 370, 272, 1056, 314, 2225, 14, 339, 768, 7725, 1415, 26, 7480, 314, 2225, 911, 506, 11584, 465, 1415, 267, 1380, 26568, 370, 314, 5420, 402, 314, 2225, 15343, 267, 1056, 14, 272, 768, 466, 1415, 26, 2155, 339, 768, 7725, 2338, 26, 7494, 5002, 1338, 402, 642, 730, 370, 1056, 687, 314, 267, 5420, 14, 7827, 370, 1373, 14, 272, 768, 466, 2338, 26, 1109, 339, 768, 7725, 730, 63, 2302, 26, 710, 5148, 626, 16756, 4052, 314, 2225, 267, 8469, 436, 4212, 652, 365, 6380, 14, 2104, 2893, 12, 1373, 730, 9022, 267, 6144, 10831, 4293, 2954, 282, 13074, 4913, 315, 1300, 1616, 267, 436, 4573, 4293, 2954, 282, 11779, 13, 11875, 1059, 14, 272, 768, 466, 730, 63, 2302, 26, 620, 339, 768, 7725, 5162, 26, 710, 536, 626, 1077, 506, 1627, 370, 642, 5162, 315, 314, 267, 1056, 14, 982, 652, 365, 440, 6841, 12, 282, 7809, 536, 911, 506, 267, 7943, 14, 2104, 2893, 12, 340, 1265, 2934, 370, 1240, 282, 13074, 4913, 267, 574, 283, 84, 2359, 297, 663, 2399, 5162, 370, 626, 574, 14, 982, 2877, 3004, 267, 315, 314, 2011, 1245, 1056, 370, 675, 314, 2011, 5162, 12, 314, 1056, 267, 911, 2449, 370, 506, 4046, 14, 272, 768, 466, 5162, 26, 620, 503, 488, 804, 272, 408, 339, 327, 2779, 1159, 9949, 626, 642, 1021, 3181, 1133, 1172, 4575, 3102, 334, 390, 1159, 2951, 282, 272, 327, 16712, 367, 282, 22219, 402, 3004, 304, 272, 327, 272, 327, 26324, 26, 5993, 13, 1328, 29, 50, 1643, 1644, 339, 347, 636, 826, 721, 277, 12, 730, 63, 2302, 12, 2338, 29, 17, 12, 1415, 29, 797, 12, 5162, 29, 403, 304, 267, 291, 14, 2427, 275, 1415, 267, 291, 14, 835, 275, 2338, 267, 291, 14, 466, 63, 2302, 275, 730, 63, 2302, 267, 291, 14, 3620, 275, 5162, 398, 340, 291, 14, 3620, 365, 440, 488, 26, 288, 1104, 14149, 8, 277, 14, 3620, 9, 339, 347, 15061, 1358, 14136, 6550, 8, 277, 304, 267, 408, 267, 3979, 6661, 282, 1056, 367, 642, 2225, 12, 314, 9827, 1077, 267 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 24494, 14, 396, 14, 396, 63, 1219, 1882, 199, 624, 29452, 314, 25463, 3882, 25655, 8929, 12, 1015, 413, 14, 16, 14, 199, 199, 32, 8585, 26, 499, 14, 17, 14, 16, 199, 624, 199, 199, 363, 452, 363, 275, 359, 272, 283, 1646, 2017, 297, 272, 283, 11135, 2017, 297, 272, 283, 11135, 2364, 297, 272, 283, 5502, 2017, 297, 272, 283, 5502, 2364, 297, 272, 1622, 199, 199, 504, 24494, 492, 3329, 199, 504, 24494, 14, 1000, 14, 15756, 1231, 492, 377, 19622, 6405, 199, 504, 24494, 14, 1188, 492, 19317, 2956, 12, 24164, 998, 63, 2709, 199, 199, 3, 3645, 642, 465, 314, 283, 835, 7, 574, 367, 376, 2225, 315, 282, 16347, 2017, 370, 199, 3, 7198, 367, 465, 5002, 1338, 465, 314, 9827, 883, 5647, 14, 199, 1734, 13387, 1149, 63, 15514, 275, 298, 324, 14136, 2, 199, 199, 3, 22466, 3748, 5162, 2582, 315, 4110, 14, 221, 11842, 367, 199, 3, 4890, 4171, 14, 199, 4896, 27078, 63, 15925, 63, 12644, 63, 9127, 275, 4337, 199, 199, 318, 1104, 14149, 8, 3620, 304, 272, 408, 272, 2670, 376, 5162, 367, 3866, 4110, 27, 746, 437, 29356, 340, 1263, 787, 272, 1911, 14, 221, 1432, 488, 340, 314, 5162, 365, 1686, 14, 272, 408, 272, 340, 13647, 315, 5162, 26, 267, 746, 437, 29356, 480, 14149, 450, 82, 1471, 440, 1395, 10029, 2, 450, 334, 3620, 4641, 272, 340, 7815, 315, 5162, 26, 267, 746, 437, 29356, 480, 14149, 450, 82, 1471, 440, 1395, 6247, 2, 450, 334, 3620, 4641, 421, 199, 533, 437, 29356, 8, 3393, 304, 272, 408, 6579, 687, 666, 626, 1630, 440, 26743, 314, 2225, 15343, 413, 14, 16, 272, 8929, 624, 421, 199, 533, 2832, 9839, 2209, 8, 9839, 547, 304, 272, 408, 16894, 1380, 2337, 365, 949, 3882, 25655, 818, 315, 314, 1245, 1041, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 533, 4914, 354, 363, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 855, 533, 4914, 354, 363, 421, 199, 533, 437, 56, 2209, 8, 3435, 14, 6382, 304, 272, 408, 8458, 1021, 3035, 2863, 1233, 367, 2225, 15343, 3788, 339, 768, 26781, 700, 63, 3620, 26, 710, 14388, 3231, 5162, 367, 2225, 267, 15343, 3788, 339, 768, 26781, 818, 26, 710, 730, 402, 642, 2225, 15343, 1245, 14, 961, 1471, 267, 506, 10087, 315, 9180, 14, 272, 408, 339, 327, 961, 1021, 365, 9006, 12, 880, 652, 1159, 9949, 626, 652, 3181, 1133, 4278, 314, 272, 327, 9006, 1083, 315, 13282, 26, 272, 327, 272, 327, 26324, 26, 5993, 13, 1328, 29, 55, 996, 1789, 339, 700, 63, 3620, 275, 283, 1219, 7, 272, 818, 275, 488, 272, 700, 63, 2302, 275, 283, 1014, 921, 15403, 14, 846, 15, 15165, 15, 1219, 15, 17, 14, 16, 7, 339, 347, 485, 1074, 1385, 8, 277, 12, 2185, 63, 589, 304, 267, 408, 18111, 376, 1919, 340, 314, 818, 315, 314, 2225, 15343, 267, 2368, 1630, 440, 1336, 4052, 365, 1420, 367, 642, 1021, 14, 398, 768, 3536, 2832, 9839, 2209, 26, 3979, 2337, 365, 949, 818, 574, 315, 2185, 63, 589, 737, 1006, 14, 398, 768, 3536, 437, 29356, 26, 3979, 818, 1630, 440, 1336, 14, 267, 408, 267, 818, 275, 2185, 63, 589, 14, 362, 360, 632, 358, 267, 340, 818, 1137, 291, 14, 632, 26, 288, 340, 440, 818, 26, 355, 746, 2832, 9839, 2209, 342, 288, 587, 26, 355, 746, 437, 29356, 8, 490, 283, 6964, 818, 450, 82, 27, 4788, 450, 82, 7, 450, 334, 277, 14, 632, 12, 818, 430, 339, 347, 485, 1222, 6213, 8, 277, 304, 267, 408, 1767, 282, 663, 402, 2225, 15343, 2368, 3035, 314, 267, 5678, 2556, 626, 1471, 506, 315, 4036, 2225, 15343, 267, 1245, 14, 267, 408, 267, 372, 791, 632, 356, 277, 14, 632, 93, 421, 199, 533, 20516, 2354, 8, 785, 304, 272, 408, 18089, 282, 2849, 2225, 315, 376, 2225, 15343, 272, 1056, 14, 961, 1077, 506, 3483, 370, 376, 437, 56, 2017, 909, 315, 1865, 370, 272, 1056, 314, 2225, 14, 339, 768, 7725, 1415, 26, 7480, 314, 2225, 911, 506, 11584, 465, 1415, 267, 1380, 26568, 370, 314, 5420, 402, 314, 2225, 15343, 267, 1056, 14, 272, 768, 466, 1415, 26, 2155, 339, 768, 7725, 2338, 26, 7494, 5002, 1338, 402, 642, 730, 370, 1056, 687, 314, 267, 5420, 14, 7827, 370, 1373, 14, 272, 768, 466, 2338, 26, 1109, 339, 768, 7725, 730, 63, 2302, 26, 710, 5148, 626, 16756, 4052, 314, 2225, 267, 8469, 436, 4212, 652, 365, 6380, 14, 2104, 2893, 12, 1373, 730, 9022, 267, 6144, 10831, 4293, 2954, 282, 13074, 4913, 315, 1300, 1616, 267, 436, 4573, 4293, 2954, 282, 11779, 13, 11875, 1059, 14, 272, 768, 466, 730, 63, 2302, 26, 620, 339, 768, 7725, 5162, 26, 710, 536, 626, 1077, 506, 1627, 370, 642, 5162, 315, 314, 267, 1056, 14, 982, 652, 365, 440, 6841, 12, 282, 7809, 536, 911, 506, 267, 7943, 14, 2104, 2893, 12, 340, 1265, 2934, 370, 1240, 282, 13074, 4913, 267, 574, 283, 84, 2359, 297, 663, 2399, 5162, 370, 626, 574, 14, 982, 2877, 3004, 267, 315, 314, 2011, 1245, 1056, 370, 675, 314, 2011, 5162, 12, 314, 1056, 267, 911, 2449, 370, 506, 4046, 14, 272, 768, 466, 5162, 26, 620, 503, 488, 804, 272, 408, 339, 327, 2779, 1159, 9949, 626, 642, 1021, 3181, 1133, 1172, 4575, 3102, 334, 390, 1159, 2951, 282, 272, 327, 16712, 367, 282, 22219, 402, 3004, 304, 272, 327, 272, 327, 26324, 26, 5993, 13, 1328, 29, 50, 1643, 1644, 339, 347, 636, 826, 721, 277, 12, 730, 63, 2302, 12, 2338, 29, 17, 12, 1415, 29, 797, 12, 5162, 29, 403, 304, 267, 291, 14, 2427, 275, 1415, 267, 291, 14, 835, 275, 2338, 267, 291, 14, 466, 63, 2302, 275, 730, 63, 2302, 267, 291, 14, 3620, 275, 5162, 398, 340, 291, 14, 3620, 365, 440, 488, 26, 288, 1104, 14149, 8, 277, 14, 3620, 9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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bioinformatics-centre/AsmVar
src/AsmvarVarScore/FeatureToScore2.py
2
12476
""" ======================================================== Statistic the SV Stat after AGE Process ======================================================== Author: Shujia Huang & Siyang Liu Date : 2014-03-07 0idx:54:15 """ import sys import re import os import string import numpy as np import matplotlib.pyplot as plt def DrawFig(figureFile, distance, properDepth, imProperDepth, nr, aa, bb, mscore, misprob, aveIden, inbCoe): fig = plt.figure(num=None, figsize=(16, 30), facecolor='w', edgecolor='k') title = ['Distance distribution', 'NRatio', 'Perfect Depth', 'Imperfect depth', '', '', ''] ylabel = ['The position of breakpoint', 'N Ratio of varints', \ 'Perfect Depth', 'Both ImPerfect Depth', 'InbreedCoefficient', \ 'Map score', 'Mismapping Probability' , 'Average Identity', \ 'ProperReadDepth', 'ImProperReadDepth'] al = 0.5 for i, data in enumerate ([distance, nr, aa, bb, inbCoe, mscore, misprob, aveIden, properDepth, imProperDepth ]): plt.subplot(10,2,2 * i + 1) #plt.title(title[i], fontsize=16) P = data[:,0] == 1; N = data[:,0] == 2; X = data[:,0] == 3 plt.scatter(data[:,1][N], data[:,2][N], marker='o', c = 'r', alpha=al, linewidths = 0.1, label = 'Negative(%d)'%len(data[:,1][N])) # Negative plt.scatter(data[:,1][P], data[:,2][P], marker='o', c = 'g', alpha=al, linewidths = 0.1, label = 'Positive(%d)'%len(data[:,1][P])) # Positive plt.scatter(data[:,1][X], data[:,2][X], marker='*', c = 'Y', alpha=al, linewidths = 0.1, label = 'Positive->Negative(%d)' % len(data[:,1][X])) # Positive->Negative plt.legend(loc='upper right') plt.xlim(-10, 50) if i == 9: plt.xlabel('Score', fontsize=16) plt.ylabel(ylabel[i], fontsize=16) plt.subplot(10, 2, 2*i + 2) NEW = data[:,0] == 0 good = data[:,1][NEW] >= VQ_CUTOFF bad = data[:,1][NEW] < VQ_CUTOFF plt.scatter(data[:,1][NEW][bad], data[:,2][NEW][bad], marker='o', c = 'm', alpha=al, linewidths = 0.1, label = 'bad(%d)' % len(data[:,1][NEW][bad])) # bad plt.scatter(data[:,1][NEW][good], data[:,2][NEW][good], marker='o', c = 'b', alpha=al, linewidths = 0.1, label = 'good(%d)' % len(data[:,1][NEW][good])) # good plt.xlim(-3, 30) plt.legend(loc='upper right') if i == 9: plt.xlabel('Score', fontsize=16) fig.savefig(figureFile + '.png') #fig.savefig(figureFile + '.pdf') def DrawPhredScale (figureFile, phredScal): fig = plt.figure() ylabel = ['Phred Scale'] for i, data in enumerate ([phredScal ]): plt.subplot(2, 1, 2 * i + 1) P = data[:,0] == 1; N = data[:,0] == 2; X = data[:,0] == 3 plt.scatter(data[:,1][N], data[:,2][N], marker='o', c = 'r', alpha=0.5, linewidths = 0, label = 'Negative(%d)'%len(data[:,1][N])) # Negative plt.scatter(data[:,1][P], data[:,2][P], marker='o', c = 'g', alpha=0.5, linewidths = 0, label = 'Positive(%d)'%len(data[:,1][P])) # Positive plt.scatter(data[:,1][X], data[:,2][X], marker='o', c = 'Y', alpha=0.5, linewidths = 0, label = 'Positive->Negative(%d)' % len(data[:,1][X])) # Positive->Negative plt.legend(loc='upper left') plt.ylabel(ylabel[i], fontsize=16) plt.subplot(2, 1, 2*i + 2) NEW = data[:,0] == 0 good = data[:,1][NEW] >= VQ_CUTOFF bad = data[:,1][NEW] < VQ_CUTOFF plt.scatter(data[:,1][NEW][bad] , data[:,2][NEW][bad] , marker='o', c = 'm', alpha=0.5, linewidths = 0, label = 'bad(%d)' % len(data[:,1][NEW][bad])) # bad plt.scatter(data[:,1][NEW][good], data[:,2][NEW][good], marker='o', c = 'b', alpha=0.5, linewidths = 0, label = 'good(%d)' % len(data[:,1][NEW][good])) # good plt.legend(loc='upper left') plt.xlabel('Score' , fontsize=16) plt.ylabel(ylabel[i], fontsize=16) fig.savefig(figureFile + '.png') #fig.savefig(figureFile + '.pdf') def Accum (data, isBig = False): tmpD= data k = sorted(tmpD.keys(), key = lambda d: float(d)) dat = [] for i in range(len(k)): if isBig: for j in range(i,len(k)): tmpD[k[i]][1] += tmpD[k[j]][0] else: for j in range(i+1): tmpD[k[i]][1] += tmpD[k[j]][0] dat.append([float(k[i]), float(tmpD[k[i]][0]), float(tmpD[k[i]][1]) ]) return dat def SampleFaLen (faLenFile): if faLenFile[-3:] == '.gz': I = os.popen('gzip -dc %s' % faLenFile) else : I = open(faLenFile) data = {} while 1: lines = I.readlines (100000) if not lines: break for line in lines: col = line.strip('\n').split() data[col[0]] = string.atoi(col[1]) I.close() return data def LoadFaLen (faLenLstFile): data = {} I = open (faLenLstFile) for line in I.readlines(): if len(line.strip('\n').split()) != 2: raise ValueError('[ERROR] The format of Fa length list maybe not right. It could just be: "sample FalenghtFile", but found',line) sampleId, fileName = line.strip('\n').split() if sampleId not in data: data[sampleId] = {} data[sampleId] = SampleFaLen(fileName) I.close() return data def main (argv): qFaLen = LoadFaLen(argv[1]) figPrefix = 'test' if len(argv) > 2: figPrefix = argv[2] if argv[0][-3:] == '.gz': I = os.popen('gzip -dc %s' % argv[0]) else: I = open (argv[0]) s, annotations, mark = set(), [], [] print '#Chr\tPosition\tDistance\tLeftIden\tRightIden\tAveIden\tN-Ratio\tAA' while 1: # VCF format lines = I.readlines(100000) if not lines: break for line in lines: col = line.strip('\n').split() if re.search(r'^#CHROM', line): col2sam = { i+9:sam for i,sam in enumerate(col[9:]) } if re.search(r'^#', line): continue key = col[0] + ':' + col[1] if key in s: continue s.add(key) #if re.search(r'^PASS', col[6]): continue #if not re.search(r'_TRAIN_SITE', col[7]): continue #if not re.search(r'^PASS', col[6]): continue isbad = False for i, sample in enumerate (col[9:]): if re.search(r'NULL', sample): isbad = True if isbad: continue fmat = { k:i for i,k in enumerate(col[8].split(':')) } if 'VS' not in fmat or 'QR' not in fmat: continue if 'AGE' not in fmat: continue if len(annotations) == 0: annotations = [[] for _ in col[9:] ] vcfinfo = { d.split('=')[0]: d.split('=')[1] for d in col[7].split(';') if len(d.split('=')) == 2 } vq = string.atof(vcfinfo['VQ']) inb = string.atof(vcfinfo['InbCoeff']) if ('POSITIVE_TRAIN_SITE' in col[7]) and ('NEGATIVE_TRAIN_SITE' in col[7]): mark.append([3, vq, inb]) elif 'POSITIVE_TRAIN_SITE' in col[7]: mark.append([1, vq, inb]) elif 'NEGATIVE_TRAIN_SITE' in col[7]: mark.append([2, vq, inb]) else: mark.append([0, vq, inb]) # GT:AA:AE:FN:MIP:MS:QR:RR:VS:VT for i, sample in enumerate (col[9:]): sampleId = col2sam[9+i] field = sample.split(':') if sample == './.' or len(field) < fmat['QR'] + 1 or field[fmat['QR']].split(',')[-1] == '.' or field[fmat['AS']] == '.': annotations[i].append([0, 0, 0, 0, 0, 0, 0, 0, 0]) continue qr = field[fmat['QR']].split(',')[-1] qregion = np.array(qr.split('-')) if len(qregion) > 3: qId = qregion[0] + '-' + qregion[1] else : qId = qregion[0] qSta = string.atoi(qregion[-2]) qEnd = string.atoi(qregion[-1]) if sampleId not in qFaLen: raise ValueError ('[ERROR] The sample name $s(in vcf) is not in the name of Fa list.' % sampleId) if qId not in qFaLen[sampleId]: raise ValueError ('[ERROR]', qId, 'is not been found in file', opt.qFalen, '\n') qSta= int(qSta * 100 / qFaLen[sampleId][qId] + 0.5) qEnd= int(qEnd * 100 / qFaLen[sampleId][qId] + 0.5) if qSta > 100 or qEnd > 100: raise ValueError ('[ERROR] Query size Overflow! sample: %s; scaffold: %s' % (sampleId, qId)) leg = qSta if 100 - qEnd < qSta: leg = qEnd nn = string.atof(sample.split(':')[fmat['NR']]) n = round(1000 * nn) / 10.0 # N ratio alt = string.atoi(sample.split(':')[fmat['AA']].split(',')[1]) # Alternate perfect bot = string.atoi(sample.split(':')[fmat['AA']].split(',')[3]) # Both imperfect pro, ipr = [0,0] ms = string.atoi(sample.split(':')[fmat['AS']]) # Mapping score mip = string.atof(sample.split(':')[fmat['MS']]) # Mismapping probability if sample.split(':')[fmat['AGE']] != '.': aveI = string.atoi(sample.split(':')[fmat['AGE']].split(',')[3]) # ave_iden in AGE else: aveI = 0 annotations[i].append([leg, n, alt, bot, pro, ipr, ms, mip, aveI]) I.close() print >> sys.stderr, '# Number of Positions: %d' % len(mark) if len(mark) != len(annotations[0]): raise ValueError ('[ERROR] The size is not match mark=%d, annotations=%d!' % (len(mark), len(annotations))) annotations = np.array(annotations); sampleNum = len(annotations) data, distance, properDepth, imProperDepth, nr, aa, bb, mscore, misprob, aveIden = [],[],[],[],[],[],[],[],[],[] inbreedCoe, phredScal = [], [] for i in range(len(annotations[0])): anno = np.array([annotations[s][i] for s in range(sampleNum) if len(annotations[s][i][annotations[s][i]!=0]) > 0 ]) # each person in the same position score = np.array([annotations[s][i][-3] for s in range(sampleNum) if annotations[s][i][-3] > 0 ]) msprob = np.array([annotations[s][i][-2] for s in range(sampleNum) if annotations[s][i][-3] > 0 ]) phred = -10 * np.log10(1.0 - score.sum() / np.sum(score/(1.0 - msprob))) # Phred scale if len(anno) == 0: continue leg, n, alt, bot, pro,ipr, ms, mip, aveI = np.median(anno, axis=0) distance.append ([mark[i][0], mark[i][1], leg ]) properDepth.append ([mark[i][0], mark[i][1], pro ]) imProperDepth.append ([mark[i][0], mark[i][1], ipr ]) nr.append ([mark[i][0], mark[i][1], n ]) aa.append ([mark[i][0], mark[i][1], alt ]) bb.append ([mark[i][0], mark[i][1], bot ]) mscore.append ([mark[i][0], mark[i][1], ms ]) misprob.append ([mark[i][0], mark[i][1], mip ]) aveIden.append ([mark[i][0], mark[i][1], aveI]) phredScal.append ([mark[i][0], mark[i][1], phred]) inbreedCoe.append ([mark[i][0], mark[i][1], mark[i][2]]) data.append([leg, alt, pro, ipr, n, bot]) print mark[i][0], mark[i][1], mark[i][2], '\t', leg, '\t', pro, '\t', ipr,'\t', n, '\t', alt, '\t', bot data = np.array(data) print >> sys.stderr, '\nPosition\tALTernatePerfect\tLeftIdentity\tRightIdentity\tAveIden\tNRatio\tBothImperfect' print >> sys.stderr, 'Means: ', data.mean(axis=0), '\nstd : ', data.std(axis=0), '\nMedian: ', np.median(data, axis=0) print >> sys.stderr, '25 Percentile:', np.percentile(data, 25,axis=0), '\n50 Percentile:', np.percentile(data, 50,axis=0), '\n75 Percentile:', np.percentile(data, 75,axis=0) DrawFig(figPrefix, \ np.array (distance ), \ np.array (properDepth ), \ np.array (imProperDepth), \ np.array (nr ), \ np.array (aa ), \ np.array (bb ), \ np.array (mscore ), \ np.array (misprob ), \ np.array (aveIden ), \ np.array (inbreedCoe ) ) DrawPhredScale (figPrefix + '.phred', np.array(phredScal)) if __name__ == '__main__': VQ_CUTOFF = 3.0 main(sys.argv[1:])
mit
[ 624, 199, 12813, 763, 199, 3391, 19940, 314, 14056, 27673, 2410, 437, 4962, 7132, 199, 12813, 763, 199, 5949, 26, 5244, 17189, 4674, 869, 85, 621, 1253, 428, 73, 11912, 24157, 85, 199, 2506, 221, 520, 6927, 13, 1644, 13, 1780, 378, 2996, 26, 1477, 26, 1046, 199, 624, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 1059, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 318, 17813, 38, 528, 8, 8941, 1173, 12, 6033, 12, 5576, 14125, 12, 3416, 919, 529, 14125, 12, 14762, 12, 18319, 12, 14027, 12, 333, 3397, 12, 3201, 6101, 12, 282, 432, 17062, 12, 315, 66, 967, 69, 304, 18407, 6085, 275, 4488, 14, 8941, 8, 1507, 29, 403, 12, 6085, 890, 2687, 975, 12, 4233, 395, 8870, 2326, 534, 87, 297, 6275, 2326, 534, 75, 358, 272, 2538, 221, 275, 788, 10076, 4084, 297, 283, 46, 13971, 297, 283, 12387, 449, 1487, 13316, 297, 283, 8499, 31740, 449, 5818, 297, 3260, 3260, 28696, 272, 612, 1302, 275, 788, 1918, 3421, 402, 17944, 297, 283, 46, 820, 32736, 402, 2729, 13141, 297, 971, 1598, 283, 12387, 449, 1487, 13316, 297, 283, 18088, 473, 77, 12387, 449, 1487, 13316, 297, 283, 607, 66, 3798, 967, 21069, 297, 971, 1598, 283, 2956, 5396, 297, 283, 5829, 4745, 22770, 3616, 7, 221, 2360, 283, 17400, 22034, 297, 971, 1598, 283, 919, 529, 3284, 14125, 297, 283, 16221, 919, 529, 3284, 14125, 418, 272, 741, 275, 378, 14, 21, 272, 367, 284, 12, 666, 315, 3874, 7287, 5590, 12, 14762, 12, 18319, 12, 14027, 12, 315, 66, 967, 69, 12, 333, 3397, 12, 3201, 6101, 12, 282, 432, 17062, 12, 5576, 14125, 12, 3416, 919, 529, 14125, 1622, 304, 267, 4488, 14, 13334, 8, 709, 12, 18, 12, 18, 627, 284, 435, 413, 9, 267, 327, 6003, 14, 1213, 8, 1213, 59, 73, 467, 19740, 29, 975, 9, 267, 510, 275, 666, 3981, 16, 61, 508, 413, 27, 653, 275, 666, 3981, 16, 61, 508, 499, 27, 1323, 275, 666, 3981, 16, 61, 508, 650, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 46, 467, 666, 3981, 18, 1527, 46, 467, 3608, 534, 79, 297, 286, 275, 283, 82, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 15562, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 46, 2459, 327, 32548, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 48, 467, 666, 3981, 18, 1527, 48, 467, 3608, 534, 79, 297, 286, 275, 283, 71, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 6951, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 48, 2459, 327, 30245, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 56, 467, 666, 3981, 18, 1527, 56, 467, 3608, 534, 7693, 286, 275, 283, 57, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 6951, 5118, 15562, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 56, 2459, 327, 30245, 5118, 15562, 267, 4488, 14, 10231, 8, 2102, 534, 4142, 2451, 358, 267, 4488, 14, 18512, 2801, 709, 12, 5238, 9, 267, 340, 284, 508, 1749, 26, 4488, 14, 14168, 360, 12642, 297, 19740, 29, 975, 9, 267, 4488, 14, 13849, 8, 13849, 59, 73, 467, 19740, 29, 975, 9, 398, 4488, 14, 13334, 8, 709, 12, 499, 12, 499, 10, 73, 435, 499, 9, 267, 18689, 221, 275, 666, 3981, 16, 61, 508, 378, 267, 6954, 275, 666, 3981, 17, 1527, 11365, 61, 2356, 812, 49, 63, 24678, 7517, 267, 4875, 221, 275, 666, 3981, 17, 1527, 11365, 61, 665, 221, 812, 49, 63, 24678, 7517, 398, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 11365, 1527, 4087, 467, 666, 3981, 18, 1527, 11365, 1527, 4087, 467, 3608, 534, 79, 297, 286, 275, 283, 77, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 4087, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 11365, 1527, 4087, 2459, 327, 4875, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 11365, 1527, 8302, 467, 666, 3981, 18, 1527, 11365, 1527, 8302, 467, 3608, 534, 79, 297, 286, 275, 283, 66, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 8302, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 11365, 1527, 8302, 2459, 327, 6954, 267, 4488, 14, 18512, 2801, 19, 12, 4233, 9, 267, 4488, 14, 10231, 8, 2102, 534, 4142, 2451, 358, 267, 340, 284, 508, 1749, 26, 4488, 14, 14168, 360, 12642, 297, 19740, 29, 975, 9, 339, 6085, 14, 19556, 8, 8941, 1173, 435, 1987, 4524, 358, 272, 327, 592, 14, 19556, 8, 8941, 1173, 435, 1987, 5607, 358, 199, 199, 318, 17813, 5663, 581, 9944, 334, 8941, 1173, 12, 3945, 581, 10249, 304, 339, 6085, 275, 4488, 14, 8941, 342, 339, 612, 1302, 275, 788, 5663, 581, 22869, 418, 272, 367, 284, 12, 666, 315, 3874, 7287, 838, 581, 10249, 1622, 304, 267, 4488, 14, 13334, 8, 18, 12, 413, 12, 499, 627, 284, 435, 413, 9, 267, 510, 275, 666, 3981, 16, 61, 508, 413, 27, 653, 275, 666, 3981, 16, 61, 508, 499, 27, 1323, 275, 666, 3981, 16, 61, 508, 650, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 46, 467, 666, 3981, 18, 1527, 46, 467, 3608, 534, 79, 297, 286, 275, 283, 82, 297, 5131, 29, 16, 14, 21, 12, 21213, 83, 275, 378, 12, 1768, 275, 283, 15562, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 46, 2459, 327, 32548, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 48, 467, 666, 3981, 18, 1527, 48, 467, 3608, 534, 79, 297, 286, 275, 283, 71, 297, 5131, 29, 16, 14, 21, 12, 21213, 83, 275, 378, 12, 1768, 275, 283, 6951, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 48, 2459, 327, 30245, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 56, 467, 666, 3981, 18, 1527, 56, 467, 3608, 534, 79, 297, 286, 275, 283, 57, 297, 5131, 29, 16 ]
[ 199, 12813, 763, 199, 3391, 19940, 314, 14056, 27673, 2410, 437, 4962, 7132, 199, 12813, 763, 199, 5949, 26, 5244, 17189, 4674, 869, 85, 621, 1253, 428, 73, 11912, 24157, 85, 199, 2506, 221, 520, 6927, 13, 1644, 13, 1780, 378, 2996, 26, 1477, 26, 1046, 199, 624, 199, 646, 984, 199, 646, 295, 199, 646, 747, 199, 646, 1059, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 318, 17813, 38, 528, 8, 8941, 1173, 12, 6033, 12, 5576, 14125, 12, 3416, 919, 529, 14125, 12, 14762, 12, 18319, 12, 14027, 12, 333, 3397, 12, 3201, 6101, 12, 282, 432, 17062, 12, 315, 66, 967, 69, 304, 18407, 6085, 275, 4488, 14, 8941, 8, 1507, 29, 403, 12, 6085, 890, 2687, 975, 12, 4233, 395, 8870, 2326, 534, 87, 297, 6275, 2326, 534, 75, 358, 272, 2538, 221, 275, 788, 10076, 4084, 297, 283, 46, 13971, 297, 283, 12387, 449, 1487, 13316, 297, 283, 8499, 31740, 449, 5818, 297, 3260, 3260, 28696, 272, 612, 1302, 275, 788, 1918, 3421, 402, 17944, 297, 283, 46, 820, 32736, 402, 2729, 13141, 297, 971, 1598, 283, 12387, 449, 1487, 13316, 297, 283, 18088, 473, 77, 12387, 449, 1487, 13316, 297, 283, 607, 66, 3798, 967, 21069, 297, 971, 1598, 283, 2956, 5396, 297, 283, 5829, 4745, 22770, 3616, 7, 221, 2360, 283, 17400, 22034, 297, 971, 1598, 283, 919, 529, 3284, 14125, 297, 283, 16221, 919, 529, 3284, 14125, 418, 272, 741, 275, 378, 14, 21, 272, 367, 284, 12, 666, 315, 3874, 7287, 5590, 12, 14762, 12, 18319, 12, 14027, 12, 315, 66, 967, 69, 12, 333, 3397, 12, 3201, 6101, 12, 282, 432, 17062, 12, 5576, 14125, 12, 3416, 919, 529, 14125, 1622, 304, 267, 4488, 14, 13334, 8, 709, 12, 18, 12, 18, 627, 284, 435, 413, 9, 267, 327, 6003, 14, 1213, 8, 1213, 59, 73, 467, 19740, 29, 975, 9, 267, 510, 275, 666, 3981, 16, 61, 508, 413, 27, 653, 275, 666, 3981, 16, 61, 508, 499, 27, 1323, 275, 666, 3981, 16, 61, 508, 650, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 46, 467, 666, 3981, 18, 1527, 46, 467, 3608, 534, 79, 297, 286, 275, 283, 82, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 15562, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 46, 2459, 327, 32548, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 48, 467, 666, 3981, 18, 1527, 48, 467, 3608, 534, 79, 297, 286, 275, 283, 71, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 6951, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 48, 2459, 327, 30245, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 56, 467, 666, 3981, 18, 1527, 56, 467, 3608, 534, 7693, 286, 275, 283, 57, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 6951, 5118, 15562, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 56, 2459, 327, 30245, 5118, 15562, 267, 4488, 14, 10231, 8, 2102, 534, 4142, 2451, 358, 267, 4488, 14, 18512, 2801, 709, 12, 5238, 9, 267, 340, 284, 508, 1749, 26, 4488, 14, 14168, 360, 12642, 297, 19740, 29, 975, 9, 267, 4488, 14, 13849, 8, 13849, 59, 73, 467, 19740, 29, 975, 9, 398, 4488, 14, 13334, 8, 709, 12, 499, 12, 499, 10, 73, 435, 499, 9, 267, 18689, 221, 275, 666, 3981, 16, 61, 508, 378, 267, 6954, 275, 666, 3981, 17, 1527, 11365, 61, 2356, 812, 49, 63, 24678, 7517, 267, 4875, 221, 275, 666, 3981, 17, 1527, 11365, 61, 665, 221, 812, 49, 63, 24678, 7517, 398, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 11365, 1527, 4087, 467, 666, 3981, 18, 1527, 11365, 1527, 4087, 467, 3608, 534, 79, 297, 286, 275, 283, 77, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 4087, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 11365, 1527, 4087, 2459, 327, 4875, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 11365, 1527, 8302, 467, 666, 3981, 18, 1527, 11365, 1527, 8302, 467, 3608, 534, 79, 297, 286, 275, 283, 66, 297, 5131, 29, 279, 12, 21213, 83, 275, 378, 14, 17, 12, 1768, 275, 283, 8302, 4042, 68, 3171, 450, 822, 8, 576, 3981, 17, 1527, 11365, 1527, 8302, 2459, 327, 6954, 267, 4488, 14, 18512, 2801, 19, 12, 4233, 9, 267, 4488, 14, 10231, 8, 2102, 534, 4142, 2451, 358, 267, 340, 284, 508, 1749, 26, 4488, 14, 14168, 360, 12642, 297, 19740, 29, 975, 9, 339, 6085, 14, 19556, 8, 8941, 1173, 435, 1987, 4524, 358, 272, 327, 592, 14, 19556, 8, 8941, 1173, 435, 1987, 5607, 358, 199, 199, 318, 17813, 5663, 581, 9944, 334, 8941, 1173, 12, 3945, 581, 10249, 304, 339, 6085, 275, 4488, 14, 8941, 342, 339, 612, 1302, 275, 788, 5663, 581, 22869, 418, 272, 367, 284, 12, 666, 315, 3874, 7287, 838, 581, 10249, 1622, 304, 267, 4488, 14, 13334, 8, 18, 12, 413, 12, 499, 627, 284, 435, 413, 9, 267, 510, 275, 666, 3981, 16, 61, 508, 413, 27, 653, 275, 666, 3981, 16, 61, 508, 499, 27, 1323, 275, 666, 3981, 16, 61, 508, 650, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 46, 467, 666, 3981, 18, 1527, 46, 467, 3608, 534, 79, 297, 286, 275, 283, 82, 297, 5131, 29, 16, 14, 21, 12, 21213, 83, 275, 378, 12, 1768, 275, 283, 15562, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 46, 2459, 327, 32548, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 48, 467, 666, 3981, 18, 1527, 48, 467, 3608, 534, 79, 297, 286, 275, 283, 71, 297, 5131, 29, 16, 14, 21, 12, 21213, 83, 275, 378, 12, 1768, 275, 283, 6951, 4042, 68, 3171, 5, 552, 8, 576, 3981, 17, 1527, 48, 2459, 327, 30245, 267, 4488, 14, 13512, 8, 576, 3981, 17, 1527, 56, 467, 666, 3981, 18, 1527, 56,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rspavel/spack
var/spack/repos/builtin/packages/r-shinyfiles/package.py
5
1173
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class RShinyfiles(RPackage): """Provides functionality for client-side navigation of the server side file system in shiny apps. In case the app is running locally this gives the user direct access to the file system without the need to "download" files to a temporary location. Both file and folder selection as well as file saving is available.""" homepage = "https://github.com/thomasp85/shinyFiles" url = "https://cloud.r-project.org/src/contrib/shinyFiles_0.7.3.tar.gz" list_url = "https://cloud.r-project.org/src/contrib/Archive/shinyFiles" version('0.7.3', sha256='710c8a6191aaf336379bc748daff1160d0d2858e2aee0d98e2ad48e7121d5a05') depends_on('r-htmltools', type=('build', 'run')) depends_on('r-jsonlite', type=('build', 'run')) depends_on('r-shiny@1.1.0:', type=('build', 'run')) depends_on('r-fs@1.2.6:', type=('build', 'run')) depends_on('r-tibble@1.4.2:', type=('build', 'run'))
lgpl-2.1
[ 3, 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 199, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 820, 2662, 8952, 1725, 8, 50, 8599, 304, 272, 408, 17473, 9330, 367, 1890, 13, 2441, 19191, 402, 314, 1654, 5366, 272, 570, 2656, 315, 1033, 8952, 8686, 14, 1010, 1930, 314, 1145, 365, 3879, 17738, 642, 10557, 272, 314, 922, 4125, 2879, 370, 314, 570, 2656, 1928, 314, 1929, 370, 298, 4249, 2, 272, 1584, 370, 282, 7937, 2909, 14, 17650, 570, 436, 4922, 7267, 465, 5521, 465, 272, 570, 13369, 365, 2808, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 273, 676, 20222, 2426, 15, 609, 8952, 5535, 2, 272, 1166, 420, 275, 298, 2859, 921, 4091, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 609, 8952, 5535, 63, 16, 14, 23, 14, 19, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 4091, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 13042, 15, 609, 8952, 5535, 2, 339, 1015, 360, 16, 14, 23, 14, 19, 297, 7793, 3912, 534, 26072, 67, 24, 65, 22, 12632, 31498, 12135, 12015, 3776, 18770, 983, 556, 845, 2259, 68, 16, 68, 1651, 2010, 69, 18, 65, 1024, 16, 68, 2905, 69, 18, 350, 2006, 69, 23, 10753, 68, 21, 65, 1717, 358, 339, 8350, 63, 265, 360, 82, 13, 1360, 2537, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 1001, 5333, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 609, 8952, 32, 17, 14, 17, 14, 16, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 2319, 32, 17, 14, 18, 14, 22, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 280, 20541, 32, 17, 14, 20, 14, 18, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6171, 13, 13934, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 436, 1163, 199, 3, 428, 1389, 7290, 23493, 14, 1666, 314, 2746, 13, 1896, 5877, 570, 367, 2436, 14, 199, 3, 199, 3, 6988, 19596, 13, 3761, 13, 7544, 26, 334, 28993, 13, 18, 14, 16, 1549, 10697, 9, 199, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 820, 2662, 8952, 1725, 8, 50, 8599, 304, 272, 408, 17473, 9330, 367, 1890, 13, 2441, 19191, 402, 314, 1654, 5366, 272, 570, 2656, 315, 1033, 8952, 8686, 14, 1010, 1930, 314, 1145, 365, 3879, 17738, 642, 10557, 272, 314, 922, 4125, 2879, 370, 314, 570, 2656, 1928, 314, 1929, 370, 298, 4249, 2, 272, 1584, 370, 282, 7937, 2909, 14, 17650, 570, 436, 4922, 7267, 465, 5521, 465, 272, 570, 13369, 365, 2808, 1041, 339, 26586, 275, 298, 2859, 921, 5031, 14, 957, 15, 273, 676, 20222, 2426, 15, 609, 8952, 5535, 2, 272, 1166, 420, 275, 298, 2859, 921, 4091, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 609, 8952, 5535, 63, 16, 14, 23, 14, 19, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 4091, 14, 82, 13, 1715, 14, 1308, 15, 2164, 15, 2828, 15, 13042, 15, 609, 8952, 5535, 2, 339, 1015, 360, 16, 14, 23, 14, 19, 297, 7793, 3912, 534, 26072, 67, 24, 65, 22, 12632, 31498, 12135, 12015, 3776, 18770, 983, 556, 845, 2259, 68, 16, 68, 1651, 2010, 69, 18, 65, 1024, 16, 68, 2905, 69, 18, 350, 2006, 69, 23, 10753, 68, 21, 65, 1717, 358, 339, 8350, 63, 265, 360, 82, 13, 1360, 2537, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 1001, 5333, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 609, 8952, 32, 17, 14, 17, 14, 16, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 2319, 32, 17, 14, 18, 14, 22, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 272, 8350, 63, 265, 360, 82, 13, 280, 20541, 32, 17, 14, 20, 14, 18, 6536, 730, 7782, 1506, 297, 283, 1065, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
40223151/2014c2g9
exts/wsgi/static/Brython2.1.0-20140419-113919/Lib/xml/dom/minidom.py
727
66854
"""Simple implementation of the Level 1 DOM. Namespaces and other minor Level 2 features are also supported. parse("foo.xml") parseString("<foo><bar/></foo>") Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces """ import io import xml.dom from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg from xml.dom.minicompat import * from xml.dom.xmlbuilder import DOMImplementationLS, DocumentLS # This is used by the ID-cache invalidation checks; the list isn't # actually complete, since the nodes being checked will never be the # DOCUMENT_NODE or DOCUMENT_FRAGMENT_NODE. (The node being checked is # the node being added or removed, not the node being modified.) # _nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE, xml.dom.Node.ENTITY_REFERENCE_NODE) class Node(xml.dom.Node): namespaceURI = None # this is non-null only for elements and attributes parentNode = None ownerDocument = None nextSibling = None previousSibling = None prefix = EMPTY_PREFIX # non-null only for NS elements and attributes def __bool__(self): return True def toxml(self, encoding=None): return self.toprettyxml("", "", encoding) def toprettyxml(self, indent="\t", newl="\n", encoding=None): if encoding is None: writer = io.StringIO() else: writer = io.TextIOWrapper(io.BytesIO(), encoding=encoding, errors="xmlcharrefreplace", newline='\n') if self.nodeType == Node.DOCUMENT_NODE: # Can pass encoding only to document, to put it into XML header self.writexml(writer, "", indent, newl, encoding) else: self.writexml(writer, "", indent, newl) if encoding is None: return writer.getvalue() else: return writer.detach().getvalue() def hasChildNodes(self): return bool(self.childNodes) def _get_childNodes(self): return self.childNodes def _get_firstChild(self): if self.childNodes: return self.childNodes[0] def _get_lastChild(self): if self.childNodes: return self.childNodes[-1] def insertBefore(self, newChild, refChild): if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: for c in tuple(newChild.childNodes): self.insertBefore(c, refChild) ### The DOM does not clearly specify what to return in this case return newChild if newChild.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(newChild), repr(self))) if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) if refChild is None: self.appendChild(newChild) else: try: index = self.childNodes.index(refChild) except ValueError: raise xml.dom.NotFoundErr() if newChild.nodeType in _nodeTypes_with_children: _clear_id_cache(self) self.childNodes.insert(index, newChild) newChild.nextSibling = refChild refChild.previousSibling = newChild if index: node = self.childNodes[index-1] node.nextSibling = newChild newChild.previousSibling = node else: newChild.previousSibling = None newChild.parentNode = self return newChild def appendChild(self, node): if node.nodeType == self.DOCUMENT_FRAGMENT_NODE: for c in tuple(node.childNodes): self.appendChild(c) ### The DOM does not clearly specify what to return in this case return node if node.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) elif node.nodeType in _nodeTypes_with_children: _clear_id_cache(self) if node.parentNode is not None: node.parentNode.removeChild(node) _append_child(self, node) node.nextSibling = None return node def replaceChild(self, newChild, oldChild): if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE: refChild = oldChild.nextSibling self.removeChild(oldChild) return self.insertBefore(newChild, refChild) if newChild.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(newChild), repr(self))) if newChild is oldChild: return if newChild.parentNode is not None: newChild.parentNode.removeChild(newChild) try: index = self.childNodes.index(oldChild) except ValueError: raise xml.dom.NotFoundErr() self.childNodes[index] = newChild newChild.parentNode = self oldChild.parentNode = None if (newChild.nodeType in _nodeTypes_with_children or oldChild.nodeType in _nodeTypes_with_children): _clear_id_cache(self) newChild.nextSibling = oldChild.nextSibling newChild.previousSibling = oldChild.previousSibling oldChild.nextSibling = None oldChild.previousSibling = None if newChild.previousSibling: newChild.previousSibling.nextSibling = newChild if newChild.nextSibling: newChild.nextSibling.previousSibling = newChild return oldChild def removeChild(self, oldChild): try: self.childNodes.remove(oldChild) except ValueError: raise xml.dom.NotFoundErr() if oldChild.nextSibling is not None: oldChild.nextSibling.previousSibling = oldChild.previousSibling if oldChild.previousSibling is not None: oldChild.previousSibling.nextSibling = oldChild.nextSibling oldChild.nextSibling = oldChild.previousSibling = None if oldChild.nodeType in _nodeTypes_with_children: _clear_id_cache(self) oldChild.parentNode = None return oldChild def normalize(self): L = [] for child in self.childNodes: if child.nodeType == Node.TEXT_NODE: if not child.data: # empty text node; discard if L: L[-1].nextSibling = child.nextSibling if child.nextSibling: child.nextSibling.previousSibling = child.previousSibling child.unlink() elif L and L[-1].nodeType == child.nodeType: # collapse text node node = L[-1] node.data = node.data + child.data node.nextSibling = child.nextSibling if child.nextSibling: child.nextSibling.previousSibling = node child.unlink() else: L.append(child) else: L.append(child) if child.nodeType == Node.ELEMENT_NODE: child.normalize() self.childNodes[:] = L def cloneNode(self, deep): return _clone_node(self, deep, self.ownerDocument or self) def isSupported(self, feature, version): return self.ownerDocument.implementation.hasFeature(feature, version) def _get_localName(self): # Overridden in Element and Attr where localName can be Non-Null return None # Node interfaces from Level 3 (WD 9 April 2002) def isSameNode(self, other): return self is other def getInterface(self, feature): if self.isSupported(feature, None): return self else: return None # The "user data" functions use a dictionary that is only present # if some user data has been set, so be careful not to assume it # exists. def getUserData(self, key): try: return self._user_data[key][0] except (AttributeError, KeyError): return None def setUserData(self, key, data, handler): old = None try: d = self._user_data except AttributeError: d = {} self._user_data = d if key in d: old = d[key][0] if data is None: # ignore handlers passed for None handler = None if old is not None: del d[key] else: d[key] = (data, handler) return old def _call_user_data_handler(self, operation, src, dst): if hasattr(self, "_user_data"): for key, (data, handler) in list(self._user_data.items()): if handler is not None: handler.handle(operation, key, data, src, dst) # minidom-specific API: def unlink(self): self.parentNode = self.ownerDocument = None if self.childNodes: for child in self.childNodes: child.unlink() self.childNodes = NodeList() self.previousSibling = None self.nextSibling = None # A Node is its own context manager, to ensure that an unlink() call occurs. # This is similar to how a file object works. def __enter__(self): return self def __exit__(self, et, ev, tb): self.unlink() defproperty(Node, "firstChild", doc="First child node, or None.") defproperty(Node, "lastChild", doc="Last child node, or None.") defproperty(Node, "localName", doc="Namespace-local name of this node.") def _append_child(self, node): # fast path with less checks; usable by DOM builders if careful childNodes = self.childNodes if childNodes: last = childNodes[-1] node.previousSibling = last last.nextSibling = node childNodes.append(node) node.parentNode = self def _in_document(node): # return True iff node is part of a document tree while node is not None: if node.nodeType == Node.DOCUMENT_NODE: return True node = node.parentNode return False def _write_data(writer, data): "Writes datachars to writer." if data: data = data.replace("&", "&amp;").replace("<", "&lt;"). \ replace("\"", "&quot;").replace(">", "&gt;") writer.write(data) def _get_elements_by_tagName_helper(parent, name, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE and \ (name == "*" or node.tagName == name): rc.append(node) _get_elements_by_tagName_helper(node, name, rc) return rc def _get_elements_by_tagName_ns_helper(parent, nsURI, localName, rc): for node in parent.childNodes: if node.nodeType == Node.ELEMENT_NODE: if ((localName == "*" or node.localName == localName) and (nsURI == "*" or node.namespaceURI == nsURI)): rc.append(node) _get_elements_by_tagName_ns_helper(node, nsURI, localName, rc) return rc class DocumentFragment(Node): nodeType = Node.DOCUMENT_FRAGMENT_NODE nodeName = "#document-fragment" nodeValue = None attributes = None parentNode = None _child_node_types = (Node.ELEMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.NOTATION_NODE) def __init__(self): self.childNodes = NodeList() class Attr(Node): __slots__=('_name', '_value', 'namespaceURI', '_prefix', 'childNodes', '_localName', 'ownerDocument', 'ownerElement') nodeType = Node.ATTRIBUTE_NODE attributes = None specified = False _is_id = False _child_node_types = (Node.TEXT_NODE, Node.ENTITY_REFERENCE_NODE) def __init__(self, qName, namespaceURI=EMPTY_NAMESPACE, localName=None, prefix=None): self.ownerElement = None self._name = qName self.namespaceURI = namespaceURI self._prefix = prefix self.childNodes = NodeList() # Add the single child node that represents the value of the attr self.childNodes.append(Text()) # nodeValue and value are set elsewhere def _get_localName(self): try: return self._localName except AttributeError: return self.nodeName.split(":", 1)[-1] def _get_name(self): return self.name def _get_specified(self): return self.specified def _get_name(self): return self._name def _set_name(self, value): self._name = value if self.ownerElement is not None: _clear_id_cache(self.ownerElement) nodeName = name = property(_get_name, _set_name) def _get_value(self): return self._value def _set_value(self, value): self._value = value self.childNodes[0].data = value if self.ownerElement is not None: _clear_id_cache(self.ownerElement) self.childNodes[0].data = value nodeValue = value = property(_get_value, _set_value) def _get_prefix(self): return self._prefix def _set_prefix(self, prefix): nsuri = self.namespaceURI if prefix == "xmlns": if nsuri and nsuri != XMLNS_NAMESPACE: raise xml.dom.NamespaceErr( "illegal use of 'xmlns' prefix for the wrong namespace") self._prefix = prefix if prefix is None: newName = self.localName else: newName = "%s:%s" % (prefix, self.localName) if self.ownerElement: _clear_id_cache(self.ownerElement) self.name = newName prefix = property(_get_prefix, _set_prefix) def unlink(self): # This implementation does not call the base implementation # since most of that is not needed, and the expense of the # method call is not warranted. We duplicate the removal of # children, but that's all we needed from the base class. elem = self.ownerElement if elem is not None: del elem._attrs[self.nodeName] del elem._attrsNS[(self.namespaceURI, self.localName)] if self._is_id: self._is_id = False elem._magic_id_nodes -= 1 self.ownerDocument._magic_id_count -= 1 for child in self.childNodes: child.unlink() del self.childNodes[:] def _get_isId(self): if self._is_id: return True doc = self.ownerDocument elem = self.ownerElement if doc is None or elem is None: return False info = doc._get_elem_info(elem) if info is None: return False if self.namespaceURI: return info.isIdNS(self.namespaceURI, self.localName) else: return info.isId(self.nodeName) def _get_schemaType(self): doc = self.ownerDocument elem = self.ownerElement if doc is None or elem is None: return _no_type info = doc._get_elem_info(elem) if info is None: return _no_type if self.namespaceURI: return info.getAttributeTypeNS(self.namespaceURI, self.localName) else: return info.getAttributeType(self.nodeName) defproperty(Attr, "isId", doc="True if this attribute is an ID.") defproperty(Attr, "localName", doc="Namespace-local name of this attribute.") defproperty(Attr, "schemaType", doc="Schema type for this attribute.") class NamedNodeMap(object): """The attribute list is a transient interface to the underlying dictionaries. Mutations here will change the underlying element's dictionary. Ordering is imposed artificially and does not reflect the order of attributes as found in an input document. """ __slots__ = ('_attrs', '_attrsNS', '_ownerElement') def __init__(self, attrs, attrsNS, ownerElement): self._attrs = attrs self._attrsNS = attrsNS self._ownerElement = ownerElement def _get_length(self): return len(self._attrs) def item(self, index): try: return self[list(self._attrs.keys())[index]] except IndexError: return None def items(self): L = [] for node in self._attrs.values(): L.append((node.nodeName, node.value)) return L def itemsNS(self): L = [] for node in self._attrs.values(): L.append(((node.namespaceURI, node.localName), node.value)) return L def __contains__(self, key): if isinstance(key, str): return key in self._attrs else: return key in self._attrsNS def keys(self): return self._attrs.keys() def keysNS(self): return self._attrsNS.keys() def values(self): return self._attrs.values() def get(self, name, value=None): return self._attrs.get(name, value) __len__ = _get_length def _cmp(self, other): if self._attrs is getattr(other, "_attrs", None): return 0 else: return (id(self) > id(other)) - (id(self) < id(other)) def __eq__(self, other): return self._cmp(other) == 0 def __ge__(self, other): return self._cmp(other) >= 0 def __gt__(self, other): return self._cmp(other) > 0 def __le__(self, other): return self._cmp(other) <= 0 def __lt__(self, other): return self._cmp(other) < 0 def __ne__(self, other): return self._cmp(other) != 0 def __getitem__(self, attname_or_tuple): if isinstance(attname_or_tuple, tuple): return self._attrsNS[attname_or_tuple] else: return self._attrs[attname_or_tuple] # same as set def __setitem__(self, attname, value): if isinstance(value, str): try: node = self._attrs[attname] except KeyError: node = Attr(attname) node.ownerDocument = self._ownerElement.ownerDocument self.setNamedItem(node) node.value = value else: if not isinstance(value, Attr): raise TypeError("value must be a string or Attr object") node = value self.setNamedItem(node) def getNamedItem(self, name): try: return self._attrs[name] except KeyError: return None def getNamedItemNS(self, namespaceURI, localName): try: return self._attrsNS[(namespaceURI, localName)] except KeyError: return None def removeNamedItem(self, name): n = self.getNamedItem(name) if n is not None: _clear_id_cache(self._ownerElement) del self._attrs[n.nodeName] del self._attrsNS[(n.namespaceURI, n.localName)] if hasattr(n, 'ownerElement'): n.ownerElement = None return n else: raise xml.dom.NotFoundErr() def removeNamedItemNS(self, namespaceURI, localName): n = self.getNamedItemNS(namespaceURI, localName) if n is not None: _clear_id_cache(self._ownerElement) del self._attrsNS[(n.namespaceURI, n.localName)] del self._attrs[n.nodeName] if hasattr(n, 'ownerElement'): n.ownerElement = None return n else: raise xml.dom.NotFoundErr() def setNamedItem(self, node): if not isinstance(node, Attr): raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) old = self._attrs.get(node.name) if old: old.unlink() self._attrs[node.name] = node self._attrsNS[(node.namespaceURI, node.localName)] = node node.ownerElement = self._ownerElement _clear_id_cache(node.ownerElement) return old def setNamedItemNS(self, node): return self.setNamedItem(node) def __delitem__(self, attname_or_tuple): node = self[attname_or_tuple] _clear_id_cache(node.ownerElement) node.unlink() def __getstate__(self): return self._attrs, self._attrsNS, self._ownerElement def __setstate__(self, state): self._attrs, self._attrsNS, self._ownerElement = state defproperty(NamedNodeMap, "length", doc="Number of nodes in the NamedNodeMap.") AttributeList = NamedNodeMap class TypeInfo(object): __slots__ = 'namespace', 'name' def __init__(self, namespace, name): self.namespace = namespace self.name = name def __repr__(self): if self.namespace: return "<TypeInfo %r (from %r)>" % (self.name, self.namespace) else: return "<TypeInfo %r>" % self.name def _get_name(self): return self.name def _get_namespace(self): return self.namespace _no_type = TypeInfo(None, None) class Element(Node): __slots__=('ownerDocument', 'parentNode', 'tagName', 'nodeName', 'prefix', 'namespaceURI', '_localName', 'childNodes', '_attrs', '_attrsNS', 'nextSibling', 'previousSibling') nodeType = Node.ELEMENT_NODE nodeValue = None schemaType = _no_type _magic_id_nodes = 0 _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.TEXT_NODE, Node.CDATA_SECTION_NODE, Node.ENTITY_REFERENCE_NODE) def __init__(self, tagName, namespaceURI=EMPTY_NAMESPACE, prefix=None, localName=None): self.parentNode = None self.tagName = self.nodeName = tagName self.prefix = prefix self.namespaceURI = namespaceURI self.childNodes = NodeList() self.nextSibling = self.previousSibling = None # Attribute dictionaries are lazily created # attributes are double-indexed: # tagName -> Attribute # URI,localName -> Attribute # in the future: consider lazy generation # of attribute objects this is too tricky # for now because of headaches with # namespaces. self._attrs = None self._attrsNS = None def _ensure_attributes(self): if self._attrs is None: self._attrs = {} self._attrsNS = {} def _get_localName(self): try: return self._localName except AttributeError: return self.tagName.split(":", 1)[-1] def _get_tagName(self): return self.tagName def unlink(self): if self._attrs is not None: for attr in list(self._attrs.values()): attr.unlink() self._attrs = None self._attrsNS = None Node.unlink(self) def getAttribute(self, attname): if self._attrs is None: return "" try: return self._attrs[attname].value except KeyError: return "" def getAttributeNS(self, namespaceURI, localName): if self._attrsNS is None: return "" try: return self._attrsNS[(namespaceURI, localName)].value except KeyError: return "" def setAttribute(self, attname, value): attr = self.getAttributeNode(attname) if attr is None: attr = Attr(attname) attr.value = value # also sets nodeValue attr.ownerDocument = self.ownerDocument self.setAttributeNode(attr) elif value != attr.value: attr.value = value if attr.isId: _clear_id_cache(self) def setAttributeNS(self, namespaceURI, qualifiedName, value): prefix, localname = _nssplit(qualifiedName) attr = self.getAttributeNodeNS(namespaceURI, localname) if attr is None: attr = Attr(qualifiedName, namespaceURI, localname, prefix) attr.value = value attr.ownerDocument = self.ownerDocument self.setAttributeNode(attr) else: if value != attr.value: attr.value = value if attr.isId: _clear_id_cache(self) if attr.prefix != prefix: attr.prefix = prefix attr.nodeName = qualifiedName def getAttributeNode(self, attrname): if self._attrs is None: return None return self._attrs.get(attrname) def getAttributeNodeNS(self, namespaceURI, localName): if self._attrsNS is None: return None return self._attrsNS.get((namespaceURI, localName)) def setAttributeNode(self, attr): if attr.ownerElement not in (None, self): raise xml.dom.InuseAttributeErr("attribute node already owned") self._ensure_attributes() old1 = self._attrs.get(attr.name, None) if old1 is not None: self.removeAttributeNode(old1) old2 = self._attrsNS.get((attr.namespaceURI, attr.localName), None) if old2 is not None and old2 is not old1: self.removeAttributeNode(old2) _set_attribute_node(self, attr) if old1 is not attr: # It might have already been part of this node, in which case # it doesn't represent a change, and should not be returned. return old1 if old2 is not attr: return old2 setAttributeNodeNS = setAttributeNode def removeAttribute(self, name): if self._attrsNS is None: raise xml.dom.NotFoundErr() try: attr = self._attrs[name] except KeyError: raise xml.dom.NotFoundErr() self.removeAttributeNode(attr) def removeAttributeNS(self, namespaceURI, localName): if self._attrsNS is None: raise xml.dom.NotFoundErr() try: attr = self._attrsNS[(namespaceURI, localName)] except KeyError: raise xml.dom.NotFoundErr() self.removeAttributeNode(attr) def removeAttributeNode(self, node): if node is None: raise xml.dom.NotFoundErr() try: self._attrs[node.name] except KeyError: raise xml.dom.NotFoundErr() _clear_id_cache(self) node.unlink() # Restore this since the node is still useful and otherwise # unlinked node.ownerDocument = self.ownerDocument removeAttributeNodeNS = removeAttributeNode def hasAttribute(self, name): if self._attrs is None: return False return name in self._attrs def hasAttributeNS(self, namespaceURI, localName): if self._attrsNS is None: return False return (namespaceURI, localName) in self._attrsNS def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): return _get_elements_by_tagName_ns_helper( self, namespaceURI, localName, NodeList()) def __repr__(self): return "<DOM Element: %s at %#x>" % (self.tagName, id(self)) def writexml(self, writer, indent="", addindent="", newl=""): # indent = current indentation # addindent = indentation to add to higher levels # newl = newline string writer.write(indent+"<" + self.tagName) attrs = self._get_attributes() a_names = sorted(attrs.keys()) for a_name in a_names: writer.write(" %s=\"" % a_name) _write_data(writer, attrs[a_name].value) writer.write("\"") if self.childNodes: writer.write(">") if (len(self.childNodes) == 1 and self.childNodes[0].nodeType == Node.TEXT_NODE): self.childNodes[0].writexml(writer, '', '', '') else: writer.write(newl) for node in self.childNodes: node.writexml(writer, indent+addindent, addindent, newl) writer.write(indent) writer.write("</%s>%s" % (self.tagName, newl)) else: writer.write("/>%s"%(newl)) def _get_attributes(self): self._ensure_attributes() return NamedNodeMap(self._attrs, self._attrsNS, self) def hasAttributes(self): if self._attrs: return True else: return False # DOM Level 3 attributes, based on the 22 Oct 2002 draft def setIdAttribute(self, name): idAttr = self.getAttributeNode(name) self.setIdAttributeNode(idAttr) def setIdAttributeNS(self, namespaceURI, localName): idAttr = self.getAttributeNodeNS(namespaceURI, localName) self.setIdAttributeNode(idAttr) def setIdAttributeNode(self, idAttr): if idAttr is None or not self.isSameNode(idAttr.ownerElement): raise xml.dom.NotFoundErr() if _get_containing_entref(self) is not None: raise xml.dom.NoModificationAllowedErr() if not idAttr._is_id: idAttr._is_id = True self._magic_id_nodes += 1 self.ownerDocument._magic_id_count += 1 _clear_id_cache(self) defproperty(Element, "attributes", doc="NamedNodeMap of attributes on the element.") defproperty(Element, "localName", doc="Namespace-local name of this element.") def _set_attribute_node(element, attr): _clear_id_cache(element) element._ensure_attributes() element._attrs[attr.name] = attr element._attrsNS[(attr.namespaceURI, attr.localName)] = attr # This creates a circular reference, but Element.unlink() # breaks the cycle since the references to the attribute # dictionaries are tossed. attr.ownerElement = element class Childless: """Mixin that makes childless-ness easy to implement and avoids the complexity of the Node methods that deal with children. """ __slots__ = () attributes = None childNodes = EmptyNodeList() firstChild = None lastChild = None def _get_firstChild(self): return None def _get_lastChild(self): return None def appendChild(self, node): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes cannot have children") def hasChildNodes(self): return False def insertBefore(self, newChild, refChild): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes do not have children") def removeChild(self, oldChild): raise xml.dom.NotFoundErr( self.nodeName + " nodes do not have children") def normalize(self): # For childless nodes, normalize() has nothing to do. pass def replaceChild(self, newChild, oldChild): raise xml.dom.HierarchyRequestErr( self.nodeName + " nodes do not have children") class ProcessingInstruction(Childless, Node): nodeType = Node.PROCESSING_INSTRUCTION_NODE __slots__ = ('target', 'data') def __init__(self, target, data): self.target = target self.data = data # nodeValue is an alias for data def _get_nodeValue(self): return self.data def _set_nodeValue(self, value): self.data = data nodeValue = property(_get_nodeValue, _set_nodeValue) # nodeName is an alias for target def _get_nodeName(self): return self.target def _set_nodeName(self, value): self.target = value nodeName = property(_get_nodeName, _set_nodeName) def writexml(self, writer, indent="", addindent="", newl=""): writer.write("%s<?%s %s?>%s" % (indent,self.target, self.data, newl)) class CharacterData(Childless, Node): __slots__=('_data', 'ownerDocument','parentNode', 'previousSibling', 'nextSibling') def __init__(self): self.ownerDocument = self.parentNode = None self.previousSibling = self.nextSibling = None self._data = '' Node.__init__(self) def _get_length(self): return len(self.data) __len__ = _get_length def _get_data(self): return self._data def _set_data(self, data): self._data = data data = nodeValue = property(_get_data, _set_data) def __repr__(self): data = self.data if len(data) > 10: dotdotdot = "..." else: dotdotdot = "" return '<DOM %s node "%r%s">' % ( self.__class__.__name__, data[0:10], dotdotdot) def substringData(self, offset, count): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") return self.data[offset:offset+count] def appendData(self, arg): self.data = self.data + arg def insertData(self, offset, arg): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if arg: self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset:]) def deleteData(self, offset, count): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") if count: self.data = self.data[:offset] + self.data[offset+count:] def replaceData(self, offset, count, arg): if offset < 0: raise xml.dom.IndexSizeErr("offset cannot be negative") if offset >= len(self.data): raise xml.dom.IndexSizeErr("offset cannot be beyond end of data") if count < 0: raise xml.dom.IndexSizeErr("count cannot be negative") if count: self.data = "%s%s%s" % ( self.data[:offset], arg, self.data[offset+count:]) defproperty(CharacterData, "length", doc="Length of the string data.") class Text(CharacterData): __slots__ = () nodeType = Node.TEXT_NODE nodeName = "#text" attributes = None def splitText(self, offset): if offset < 0 or offset > len(self.data): raise xml.dom.IndexSizeErr("illegal offset value") newText = self.__class__() newText.data = self.data[offset:] newText.ownerDocument = self.ownerDocument next = self.nextSibling if self.parentNode and self in self.parentNode.childNodes: if next is None: self.parentNode.appendChild(newText) else: self.parentNode.insertBefore(newText, next) self.data = self.data[:offset] return newText def writexml(self, writer, indent="", addindent="", newl=""): _write_data(writer, "%s%s%s" % (indent, self.data, newl)) # DOM Level 3 (WD 9 April 2002) def _get_wholeText(self): L = [self.data] n = self.previousSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): L.insert(0, n.data) n = n.previousSibling else: break n = self.nextSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): L.append(n.data) n = n.nextSibling else: break return ''.join(L) def replaceWholeText(self, content): # XXX This needs to be seriously changed if minidom ever # supports EntityReference nodes. parent = self.parentNode n = self.previousSibling while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): next = n.previousSibling parent.removeChild(n) n = next else: break n = self.nextSibling if not content: parent.removeChild(self) while n is not None: if n.nodeType in (Node.TEXT_NODE, Node.CDATA_SECTION_NODE): next = n.nextSibling parent.removeChild(n) n = next else: break if content: self.data = content return self else: return None def _get_isWhitespaceInElementContent(self): if self.data.strip(): return False elem = _get_containing_element(self) if elem is None: return False info = self.ownerDocument._get_elem_info(elem) if info is None: return False else: return info.isElementContent() defproperty(Text, "isWhitespaceInElementContent", doc="True iff this text node contains only whitespace" " and is in element content.") defproperty(Text, "wholeText", doc="The text of all logically-adjacent text nodes.") def _get_containing_element(node): c = node.parentNode while c is not None: if c.nodeType == Node.ELEMENT_NODE: return c c = c.parentNode return None def _get_containing_entref(node): c = node.parentNode while c is not None: if c.nodeType == Node.ENTITY_REFERENCE_NODE: return c c = c.parentNode return None class Comment(CharacterData): nodeType = Node.COMMENT_NODE nodeName = "#comment" def __init__(self, data): CharacterData.__init__(self) self._data = data def writexml(self, writer, indent="", addindent="", newl=""): if "--" in self.data: raise ValueError("'--' is not allowed in a comment node") writer.write("%s<!--%s-->%s" % (indent, self.data, newl)) class CDATASection(Text): __slots__ = () nodeType = Node.CDATA_SECTION_NODE nodeName = "#cdata-section" def writexml(self, writer, indent="", addindent="", newl=""): if self.data.find("]]>") >= 0: raise ValueError("']]>' not allowed in a CDATA section") writer.write("<![CDATA[%s]]>" % self.data) class ReadOnlySequentialNamedNodeMap(object): __slots__ = '_seq', def __init__(self, seq=()): # seq should be a list or tuple self._seq = seq def __len__(self): return len(self._seq) def _get_length(self): return len(self._seq) def getNamedItem(self, name): for n in self._seq: if n.nodeName == name: return n def getNamedItemNS(self, namespaceURI, localName): for n in self._seq: if n.namespaceURI == namespaceURI and n.localName == localName: return n def __getitem__(self, name_or_tuple): if isinstance(name_or_tuple, tuple): node = self.getNamedItemNS(*name_or_tuple) else: node = self.getNamedItem(name_or_tuple) if node is None: raise KeyError(name_or_tuple) return node def item(self, index): if index < 0: return None try: return self._seq[index] except IndexError: return None def removeNamedItem(self, name): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def removeNamedItemNS(self, namespaceURI, localName): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def setNamedItem(self, node): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def setNamedItemNS(self, node): raise xml.dom.NoModificationAllowedErr( "NamedNodeMap instance is read-only") def __getstate__(self): return [self._seq] def __setstate__(self, state): self._seq = state[0] defproperty(ReadOnlySequentialNamedNodeMap, "length", doc="Number of entries in the NamedNodeMap.") class Identified: """Mix-in class that supports the publicId and systemId attributes.""" __slots__ = 'publicId', 'systemId' def _identified_mixin_init(self, publicId, systemId): self.publicId = publicId self.systemId = systemId def _get_publicId(self): return self.publicId def _get_systemId(self): return self.systemId class DocumentType(Identified, Childless, Node): nodeType = Node.DOCUMENT_TYPE_NODE nodeValue = None name = None publicId = None systemId = None internalSubset = None def __init__(self, qualifiedName): self.entities = ReadOnlySequentialNamedNodeMap() self.notations = ReadOnlySequentialNamedNodeMap() if qualifiedName: prefix, localname = _nssplit(qualifiedName) self.name = localname self.nodeName = self.name def _get_internalSubset(self): return self.internalSubset def cloneNode(self, deep): if self.ownerDocument is None: # it's ok clone = DocumentType(None) clone.name = self.name clone.nodeName = self.name operation = xml.dom.UserDataHandler.NODE_CLONED if deep: clone.entities._seq = [] clone.notations._seq = [] for n in self.notations._seq: notation = Notation(n.nodeName, n.publicId, n.systemId) clone.notations._seq.append(notation) n._call_user_data_handler(operation, n, notation) for e in self.entities._seq: entity = Entity(e.nodeName, e.publicId, e.systemId, e.notationName) entity.actualEncoding = e.actualEncoding entity.encoding = e.encoding entity.version = e.version clone.entities._seq.append(entity) e._call_user_data_handler(operation, n, entity) self._call_user_data_handler(operation, self, clone) return clone else: return None def writexml(self, writer, indent="", addindent="", newl=""): writer.write("<!DOCTYPE ") writer.write(self.name) if self.publicId: writer.write("%s PUBLIC '%s'%s '%s'" % (newl, self.publicId, newl, self.systemId)) elif self.systemId: writer.write("%s SYSTEM '%s'" % (newl, self.systemId)) if self.internalSubset is not None: writer.write(" [") writer.write(self.internalSubset) writer.write("]") writer.write(">"+newl) class Entity(Identified, Node): attributes = None nodeType = Node.ENTITY_NODE nodeValue = None actualEncoding = None encoding = None version = None def __init__(self, name, publicId, systemId, notation): self.nodeName = name self.notationName = notation self.childNodes = NodeList() self._identified_mixin_init(publicId, systemId) def _get_actualEncoding(self): return self.actualEncoding def _get_encoding(self): return self.encoding def _get_version(self): return self.version def appendChild(self, newChild): raise xml.dom.HierarchyRequestErr( "cannot append children to an entity node") def insertBefore(self, newChild, refChild): raise xml.dom.HierarchyRequestErr( "cannot insert children below an entity node") def removeChild(self, oldChild): raise xml.dom.HierarchyRequestErr( "cannot remove children from an entity node") def replaceChild(self, newChild, oldChild): raise xml.dom.HierarchyRequestErr( "cannot replace children of an entity node") class Notation(Identified, Childless, Node): nodeType = Node.NOTATION_NODE nodeValue = None def __init__(self, name, publicId, systemId): self.nodeName = name self._identified_mixin_init(publicId, systemId) class DOMImplementation(DOMImplementationLS): _features = [("core", "1.0"), ("core", "2.0"), ("core", None), ("xml", "1.0"), ("xml", "2.0"), ("xml", None), ("ls-load", "3.0"), ("ls-load", None), ] def hasFeature(self, feature, version): if version == "": version = None return (feature.lower(), version) in self._features def createDocument(self, namespaceURI, qualifiedName, doctype): if doctype and doctype.parentNode is not None: raise xml.dom.WrongDocumentErr( "doctype object owned by another DOM tree") doc = self._create_document() add_root_element = not (namespaceURI is None and qualifiedName is None and doctype is None) if not qualifiedName and add_root_element: # The spec is unclear what to raise here; SyntaxErr # would be the other obvious candidate. Since Xerces raises # InvalidCharacterErr, and since SyntaxErr is not listed # for createDocument, that seems to be the better choice. # XXX: need to check for illegal characters here and in # createElement. # DOM Level III clears this up when talking about the return value # of this function. If namespaceURI, qName and DocType are # Null the document is returned without a document element # Otherwise if doctype or namespaceURI are not None # Then we go back to the above problem raise xml.dom.InvalidCharacterErr("Element with no name") if add_root_element: prefix, localname = _nssplit(qualifiedName) if prefix == "xml" \ and namespaceURI != "http://www.w3.org/XML/1998/namespace": raise xml.dom.NamespaceErr("illegal use of 'xml' prefix") if prefix and not namespaceURI: raise xml.dom.NamespaceErr( "illegal use of prefix without namespaces") element = doc.createElementNS(namespaceURI, qualifiedName) if doctype: doc.appendChild(doctype) doc.appendChild(element) if doctype: doctype.parentNode = doctype.ownerDocument = doc doc.doctype = doctype doc.implementation = self return doc def createDocumentType(self, qualifiedName, publicId, systemId): doctype = DocumentType(qualifiedName) doctype.publicId = publicId doctype.systemId = systemId return doctype # DOM Level 3 (WD 9 April 2002) def getInterface(self, feature): if self.hasFeature(feature, None): return self else: return None # internal def _create_document(self): return Document() class ElementInfo(object): """Object that represents content-model information for an element. This implementation is not expected to be used in practice; DOM builders should provide implementations which do the right thing using information available to it. """ __slots__ = 'tagName', def __init__(self, name): self.tagName = name def getAttributeType(self, aname): return _no_type def getAttributeTypeNS(self, namespaceURI, localName): return _no_type def isElementContent(self): return False def isEmpty(self): """Returns true iff this element is declared to have an EMPTY content model.""" return False def isId(self, aname): """Returns true iff the named attribute is a DTD-style ID.""" return False def isIdNS(self, namespaceURI, localName): """Returns true iff the identified attribute is a DTD-style ID.""" return False def __getstate__(self): return self.tagName def __setstate__(self, state): self.tagName = state def _clear_id_cache(node): if node.nodeType == Node.DOCUMENT_NODE: node._id_cache.clear() node._id_search_stack = None elif _in_document(node): node.ownerDocument._id_cache.clear() node.ownerDocument._id_search_stack= None class Document(Node, DocumentLS): __slots__ = ('_elem_info', 'doctype', '_id_search_stack', 'childNodes', '_id_cache') _child_node_types = (Node.ELEMENT_NODE, Node.PROCESSING_INSTRUCTION_NODE, Node.COMMENT_NODE, Node.DOCUMENT_TYPE_NODE) implementation = DOMImplementation() nodeType = Node.DOCUMENT_NODE nodeName = "#document" nodeValue = None attributes = None parentNode = None previousSibling = nextSibling = None # Document attributes from Level 3 (WD 9 April 2002) actualEncoding = None encoding = None standalone = None version = None strictErrorChecking = False errorHandler = None documentURI = None _magic_id_count = 0 def __init__(self): self.doctype = None self.childNodes = NodeList() # mapping of (namespaceURI, localName) -> ElementInfo # and tagName -> ElementInfo self._elem_info = {} self._id_cache = {} self._id_search_stack = None def _get_elem_info(self, element): if element.namespaceURI: key = element.namespaceURI, element.localName else: key = element.tagName return self._elem_info.get(key) def _get_actualEncoding(self): return self.actualEncoding def _get_doctype(self): return self.doctype def _get_documentURI(self): return self.documentURI def _get_encoding(self): return self.encoding def _get_errorHandler(self): return self.errorHandler def _get_standalone(self): return self.standalone def _get_strictErrorChecking(self): return self.strictErrorChecking def _get_version(self): return self.version def appendChild(self, node): if node.nodeType not in self._child_node_types: raise xml.dom.HierarchyRequestErr( "%s cannot be child of %s" % (repr(node), repr(self))) if node.parentNode is not None: # This needs to be done before the next test since this # may *be* the document element, in which case it should # end up re-ordered to the end. node.parentNode.removeChild(node) if node.nodeType == Node.ELEMENT_NODE \ and self._get_documentElement(): raise xml.dom.HierarchyRequestErr( "two document elements disallowed") return Node.appendChild(self, node) def removeChild(self, oldChild): try: self.childNodes.remove(oldChild) except ValueError: raise xml.dom.NotFoundErr() oldChild.nextSibling = oldChild.previousSibling = None oldChild.parentNode = None if self.documentElement is oldChild: self.documentElement = None return oldChild def _get_documentElement(self): for node in self.childNodes: if node.nodeType == Node.ELEMENT_NODE: return node def unlink(self): if self.doctype is not None: self.doctype.unlink() self.doctype = None Node.unlink(self) def cloneNode(self, deep): if not deep: return None clone = self.implementation.createDocument(None, None, None) clone.encoding = self.encoding clone.standalone = self.standalone clone.version = self.version for n in self.childNodes: childclone = _clone_node(n, deep, clone) assert childclone.ownerDocument.isSameNode(clone) clone.childNodes.append(childclone) if childclone.nodeType == Node.DOCUMENT_NODE: assert clone.documentElement is None elif childclone.nodeType == Node.DOCUMENT_TYPE_NODE: assert clone.doctype is None clone.doctype = childclone childclone.parentNode = clone self._call_user_data_handler(xml.dom.UserDataHandler.NODE_CLONED, self, clone) return clone def createDocumentFragment(self): d = DocumentFragment() d.ownerDocument = self return d def createElement(self, tagName): e = Element(tagName) e.ownerDocument = self return e def createTextNode(self, data): if not isinstance(data, str): raise TypeError("node contents must be a string") t = Text() t.data = data t.ownerDocument = self return t def createCDATASection(self, data): if not isinstance(data, str): raise TypeError("node contents must be a string") c = CDATASection() c.data = data c.ownerDocument = self return c def createComment(self, data): c = Comment(data) c.ownerDocument = self return c def createProcessingInstruction(self, target, data): p = ProcessingInstruction(target, data) p.ownerDocument = self return p def createAttribute(self, qName): a = Attr(qName) a.ownerDocument = self a.value = "" return a def createElementNS(self, namespaceURI, qualifiedName): prefix, localName = _nssplit(qualifiedName) e = Element(qualifiedName, namespaceURI, prefix) e.ownerDocument = self return e def createAttributeNS(self, namespaceURI, qualifiedName): prefix, localName = _nssplit(qualifiedName) a = Attr(qualifiedName, namespaceURI, localName, prefix) a.ownerDocument = self a.value = "" return a # A couple of implementation-specific helpers to create node types # not supported by the W3C DOM specs: def _create_entity(self, name, publicId, systemId, notationName): e = Entity(name, publicId, systemId, notationName) e.ownerDocument = self return e def _create_notation(self, name, publicId, systemId): n = Notation(name, publicId, systemId) n.ownerDocument = self return n def getElementById(self, id): if id in self._id_cache: return self._id_cache[id] if not (self._elem_info or self._magic_id_count): return None stack = self._id_search_stack if stack is None: # we never searched before, or the cache has been cleared stack = [self.documentElement] self._id_search_stack = stack elif not stack: # Previous search was completed and cache is still valid; # no matching node. return None result = None while stack: node = stack.pop() # add child elements to stack for continued searching stack.extend([child for child in node.childNodes if child.nodeType in _nodeTypes_with_children]) # check this node info = self._get_elem_info(node) if info: # We have to process all ID attributes before # returning in order to get all the attributes set to # be IDs using Element.setIdAttribute*(). for attr in node.attributes.values(): if attr.namespaceURI: if info.isIdNS(attr.namespaceURI, attr.localName): self._id_cache[attr.value] = node if attr.value == id: result = node elif not node._magic_id_nodes: break elif info.isId(attr.name): self._id_cache[attr.value] = node if attr.value == id: result = node elif not node._magic_id_nodes: break elif attr._is_id: self._id_cache[attr.value] = node if attr.value == id: result = node elif node._magic_id_nodes == 1: break elif node._magic_id_nodes: for attr in node.attributes.values(): if attr._is_id: self._id_cache[attr.value] = node if attr.value == id: result = node if result is not None: break return result def getElementsByTagName(self, name): return _get_elements_by_tagName_helper(self, name, NodeList()) def getElementsByTagNameNS(self, namespaceURI, localName): return _get_elements_by_tagName_ns_helper( self, namespaceURI, localName, NodeList()) def isSupported(self, feature, version): return self.implementation.hasFeature(feature, version) def importNode(self, node, deep): if node.nodeType == Node.DOCUMENT_NODE: raise xml.dom.NotSupportedErr("cannot import document nodes") elif node.nodeType == Node.DOCUMENT_TYPE_NODE: raise xml.dom.NotSupportedErr("cannot import document type nodes") return _clone_node(node, deep, self) def writexml(self, writer, indent="", addindent="", newl="", encoding=None): if encoding is None: writer.write('<?xml version="1.0" ?>'+newl) else: writer.write('<?xml version="1.0" encoding="%s"?>%s' % ( encoding, newl)) for node in self.childNodes: node.writexml(writer, indent, addindent, newl) # DOM Level 3 (WD 9 April 2002) def renameNode(self, n, namespaceURI, name): if n.ownerDocument is not self: raise xml.dom.WrongDocumentErr( "cannot rename nodes from other documents;\n" "expected %s,\nfound %s" % (self, n.ownerDocument)) if n.nodeType not in (Node.ELEMENT_NODE, Node.ATTRIBUTE_NODE): raise xml.dom.NotSupportedErr( "renameNode() only applies to element and attribute nodes") if namespaceURI != EMPTY_NAMESPACE: if ':' in name: prefix, localName = name.split(':', 1) if ( prefix == "xmlns" and namespaceURI != xml.dom.XMLNS_NAMESPACE): raise xml.dom.NamespaceErr( "illegal use of 'xmlns' prefix") else: if ( name == "xmlns" and namespaceURI != xml.dom.XMLNS_NAMESPACE and n.nodeType == Node.ATTRIBUTE_NODE): raise xml.dom.NamespaceErr( "illegal use of the 'xmlns' attribute") prefix = None localName = name else: prefix = None localName = None if n.nodeType == Node.ATTRIBUTE_NODE: element = n.ownerElement if element is not None: is_id = n._is_id element.removeAttributeNode(n) else: element = None n.prefix = prefix n._localName = localName n.namespaceURI = namespaceURI n.nodeName = name if n.nodeType == Node.ELEMENT_NODE: n.tagName = name else: # attribute node n.name = name if element is not None: element.setAttributeNode(n) if is_id: element.setIdAttributeNode(n) # It's not clear from a semantic perspective whether we should # call the user data handlers for the NODE_RENAMED event since # we're re-using the existing node. The draft spec has been # interpreted as meaning "no, don't call the handler unless a # new node is created." return n defproperty(Document, "documentElement", doc="Top-level element of this document.") def _clone_node(node, deep, newOwnerDocument): """ Clone a node and give it the new owner document. Called by Node.cloneNode and Document.importNode """ if node.ownerDocument.isSameNode(newOwnerDocument): operation = xml.dom.UserDataHandler.NODE_CLONED else: operation = xml.dom.UserDataHandler.NODE_IMPORTED if node.nodeType == Node.ELEMENT_NODE: clone = newOwnerDocument.createElementNS(node.namespaceURI, node.nodeName) for attr in node.attributes.values(): clone.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.value) a = clone.getAttributeNodeNS(attr.namespaceURI, attr.localName) a.specified = attr.specified if deep: for child in node.childNodes: c = _clone_node(child, deep, newOwnerDocument) clone.appendChild(c) elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE: clone = newOwnerDocument.createDocumentFragment() if deep: for child in node.childNodes: c = _clone_node(child, deep, newOwnerDocument) clone.appendChild(c) elif node.nodeType == Node.TEXT_NODE: clone = newOwnerDocument.createTextNode(node.data) elif node.nodeType == Node.CDATA_SECTION_NODE: clone = newOwnerDocument.createCDATASection(node.data) elif node.nodeType == Node.PROCESSING_INSTRUCTION_NODE: clone = newOwnerDocument.createProcessingInstruction(node.target, node.data) elif node.nodeType == Node.COMMENT_NODE: clone = newOwnerDocument.createComment(node.data) elif node.nodeType == Node.ATTRIBUTE_NODE: clone = newOwnerDocument.createAttributeNS(node.namespaceURI, node.nodeName) clone.specified = True clone.value = node.value elif node.nodeType == Node.DOCUMENT_TYPE_NODE: assert node.ownerDocument is not newOwnerDocument operation = xml.dom.UserDataHandler.NODE_IMPORTED clone = newOwnerDocument.implementation.createDocumentType( node.name, node.publicId, node.systemId) clone.ownerDocument = newOwnerDocument if deep: clone.entities._seq = [] clone.notations._seq = [] for n in node.notations._seq: notation = Notation(n.nodeName, n.publicId, n.systemId) notation.ownerDocument = newOwnerDocument clone.notations._seq.append(notation) if hasattr(n, '_call_user_data_handler'): n._call_user_data_handler(operation, n, notation) for e in node.entities._seq: entity = Entity(e.nodeName, e.publicId, e.systemId, e.notationName) entity.actualEncoding = e.actualEncoding entity.encoding = e.encoding entity.version = e.version entity.ownerDocument = newOwnerDocument clone.entities._seq.append(entity) if hasattr(e, '_call_user_data_handler'): e._call_user_data_handler(operation, n, entity) else: # Note the cloning of Document and DocumentType nodes is # implementation specific. minidom handles those cases # directly in the cloneNode() methods. raise xml.dom.NotSupportedErr("Cannot clone node %s" % repr(node)) # Check for _call_user_data_handler() since this could conceivably # used with other DOM implementations (one of the FourThought # DOMs, perhaps?). if hasattr(node, '_call_user_data_handler'): node._call_user_data_handler(operation, node, clone) return clone def _nssplit(qualifiedName): fields = qualifiedName.split(':', 1) if len(fields) == 2: return fields else: return (None, fields[0]) def _do_pulldom_parse(func, args, kwargs): events = func(*args, **kwargs) toktype, rootNode = events.getEvent() events.expandNode(rootNode) events.clear() return rootNode def parse(file, parser=None, bufsize=None): """Parse a file into a DOM by filename or file object.""" if parser is None and not bufsize: from xml.dom import expatbuilder return expatbuilder.parse(file) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize}) def parseString(string, parser=None): """Parse a file into a DOM from a string.""" if parser is None: from xml.dom import expatbuilder return expatbuilder.parseString(string) else: from xml.dom import pulldom return _do_pulldom_parse(pulldom.parseString, (string,), {'parser': parser}) def getDOMImplementation(features=None): if features: if isinstance(features, str): features = domreg._parse_feature_string(features) for f, v in features: if not Document.implementation.hasFeature(f, v): return None return Document.implementation
gpl-2.0
[ 624, 3184, 4514, 402, 314, 20400, 413, 14316, 14, 199, 199, 985, 10749, 436, 1163, 12612, 20400, 499, 4534, 787, 2597, 3748, 14, 199, 199, 1122, 480, 1421, 14, 1652, 531, 199, 199, 14934, 6757, 1421, 2535, 1700, 15, 2957, 1421, 9579, 199, 199, 52, 19657, 26, 199, 19989, 199, 627, 16777, 3102, 367, 10232, 4008, 436, 1318, 14, 199, 627, 1655, 5343, 199, 627, 330, 5985, 2005, 402, 314, 7060, 436, 7798, 1793, 1233, 1901, 406, 11478, 543, 642, 267, 3217, 199, 627, 19310, 499, 10747, 199, 624, 199, 199, 646, 5890, 199, 646, 2748, 14, 4556, 199, 199, 504, 2748, 14, 4556, 492, 16589, 63, 13001, 12, 16589, 63, 6351, 12, 4692, 2709, 63, 13001, 12, 8266, 1135, 199, 504, 2748, 14, 4556, 14, 18000, 5819, 492, 627, 199, 504, 2748, 14, 4556, 14, 1652, 5649, 492, 14316, 7921, 5296, 12, 7543, 5296, 199, 199, 3, 961, 365, 1202, 701, 314, 2870, 13, 1637, 3866, 425, 5920, 27, 314, 769, 5712, 1133, 199, 3, 5965, 4890, 12, 3967, 314, 3380, 3769, 7923, 911, 7078, 506, 314, 199, 3, 29970, 63, 8063, 503, 29970, 63, 28147, 63, 8063, 14, 221, 334, 1918, 1031, 3769, 7923, 365, 199, 3, 314, 1031, 3769, 3483, 503, 4829, 12, 440, 314, 1031, 3769, 6042, 4959, 199, 3, 199, 63, 932, 4100, 63, 1045, 63, 3223, 275, 334, 1652, 14, 4556, 14, 1716, 14, 12535, 63, 8063, 12, 1169, 2748, 14, 4556, 14, 1716, 14, 13630, 63, 31177, 63, 8063, 9, 421, 199, 533, 5013, 8, 1652, 14, 4556, 14, 1716, 304, 272, 3231, 7639, 275, 488, 327, 642, 365, 2222, 13, 2307, 1454, 367, 4008, 436, 3004, 272, 1676, 1716, 275, 488, 272, 5771, 5564, 275, 488, 272, 2163, 16016, 275, 488, 272, 4136, 16016, 275, 488, 339, 2403, 275, 16589, 63, 6351, 327, 2222, 13, 2307, 1454, 367, 9380, 4008, 436, 3004, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 715, 339, 347, 370, 1652, 8, 277, 12, 2644, 29, 403, 304, 267, 372, 291, 14, 2119, 21958, 1652, 12398, 4873, 2644, 9, 339, 347, 370, 9118, 1652, 8, 277, 12, 4363, 21024, 84, 401, 892, 76, 21024, 78, 401, 2644, 29, 403, 304, 267, 340, 2644, 365, 488, 26, 288, 7060, 275, 5890, 14, 6424, 342, 267, 587, 26, 288, 7060, 275, 5890, 14, 1872, 29365, 8, 2308, 14, 15466, 1062, 4228, 2644, 29, 2991, 12, 4228, 2552, 628, 1652, 24253, 1814, 401, 4228, 8057, 17115, 78, 358, 267, 340, 291, 14, 12412, 508, 5013, 14, 7884, 63, 8063, 26, 288, 327, 6855, 986, 2644, 1454, 370, 2213, 12, 370, 5324, 652, 1901, 4692, 1406, 288, 291, 14, 952, 1652, 8, 5491, 12, 4873, 4363, 12, 892, 76, 12, 2644, 9, 267, 587, 26, 288, 291, 14, 952, 1652, 8, 5491, 12, 4873, 4363, 12, 892, 76, 9, 267, 340, 2644, 365, 488, 26, 288, 372, 7060, 14, 7150, 342, 267, 587, 26, 288, 372, 7060, 14, 14481, 1252, 7150, 342, 339, 347, 965, 3493, 6300, 8, 277, 304, 267, 372, 2155, 8, 277, 14, 10626, 9, 339, 347, 485, 362, 63, 10626, 8, 277, 304, 267, 372, 291, 14, 10626, 339, 347, 485, 362, 63, 22262, 8, 277, 304, 267, 340, 291, 14, 10626, 26, 288, 372, 291, 14, 10626, 59, 16, 61, 339, 347, 485, 362, 63, 2019, 3493, 8, 277, 304, 267, 340, 291, 14, 10626, 26, 288, 372, 291, 14, 10626, 1988, 17, 61, 339, 347, 5518, 13569, 8, 277, 12, 28482, 12, 2984, 3493, 304, 267, 340, 28482, 14, 12412, 508, 291, 14, 7884, 63, 28147, 63, 8063, 26, 288, 367, 286, 315, 2008, 8, 1222, 3493, 14, 10626, 304, 355, 291, 14, 3176, 13569, 8, 67, 12, 2984, 3493, 9, 288, 6754, 710, 14316, 1630, 440, 5436, 590, 4165, 4052, 370, 372, 315, 642, 1930, 288, 372, 28482, 267, 340, 28482, 14, 12412, 440, 315, 291, 423, 1739, 63, 932, 63, 1313, 26, 288, 746, 2748, 14, 4556, 14, 29460, 2017, 5432, 8, 355, 2071, 83, 3913, 506, 1982, 402, 450, 83, 2, 450, 334, 2722, 8, 1222, 3493, 395, 4700, 8, 277, 1724, 267, 340, 28482, 14, 24899, 365, 440, 488, 26, 288, 28482, 14, 24899, 14, 2168, 3493, 8, 1222, 3493, 9, 267, 340, 2984, 3493, 365, 488, 26, 288, 291, 14, 14988, 8, 1222, 3493, 9, 267, 587, 26, 288, 862, 26, 355, 1478, 275, 291, 14, 10626, 14, 1080, 8, 1121, 3493, 9, 288, 871, 1722, 26, 355, 746, 2748, 14, 4556, 14, 4667, 5432, 342, 288, 340, 28482, 14, 12412, 315, 485, 932, 4100, 63, 1045, 63, 3223, 26, 355, 485, 3584, 63, 344, 63, 1637, 8, 277, 9, 288, 291, 14, 10626, 14, 3176, 8, 1080, 12, 28482, 9, 288, 28482, 14, 30336, 275, 2984, 3493, 288, 2984, 3493, 14, 6352, 16016, 275, 28482, 288, 340, 1478, 26, 355, 1031, 275, 291, 14, 10626, 59, 1080, 13, 17, 61, 355, 1031, 14, 30336, 275, 28482, 355, 28482, 14, 6352, 16016, 275, 1031, 288, 587, 26, 355, 28482, 14, 6352, 16016, 275, 488, 288, 28482, 14, 24899, 275, 291, 267, 372, 28482, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 340, 1031, 14, 12412, 508, 291, 14, 7884, 63, 28147, 63, 8063, 26, 288, 367, 286, 315, 2008, 8, 932, 14, 10626, 304, 355, 291, 14, 14988, 8, 67, 9, 288, 6754, 710, 14316, 1630, 440, 5436, 590, 4165, 4052, 370, 372, 315, 642, 1930, 288, 372, 1031, 267, 340, 1031, 14, 12412, 440, 315, 291, 423, 1739, 63, 932, 63, 1313, 26, 288, 746, 2748, 14, 4556, 14, 29460, 2017, 5432, 8, 355, 2071, 83, 3913, 506, 1982, 402, 450, 83, 2, 450, 334, 2722, 8, 932, 395, 4700, 8, 277, 1724, 267, 916, 1031, 14, 12412, 315, 485, 932, 4100, 63, 1045, 63, 3223, 26, 288, 485, 3584, 63, 344, 63, 1637, 8, 277, 9, 267, 340, 1031, 14, 24899, 365, 440, 488, 26, 288, 1031, 14, 24899, 14, 2168, 3493, 8, 932, 9, 267, 485, 740, 63, 1739, 8, 277, 12, 1031, 9, 267, 1031, 14, 30336, 275, 488, 267, 372, 1031, 339, 347, 3350, 3493, 8, 277, 12, 28482, 12, 2269, 3493, 304, 267, 340, 28482, 14 ]
[ 3184, 4514, 402, 314, 20400, 413, 14316, 14, 199, 199, 985, 10749, 436, 1163, 12612, 20400, 499, 4534, 787, 2597, 3748, 14, 199, 199, 1122, 480, 1421, 14, 1652, 531, 199, 199, 14934, 6757, 1421, 2535, 1700, 15, 2957, 1421, 9579, 199, 199, 52, 19657, 26, 199, 19989, 199, 627, 16777, 3102, 367, 10232, 4008, 436, 1318, 14, 199, 627, 1655, 5343, 199, 627, 330, 5985, 2005, 402, 314, 7060, 436, 7798, 1793, 1233, 1901, 406, 11478, 543, 642, 267, 3217, 199, 627, 19310, 499, 10747, 199, 624, 199, 199, 646, 5890, 199, 646, 2748, 14, 4556, 199, 199, 504, 2748, 14, 4556, 492, 16589, 63, 13001, 12, 16589, 63, 6351, 12, 4692, 2709, 63, 13001, 12, 8266, 1135, 199, 504, 2748, 14, 4556, 14, 18000, 5819, 492, 627, 199, 504, 2748, 14, 4556, 14, 1652, 5649, 492, 14316, 7921, 5296, 12, 7543, 5296, 199, 199, 3, 961, 365, 1202, 701, 314, 2870, 13, 1637, 3866, 425, 5920, 27, 314, 769, 5712, 1133, 199, 3, 5965, 4890, 12, 3967, 314, 3380, 3769, 7923, 911, 7078, 506, 314, 199, 3, 29970, 63, 8063, 503, 29970, 63, 28147, 63, 8063, 14, 221, 334, 1918, 1031, 3769, 7923, 365, 199, 3, 314, 1031, 3769, 3483, 503, 4829, 12, 440, 314, 1031, 3769, 6042, 4959, 199, 3, 199, 63, 932, 4100, 63, 1045, 63, 3223, 275, 334, 1652, 14, 4556, 14, 1716, 14, 12535, 63, 8063, 12, 1169, 2748, 14, 4556, 14, 1716, 14, 13630, 63, 31177, 63, 8063, 9, 421, 199, 533, 5013, 8, 1652, 14, 4556, 14, 1716, 304, 272, 3231, 7639, 275, 488, 327, 642, 365, 2222, 13, 2307, 1454, 367, 4008, 436, 3004, 272, 1676, 1716, 275, 488, 272, 5771, 5564, 275, 488, 272, 2163, 16016, 275, 488, 272, 4136, 16016, 275, 488, 339, 2403, 275, 16589, 63, 6351, 327, 2222, 13, 2307, 1454, 367, 9380, 4008, 436, 3004, 339, 347, 636, 2245, 721, 277, 304, 267, 372, 715, 339, 347, 370, 1652, 8, 277, 12, 2644, 29, 403, 304, 267, 372, 291, 14, 2119, 21958, 1652, 12398, 4873, 2644, 9, 339, 347, 370, 9118, 1652, 8, 277, 12, 4363, 21024, 84, 401, 892, 76, 21024, 78, 401, 2644, 29, 403, 304, 267, 340, 2644, 365, 488, 26, 288, 7060, 275, 5890, 14, 6424, 342, 267, 587, 26, 288, 7060, 275, 5890, 14, 1872, 29365, 8, 2308, 14, 15466, 1062, 4228, 2644, 29, 2991, 12, 4228, 2552, 628, 1652, 24253, 1814, 401, 4228, 8057, 17115, 78, 358, 267, 340, 291, 14, 12412, 508, 5013, 14, 7884, 63, 8063, 26, 288, 327, 6855, 986, 2644, 1454, 370, 2213, 12, 370, 5324, 652, 1901, 4692, 1406, 288, 291, 14, 952, 1652, 8, 5491, 12, 4873, 4363, 12, 892, 76, 12, 2644, 9, 267, 587, 26, 288, 291, 14, 952, 1652, 8, 5491, 12, 4873, 4363, 12, 892, 76, 9, 267, 340, 2644, 365, 488, 26, 288, 372, 7060, 14, 7150, 342, 267, 587, 26, 288, 372, 7060, 14, 14481, 1252, 7150, 342, 339, 347, 965, 3493, 6300, 8, 277, 304, 267, 372, 2155, 8, 277, 14, 10626, 9, 339, 347, 485, 362, 63, 10626, 8, 277, 304, 267, 372, 291, 14, 10626, 339, 347, 485, 362, 63, 22262, 8, 277, 304, 267, 340, 291, 14, 10626, 26, 288, 372, 291, 14, 10626, 59, 16, 61, 339, 347, 485, 362, 63, 2019, 3493, 8, 277, 304, 267, 340, 291, 14, 10626, 26, 288, 372, 291, 14, 10626, 1988, 17, 61, 339, 347, 5518, 13569, 8, 277, 12, 28482, 12, 2984, 3493, 304, 267, 340, 28482, 14, 12412, 508, 291, 14, 7884, 63, 28147, 63, 8063, 26, 288, 367, 286, 315, 2008, 8, 1222, 3493, 14, 10626, 304, 355, 291, 14, 3176, 13569, 8, 67, 12, 2984, 3493, 9, 288, 6754, 710, 14316, 1630, 440, 5436, 590, 4165, 4052, 370, 372, 315, 642, 1930, 288, 372, 28482, 267, 340, 28482, 14, 12412, 440, 315, 291, 423, 1739, 63, 932, 63, 1313, 26, 288, 746, 2748, 14, 4556, 14, 29460, 2017, 5432, 8, 355, 2071, 83, 3913, 506, 1982, 402, 450, 83, 2, 450, 334, 2722, 8, 1222, 3493, 395, 4700, 8, 277, 1724, 267, 340, 28482, 14, 24899, 365, 440, 488, 26, 288, 28482, 14, 24899, 14, 2168, 3493, 8, 1222, 3493, 9, 267, 340, 2984, 3493, 365, 488, 26, 288, 291, 14, 14988, 8, 1222, 3493, 9, 267, 587, 26, 288, 862, 26, 355, 1478, 275, 291, 14, 10626, 14, 1080, 8, 1121, 3493, 9, 288, 871, 1722, 26, 355, 746, 2748, 14, 4556, 14, 4667, 5432, 342, 288, 340, 28482, 14, 12412, 315, 485, 932, 4100, 63, 1045, 63, 3223, 26, 355, 485, 3584, 63, 344, 63, 1637, 8, 277, 9, 288, 291, 14, 10626, 14, 3176, 8, 1080, 12, 28482, 9, 288, 28482, 14, 30336, 275, 2984, 3493, 288, 2984, 3493, 14, 6352, 16016, 275, 28482, 288, 340, 1478, 26, 355, 1031, 275, 291, 14, 10626, 59, 1080, 13, 17, 61, 355, 1031, 14, 30336, 275, 28482, 355, 28482, 14, 6352, 16016, 275, 1031, 288, 587, 26, 355, 28482, 14, 6352, 16016, 275, 488, 288, 28482, 14, 24899, 275, 291, 267, 372, 28482, 339, 347, 5666, 3493, 8, 277, 12, 1031, 304, 267, 340, 1031, 14, 12412, 508, 291, 14, 7884, 63, 28147, 63, 8063, 26, 288, 367, 286, 315, 2008, 8, 932, 14, 10626, 304, 355, 291, 14, 14988, 8, 67, 9, 288, 6754, 710, 14316, 1630, 440, 5436, 590, 4165, 4052, 370, 372, 315, 642, 1930, 288, 372, 1031, 267, 340, 1031, 14, 12412, 440, 315, 291, 423, 1739, 63, 932, 63, 1313, 26, 288, 746, 2748, 14, 4556, 14, 29460, 2017, 5432, 8, 355, 2071, 83, 3913, 506, 1982, 402, 450, 83, 2, 450, 334, 2722, 8, 932, 395, 4700, 8, 277, 1724, 267, 916, 1031, 14, 12412, 315, 485, 932, 4100, 63, 1045, 63, 3223, 26, 288, 485, 3584, 63, 344, 63, 1637, 8, 277, 9, 267, 340, 1031, 14, 24899, 365, 440, 488, 26, 288, 1031, 14, 24899, 14, 2168, 3493, 8, 932, 9, 267, 485, 740, 63, 1739, 8, 277, 12, 1031, 9, 267, 1031, 14, 30336, 275, 488, 267, 372, 1031, 339, 347, 3350, 3493, 8, 277, 12, 28482, 12, 2269, 3493, 304, 267, 340, 28482, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
IljaGrebel/OpenWrt-SDK-imx6_HummingBoard
staging_dir/host/lib/scons-2.3.5/SCons/cpp.py
1
19694
# # Copyright (c) 2001 - 2015 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # __revision__ = "src/engine/SCons/cpp.py rel_2.3.5:3329:275e75118ad4 2015/06/20 11:18:26 bdbaddog" __doc__ = """ SCons C Pre-Processor module """ #TODO 2.3 and before has no sorted() import SCons.compat import os import re # # First "subsystem" of regular expressions that we set up: # # Stuff to turn the C preprocessor directives in a file's contents into # a list of tuples that we can process easily. # # A table of regular expressions that fetch the arguments from the rest of # a C preprocessor line. Different directives have different arguments # that we want to fetch, using the regular expressions to which the lists # of preprocessor directives map. cpp_lines_dict = { # Fetch the rest of a #if/#elif/#ifdef/#ifndef as one argument, # separated from the keyword by white space. ('if', 'elif', 'ifdef', 'ifndef',) : '\s+(.+)', # Fetch the rest of a #import/#include/#include_next line as one # argument, with white space optional. ('import', 'include', 'include_next',) : '\s*(.+)', # We don't care what comes after a #else or #endif line. ('else', 'endif',) : '', # Fetch three arguments from a #define line: # 1) The #defined keyword. # 2) The optional parentheses and arguments (if it's a function-like # macro, '' if it's not). # 3) The expansion value. ('define',) : '\s+([_A-Za-z][_A-Za-z0-9_]*)(\([^)]*\))?\s*(.*)', # Fetch the #undefed keyword from a #undef line. ('undef',) : '\s+([_A-Za-z][A-Za-z0-9_]*)', } # Create a table that maps each individual C preprocessor directive to # the corresponding compiled regular expression that fetches the arguments # we care about. Table = {} for op_list, expr in cpp_lines_dict.items(): e = re.compile(expr) for op in op_list: Table[op] = e del e del op del op_list # Create a list of the expressions we'll use to match all of the # preprocessor directives. These are the same as the directives # themselves *except* that we must use a negative lookahead assertion # when matching "if" so it doesn't match the "if" in "ifdef." override = { 'if' : 'if(?!def)', } l = [override.get(x, x) for x in Table.keys()] # Turn the list of expressions into one big honkin' regular expression # that will match all the preprocessor lines at once. This will return # a list of tuples, one for each preprocessor line. The preprocessor # directive will be the first element in each tuple, and the rest of # the line will be the second element. e = '^\s*#\s*(' + '|'.join(l) + ')(.*)$' # And last but not least, compile the expression. CPP_Expression = re.compile(e, re.M) # # Second "subsystem" of regular expressions that we set up: # # Stuff to translate a C preprocessor expression (as found on a #if or # #elif line) into an equivalent Python expression that we can eval(). # # A dictionary that maps the C representation of Boolean operators # to their Python equivalents. CPP_to_Python_Ops_Dict = { '!' : ' not ', '!=' : ' != ', '&&' : ' and ', '||' : ' or ', '?' : ' and ', ':' : ' or ', '\r' : '', } CPP_to_Python_Ops_Sub = lambda m: CPP_to_Python_Ops_Dict[m.group(0)] # We have to sort the keys by length so that longer expressions # come *before* shorter expressions--in particular, "!=" must # come before "!" in the alternation. Without this, the Python # re module, as late as version 2.2.2, empirically matches the # "!" in "!=" first, instead of finding the longest match. # What's up with that? l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True) # Turn the list of keys into one regular expression that will allow us # to substitute all of the operators at once. expr = '|'.join(map(re.escape, l)) # ...and compile the expression. CPP_to_Python_Ops_Expression = re.compile(expr) # A separate list of expressions to be evaluated and substituted # sequentially, not all at once. CPP_to_Python_Eval_List = [ ['defined\s+(\w+)', '"\\1" in __dict__'], ['defined\s*\((\w+)\)', '"\\1" in __dict__'], ['/\*.*\*/', ''], ['/\*.*', ''], ['//.*', ''], ['(0x[0-9A-Fa-f]*)[UL]+', '\\1'], ] # Replace the string representations of the regular expressions in the # list with compiled versions. for l in CPP_to_Python_Eval_List: l[0] = re.compile(l[0]) # Wrap up all of the above into a handy function. def CPP_to_Python(s): """ Converts a C pre-processor expression into an equivalent Python expression that can be evaluated. """ s = CPP_to_Python_Ops_Expression.sub(CPP_to_Python_Ops_Sub, s) for expr, repl in CPP_to_Python_Eval_List: s = expr.sub(repl, s) return s del expr del l del override class FunctionEvaluator(object): """ Handles delayed evaluation of a #define function call. """ def __init__(self, name, args, expansion): """ Squirrels away the arguments and expansion value of a #define macro function for later evaluation when we must actually expand a value that uses it. """ self.name = name self.args = function_arg_separator.split(args) try: expansion = expansion.split('##') except AttributeError: pass self.expansion = expansion def __call__(self, *values): """ Evaluates the expansion of a #define macro function called with the specified values. """ if len(self.args) != len(values): raise ValueError("Incorrect number of arguments to `%s'" % self.name) # Create a dictionary that maps the macro arguments to the # corresponding values in this "call." We'll use this when we # eval() the expansion so that arguments will get expanded to # the right values. locals = {} for k, v in zip(self.args, values): locals[k] = v parts = [] for s in self.expansion: if not s in self.args: s = repr(s) parts.append(s) statement = ' + '.join(parts) return eval(statement, globals(), locals) # Find line continuations. line_continuations = re.compile('\\\\\r?\n') # Search for a "function call" macro on an expansion. Returns the # two-tuple of the "function" name itself, and a string containing the # arguments within the call parentheses. function_name = re.compile('(\S+)\(([^)]*)\)') # Split a string containing comma-separated function call arguments into # the separate arguments. function_arg_separator = re.compile(',\s*') class PreProcessor(object): """ The main workhorse class for handling C pre-processing. """ def __init__(self, current=os.curdir, cpppath=(), dict={}, all=0): global Table cpppath = tuple(cpppath) self.searchpath = { '"' : (current,) + cpppath, '<' : cpppath + (current,), } # Initialize our C preprocessor namespace for tracking the # values of #defined keywords. We use this namespace to look # for keywords on #ifdef/#ifndef lines, and to eval() the # expressions on #if/#elif lines (after massaging them from C to # Python). self.cpp_namespace = dict.copy() self.cpp_namespace['__dict__'] = self.cpp_namespace if all: self.do_include = self.all_include # For efficiency, a dispatch table maps each C preprocessor # directive (#if, #define, etc.) to the method that should be # called when we see it. We accomodate state changes (#if, # #ifdef, #ifndef) by pushing the current dispatch table on a # stack and changing what method gets called for each relevant # directive we might see next at this level (#else, #elif). # #endif will simply pop the stack. d = { 'scons_current_file' : self.scons_current_file } for op in Table.keys(): d[op] = getattr(self, 'do_' + op) self.default_table = d # Controlling methods. def tupleize(self, contents): """ Turns the contents of a file into a list of easily-processed tuples describing the CPP lines in the file. The first element of each tuple is the line's preprocessor directive (#if, #include, #define, etc., minus the initial '#'). The remaining elements are specific to the type of directive, as pulled apart by the regular expression. """ global CPP_Expression, Table contents = line_continuations.sub('', contents) cpp_tuples = CPP_Expression.findall(contents) return [(m[0],) + Table[m[0]].match(m[1]).groups() for m in cpp_tuples] def __call__(self, file): """ Pre-processes a file. This is the main public entry point. """ self.current_file = file return self.process_contents(self.read_file(file), file) def process_contents(self, contents, fname=None): """ Pre-processes a file contents. This is the main internal entry point. """ self.stack = [] self.dispatch_table = self.default_table.copy() self.current_file = fname self.tuples = self.tupleize(contents) self.initialize_result(fname) while self.tuples: t = self.tuples.pop(0) # Uncomment to see the list of tuples being processed (e.g., # to validate the CPP lines are being translated correctly). #print t self.dispatch_table[t[0]](t) return self.finalize_result(fname) # Dispatch table stack manipulation methods. def save(self): """ Pushes the current dispatch table on the stack and re-initializes the current dispatch table to the default. """ self.stack.append(self.dispatch_table) self.dispatch_table = self.default_table.copy() def restore(self): """ Pops the previous dispatch table off the stack and makes it the current one. """ try: self.dispatch_table = self.stack.pop() except IndexError: pass # Utility methods. def do_nothing(self, t): """ Null method for when we explicitly want the action for a specific preprocessor directive to do nothing. """ pass def scons_current_file(self, t): self.current_file = t[1] def eval_expression(self, t): """ Evaluates a C preprocessor expression. This is done by converting it to a Python equivalent and eval()ing it in the C preprocessor namespace we use to track #define values. """ t = CPP_to_Python(' '.join(t[1:])) try: return eval(t, self.cpp_namespace) except (NameError, TypeError): return 0 def initialize_result(self, fname): self.result = [fname] def finalize_result(self, fname): return self.result[1:] def find_include_file(self, t): """ Finds the #include file for a given preprocessor tuple. """ fname = t[2] for d in self.searchpath[t[1]]: if d == os.curdir: f = fname else: f = os.path.join(d, fname) if os.path.isfile(f): return f return None def read_file(self, file): return open(file).read() # Start and stop processing include lines. def start_handling_includes(self, t=None): """ Causes the PreProcessor object to start processing #import, #include and #include_next lines. This method will be called when a #if, #ifdef, #ifndef or #elif evaluates True, or when we reach the #else in a #if, #ifdef, #ifndef or #elif block where a condition already evaluated False. """ d = self.dispatch_table p = self.stack[-1] if self.stack else self.default_table for k in ('import', 'include', 'include_next'): d[k] = p[k] def stop_handling_includes(self, t=None): """ Causes the PreProcessor object to stop processing #import, #include and #include_next lines. This method will be called when a #if, #ifdef, #ifndef or #elif evaluates False, or when we reach the #else in a #if, #ifdef, #ifndef or #elif block where a condition already evaluated True. """ d = self.dispatch_table d['import'] = self.do_nothing d['include'] = self.do_nothing d['include_next'] = self.do_nothing # Default methods for handling all of the preprocessor directives. # (Note that what actually gets called for a given directive at any # point in time is really controlled by the dispatch_table.) def _do_if_else_condition(self, condition): """ Common logic for evaluating the conditions on #if, #ifdef and #ifndef lines. """ self.save() d = self.dispatch_table if condition: self.start_handling_includes() d['elif'] = self.stop_handling_includes d['else'] = self.stop_handling_includes else: self.stop_handling_includes() d['elif'] = self.do_elif d['else'] = self.start_handling_includes def do_ifdef(self, t): """ Default handling of a #ifdef line. """ self._do_if_else_condition(t[1] in self.cpp_namespace) def do_ifndef(self, t): """ Default handling of a #ifndef line. """ self._do_if_else_condition(t[1] not in self.cpp_namespace) def do_if(self, t): """ Default handling of a #if line. """ self._do_if_else_condition(self.eval_expression(t)) def do_elif(self, t): """ Default handling of a #elif line. """ d = self.dispatch_table if self.eval_expression(t): self.start_handling_includes() d['elif'] = self.stop_handling_includes d['else'] = self.stop_handling_includes def do_else(self, t): """ Default handling of a #else line. """ pass def do_endif(self, t): """ Default handling of a #endif line. """ self.restore() def do_define(self, t): """ Default handling of a #define line. """ _, name, args, expansion = t try: expansion = int(expansion) except (TypeError, ValueError): pass if args: evaluator = FunctionEvaluator(name, args[1:-1], expansion) self.cpp_namespace[name] = evaluator else: self.cpp_namespace[name] = expansion def do_undef(self, t): """ Default handling of a #undef line. """ try: del self.cpp_namespace[t[1]] except KeyError: pass def do_import(self, t): """ Default handling of a #import line. """ # XXX finish this -- maybe borrow/share logic from do_include()...? pass def do_include(self, t): """ Default handling of a #include line. """ t = self.resolve_include(t) include_file = self.find_include_file(t) if include_file: #print "include_file =", include_file self.result.append(include_file) contents = self.read_file(include_file) new_tuples = [('scons_current_file', include_file)] + \ self.tupleize(contents) + \ [('scons_current_file', self.current_file)] self.tuples[:] = new_tuples + self.tuples # Date: Tue, 22 Nov 2005 20:26:09 -0500 # From: Stefan Seefeld <seefeld@sympatico.ca> # # By the way, #include_next is not the same as #include. The difference # being that #include_next starts its search in the path following the # path that let to the including file. In other words, if your system # include paths are ['/foo', '/bar'], and you are looking at a header # '/foo/baz.h', it might issue an '#include_next <baz.h>' which would # correctly resolve to '/bar/baz.h' (if that exists), but *not* see # '/foo/baz.h' again. See http://www.delorie.com/gnu/docs/gcc/cpp_11.html # for more reasoning. # # I have no idea in what context 'import' might be used. # XXX is #include_next really the same as #include ? do_include_next = do_include # Utility methods for handling resolution of include files. def resolve_include(self, t): """Resolve a tuple-ized #include line. This handles recursive expansion of values without "" or <> surrounding the name until an initial " or < is found, to handle #include FILE where FILE is a #define somewhere else. """ s = t[1] while not s[0] in '<"': #print "s =", s try: s = self.cpp_namespace[s] except KeyError: m = function_name.search(s) s = self.cpp_namespace[m.group(1)] if callable(s): args = function_arg_separator.split(m.group(2)) s = s(*args) if not s: return None return (t[0], s[0], s[1:-1]) def all_include(self, t): """ """ self.result.append(self.resolve_include(t)) class DumbPreProcessor(PreProcessor): """A preprocessor that ignores all #if/#elif/#else/#endif directives and just reports back *all* of the #include files (like the classic SCons scanner did). This is functionally equivalent to using a regular expression to find all of the #include lines, only slower. It exists mainly as an example of how the main PreProcessor class can be sub-classed to tailor its behavior. """ def __init__(self, *args, **kw): PreProcessor.__init__(self, *args, **kw) d = self.default_table for func in ['if', 'elif', 'else', 'endif', 'ifdef', 'ifndef']: d[func] = d[func] = self.do_nothing del __revision__ # Local Variables: # tab-width:4 # indent-tabs-mode:nil # End: # vim: set expandtab tabstop=4 shiftwidth=4:
gpl-2.0
[ 3, 199, 3, 1898, 334, 67, 9, 12521, 446, 6900, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5910, 14, 647, 4668, 63, 18, 14, 19, 14, 21, 26, 9526, 25, 26, 13643, 69, 2194, 7906, 350, 20, 6900, 15, 1690, 15, 1165, 4119, 26, 1085, 26, 1479, 330, 697, 525, 974, 2, 199, 199, 363, 1301, 363, 275, 408, 199, 18521, 445, 5543, 13, 10438, 859, 199, 624, 199, 3, 11768, 499, 14, 19, 436, 2544, 965, 949, 3355, 342, 199, 646, 8218, 14, 5819, 199, 199, 646, 747, 199, 646, 295, 199, 199, 3, 199, 3, 7758, 298, 954, 2253, 2, 402, 5578, 8455, 626, 781, 663, 1536, 26, 199, 3, 199, 3, 1933, 3043, 370, 7485, 314, 445, 22335, 13502, 315, 282, 570, 1159, 4072, 1901, 199, 3, 282, 769, 402, 6346, 626, 781, 883, 2112, 16174, 14, 199, 3, 199, 199, 3, 437, 1817, 402, 5578, 8455, 626, 5267, 314, 2368, 687, 314, 4618, 402, 199, 3, 282, 445, 22335, 1004, 14, 221, 18029, 640, 13502, 1172, 3365, 2368, 199, 3, 626, 781, 2934, 370, 5267, 12, 1808, 314, 5578, 8455, 370, 1314, 314, 5548, 199, 3, 402, 22335, 13502, 2341, 14, 199, 5910, 63, 1278, 63, 807, 275, 469, 272, 327, 16347, 314, 4618, 402, 282, 327, 692, 12645, 4164, 12645, 27737, 12645, 27708, 465, 1373, 1423, 12, 272, 327, 11673, 687, 314, 4252, 701, 10424, 4601, 14, 272, 661, 692, 297, 283, 4164, 297, 283, 27737, 297, 283, 27708, 9538, 717, 520, 1557, 83, 15622, 6977, 3196, 339, 327, 16347, 314, 4618, 402, 282, 327, 646, 12645, 2613, 12645, 2613, 63, 2184, 1004, 465, 1373, 272, 327, 1423, 12, 543, 10424, 4601, 2716, 14, 272, 661, 646, 297, 283, 2613, 297, 283, 2613, 63, 2184, 9538, 717, 520, 1557, 83, 5830, 6977, 3196, 339, 327, 2136, 2793, 1133, 10296, 4052, 12477, 2410, 282, 327, 2836, 503, 327, 13739, 1004, 14, 272, 661, 2836, 297, 283, 13739, 9538, 221, 520, 3260, 339, 327, 16347, 7795, 2368, 687, 282, 327, 4640, 1004, 26, 272, 327, 257, 413, 9, 710, 327, 4037, 4252, 14, 272, 327, 257, 499, 9, 710, 2716, 23592, 436, 2368, 334, 692, 652, 1159, 282, 805, 13, 2930, 272, 327, 420, 9559, 12, 2125, 340, 652, 1159, 440, 680, 272, 327, 257, 650, 9, 710, 14819, 574, 14, 272, 661, 4640, 9538, 260, 520, 1557, 83, 11, 779, 63, 33, 13, 13163, 13, 90, 1527, 63, 33, 13, 13163, 13, 90, 16, 13, 25, 15555, 10127, 7059, 1874, 7590, 430, 8995, 83, 5830, 2795, 3196, 339, 327, 16347, 314, 327, 25878, 379, 4252, 687, 282, 327, 25878, 1004, 14, 272, 661, 25878, 9538, 3515, 520, 1557, 83, 11, 779, 63, 33, 13, 13163, 13, 90, 1527, 33, 13, 13163, 13, 90, 16, 13, 25, 15555, 3196, 199, 93, 199, 199, 3, 2790, 282, 1817, 626, 9033, 1924, 8212, 445, 22335, 13613, 370, 199, 3, 314, 5226, 10311, 5578, 3965, 626, 28053, 314, 2368, 199, 3, 781, 10296, 3595, 14, 199, 3186, 275, 1052, 199, 509, 1687, 63, 513, 12, 5348, 315, 7246, 63, 1278, 63, 807, 14, 1744, 837, 272, 325, 275, 295, 14, 2014, 8, 3684, 9, 272, 367, 1687, 315, 1687, 63, 513, 26, 267, 6957, 59, 411, 61, 275, 325, 199, 2264, 325, 199, 2264, 1687, 199, 2264, 1687, 63, 513, 199, 199, 3, 2790, 282, 769, 402, 314, 8455, 781, 7171, 675, 370, 1336, 1006, 402, 314, 199, 3, 22335, 13502, 14, 221, 5723, 787, 314, 2011, 465, 314, 13502, 199, 3, 17279, 627, 2590, 10, 626, 781, 1471, 675, 282, 6946, 16076, 14412, 199, 3, 1380, 4877, 298, 692, 2, 880, 652, 3181, 1133, 1336, 314, 298, 692, 2, 315, 298, 27737, 2122, 199, 4415, 275, 469, 272, 283, 692, 7, 12788, 520, 283, 692, 26313, 318, 3196, 199, 93, 199, 76, 275, 359, 4415, 14, 362, 8, 88, 12, 671, 9, 367, 671, 315, 6957, 14, 1612, 5106, 421, 199, 3, 16147, 314, 769, 402, 8455, 1901, 1373, 7282, 394, 265, 19269, 7, 5578, 3965, 199, 3, 626, 911, 1336, 1006, 314, 22335, 2385, 737, 5403, 14, 221, 961, 911, 372, 199, 3, 282, 769, 402, 6346, 12, 1373, 367, 1924, 22335, 1004, 14, 221, 710, 22335, 199, 3, 13613, 911, 506, 314, 1642, 1819, 315, 1924, 2008, 12, 436, 314, 4618, 402, 199, 3, 314, 1004, 911, 506, 314, 3499, 1819, 14, 199, 69, 275, 283, 12773, 83, 10, 20262, 83, 10, 360, 435, 21590, 904, 8, 76, 9, 435, 283, 5130, 12432, 12913, 199, 199, 3, 6061, 2061, 1325, 440, 5210, 12, 6555, 314, 3965, 14, 199, 14533, 63, 9093, 275, 295, 14, 2014, 8, 69, 12, 295, 14, 45, 9, 6905, 199, 3, 199, 3, 16707, 298 ]
[ 199, 3, 1898, 334, 67, 9, 12521, 446, 6900, 710, 8218, 2752, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 199, 3, 282, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 199, 3, 11207, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 199, 3, 11291, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 199, 3, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 199, 3, 3826, 12, 7168, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 199, 3, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 13229, 14, 1621, 4825, 6461, 7000, 2334, 10610, 1549, 5877, 8164, 6262, 199, 3, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 7061, 1621, 1261, 9612, 199, 3, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 5738, 1634, 1549, 1621, 11287, 199, 3, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 2334, 4141, 14, 199, 3, 199, 199, 363, 5792, 363, 275, 298, 2164, 15, 3908, 15, 18521, 15, 5910, 14, 647, 4668, 63, 18, 14, 19, 14, 21, 26, 9526, 25, 26, 13643, 69, 2194, 7906, 350, 20, 6900, 15, 1690, 15, 1165, 4119, 26, 1085, 26, 1479, 330, 697, 525, 974, 2, 199, 199, 363, 1301, 363, 275, 408, 199, 18521, 445, 5543, 13, 10438, 859, 199, 624, 199, 3, 11768, 499, 14, 19, 436, 2544, 965, 949, 3355, 342, 199, 646, 8218, 14, 5819, 199, 199, 646, 747, 199, 646, 295, 199, 199, 3, 199, 3, 7758, 298, 954, 2253, 2, 402, 5578, 8455, 626, 781, 663, 1536, 26, 199, 3, 199, 3, 1933, 3043, 370, 7485, 314, 445, 22335, 13502, 315, 282, 570, 1159, 4072, 1901, 199, 3, 282, 769, 402, 6346, 626, 781, 883, 2112, 16174, 14, 199, 3, 199, 199, 3, 437, 1817, 402, 5578, 8455, 626, 5267, 314, 2368, 687, 314, 4618, 402, 199, 3, 282, 445, 22335, 1004, 14, 221, 18029, 640, 13502, 1172, 3365, 2368, 199, 3, 626, 781, 2934, 370, 5267, 12, 1808, 314, 5578, 8455, 370, 1314, 314, 5548, 199, 3, 402, 22335, 13502, 2341, 14, 199, 5910, 63, 1278, 63, 807, 275, 469, 272, 327, 16347, 314, 4618, 402, 282, 327, 692, 12645, 4164, 12645, 27737, 12645, 27708, 465, 1373, 1423, 12, 272, 327, 11673, 687, 314, 4252, 701, 10424, 4601, 14, 272, 661, 692, 297, 283, 4164, 297, 283, 27737, 297, 283, 27708, 9538, 717, 520, 1557, 83, 15622, 6977, 3196, 339, 327, 16347, 314, 4618, 402, 282, 327, 646, 12645, 2613, 12645, 2613, 63, 2184, 1004, 465, 1373, 272, 327, 1423, 12, 543, 10424, 4601, 2716, 14, 272, 661, 646, 297, 283, 2613, 297, 283, 2613, 63, 2184, 9538, 717, 520, 1557, 83, 5830, 6977, 3196, 339, 327, 2136, 2793, 1133, 10296, 4052, 12477, 2410, 282, 327, 2836, 503, 327, 13739, 1004, 14, 272, 661, 2836, 297, 283, 13739, 9538, 221, 520, 3260, 339, 327, 16347, 7795, 2368, 687, 282, 327, 4640, 1004, 26, 272, 327, 257, 413, 9, 710, 327, 4037, 4252, 14, 272, 327, 257, 499, 9, 710, 2716, 23592, 436, 2368, 334, 692, 652, 1159, 282, 805, 13, 2930, 272, 327, 420, 9559, 12, 2125, 340, 652, 1159, 440, 680, 272, 327, 257, 650, 9, 710, 14819, 574, 14, 272, 661, 4640, 9538, 260, 520, 1557, 83, 11, 779, 63, 33, 13, 13163, 13, 90, 1527, 63, 33, 13, 13163, 13, 90, 16, 13, 25, 15555, 10127, 7059, 1874, 7590, 430, 8995, 83, 5830, 2795, 3196, 339, 327, 16347, 314, 327, 25878, 379, 4252, 687, 282, 327, 25878, 1004, 14, 272, 661, 25878, 9538, 3515, 520, 1557, 83, 11, 779, 63, 33, 13, 13163, 13, 90, 1527, 33, 13, 13163, 13, 90, 16, 13, 25, 15555, 3196, 199, 93, 199, 199, 3, 2790, 282, 1817, 626, 9033, 1924, 8212, 445, 22335, 13613, 370, 199, 3, 314, 5226, 10311, 5578, 3965, 626, 28053, 314, 2368, 199, 3, 781, 10296, 3595, 14, 199, 3186, 275, 1052, 199, 509, 1687, 63, 513, 12, 5348, 315, 7246, 63, 1278, 63, 807, 14, 1744, 837, 272, 325, 275, 295, 14, 2014, 8, 3684, 9, 272, 367, 1687, 315, 1687, 63, 513, 26, 267, 6957, 59, 411, 61, 275, 325, 199, 2264, 325, 199, 2264, 1687, 199, 2264, 1687, 63, 513, 199, 199, 3, 2790, 282, 769, 402, 314, 8455, 781, 7171, 675, 370, 1336, 1006, 402, 314, 199, 3, 22335, 13502, 14, 221, 5723, 787, 314, 2011, 465, 314, 13502, 199, 3, 17279, 627, 2590, 10, 626, 781, 1471, 675, 282, 6946, 16076, 14412, 199, 3, 1380, 4877, 298, 692, 2, 880, 652, 3181, 1133, 1336, 314, 298, 692, 2, 315, 298, 27737, 2122, 199, 4415, 275, 469, 272, 283, 692, 7, 12788, 520, 283, 692, 26313, 318, 3196, 199, 93, 199, 76, 275, 359, 4415, 14, 362, 8, 88, 12, 671, 9, 367, 671, 315, 6957, 14, 1612, 5106, 421, 199, 3, 16147, 314, 769, 402, 8455, 1901, 1373, 7282, 394, 265, 19269, 7, 5578, 3965, 199, 3, 626, 911, 1336, 1006, 314, 22335, 2385, 737, 5403, 14, 221, 961, 911, 372, 199, 3, 282, 769, 402, 6346, 12, 1373, 367, 1924, 22335, 1004, 14, 221, 710, 22335, 199, 3, 13613, 911, 506, 314, 1642, 1819, 315, 1924, 2008, 12, 436, 314, 4618, 402, 199, 3, 314, 1004, 911, 506, 314, 3499, 1819, 14, 199, 69, 275, 283, 12773, 83, 10, 20262, 83, 10, 360, 435, 21590, 904, 8, 76, 9, 435, 283, 5130, 12432, 12913, 199, 199, 3, 6061, 2061, 1325, 440, 5210, 12, 6555, 314, 3965, 14, 199, 14533, 63, 9093, 275, 295, 14, 2014, 8, 69, 12, 295, 14, 45, 9, 6905, 199, 3, 199, 3, 16707, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
golismero/golismero-devel
thirdparty_libs/django/dispatch/dispatcher.py
105
9373
import weakref import threading from django.dispatch import saferef from django.utils.six.moves import xrange WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref) def _make_id(target): if hasattr(target, '__func__'): return (id(target.__self__), id(target.__func__)) return id(target) class Signal(object): """ Base class for all signals Internal attributes: receivers { receriverkey (id) : weakref(receiver) } """ def __init__(self, providing_args=None): """ Create a new signal. providing_args A list of the arguments this signal can pass along in a send() call. """ self.receivers = [] if providing_args is None: providing_args = [] self.providing_args = set(providing_args) self.lock = threading.Lock() def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. If weak is True, then receiver must be weak-referencable (more precisely saferef.safeRef() must be able to create a reference to the receiver). Receivers must be able to accept keyword arguments. If receivers have a dispatch_uid attribute, the receiver will not be added if another receiver already exists with that dispatch_uid. sender The sender to which the receiver should respond. Must either be of type Signal, or None to receive events from any sender. weak Whether to use weak references to the receiver. By default, the module will attempt to use weak references to the receiver objects. If this parameter is false, then strong references will be used. dispatch_uid An identifier used to uniquely identify a particular instance of a receiver. This will usually be a string, though it may be anything hashable. """ from django.conf import settings # If DEBUG is on, check that we got a good receiver if settings.DEBUG: import inspect assert callable(receiver), "Signal receivers must be callable." # Check for **kwargs # Not all callables are inspectable with getargspec, so we'll # try a couple different ways but in the end fall back on assuming # it is -- we don't want to prevent registration of valid but weird # callables. try: argspec = inspect.getargspec(receiver) except TypeError: try: argspec = inspect.getargspec(receiver.__call__) except (TypeError, AttributeError): argspec = None if argspec: assert argspec[2] is not None, \ "Signal receivers must accept keyword arguments (**kwargs)." if dispatch_uid: lookup_key = (dispatch_uid, _make_id(sender)) else: lookup_key = (_make_id(receiver), _make_id(sender)) if weak: receiver = saferef.safeRef(receiver, onDelete=self._remove_receiver) with self.lock: for r_key, _ in self.receivers: if r_key == lookup_key: break else: self.receivers.append((lookup_key, receiver)) def disconnect(self, receiver=None, sender=None, weak=True, dispatch_uid=None): """ Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver The registered receiver to disconnect. May be none if dispatch_uid is specified. sender The registered sender to disconnect weak The weakref state to disconnect dispatch_uid the unique identifier of the receiver to disconnect """ if dispatch_uid: lookup_key = (dispatch_uid, _make_id(sender)) else: lookup_key = (_make_id(receiver), _make_id(sender)) with self.lock: for index in xrange(len(self.receivers)): (r_key, _) = self.receivers[index] if r_key == lookup_key: del self.receivers[index] break def has_listeners(self, sender=None): return bool(self._live_receivers(_make_id(sender))) def send(self, sender, **named): """ Send signal from sender to all connected receivers. If any receiver raises an error, the error propagates back through send, terminating the dispatch loop, so it is quite possible to not have all receivers called if a raises an error. Arguments: sender The sender of the signal Either a specific object or None. named Named arguments which will be passed to receivers. Returns a list of tuple pairs [(receiver, response), ... ]. """ responses = [] if not self.receivers: return responses for receiver in self._live_receivers(_make_id(sender)): response = receiver(signal=self, sender=sender, **named) responses.append((receiver, response)) return responses def send_robust(self, sender, **named): """ Send signal from sender to all connected receivers catching errors. Arguments: sender The sender of the signal. Can be any python object (normally one registered with a connect if you actually want something to occur). named Named arguments which will be passed to receivers. These arguments must be a subset of the argument names defined in providing_args. Return a list of tuple pairs [(receiver, response), ... ]. May raise DispatcherKeyError. If any receiver raises an error (specifically any subclass of Exception), the error instance is returned as the result for that receiver. """ responses = [] if not self.receivers: return responses # Call each receiver with whatever arguments it can accept. # Return a list of tuple pairs [(receiver, response), ... ]. for receiver in self._live_receivers(_make_id(sender)): try: response = receiver(signal=self, sender=sender, **named) except Exception as err: responses.append((receiver, err)) else: responses.append((receiver, response)) return responses def _live_receivers(self, senderkey): """ Filter sequence of receivers to get resolved, live receivers. This checks for weak references and resolves them, then returning only live receivers. """ none_senderkey = _make_id(None) receivers = [] for (receiverkey, r_senderkey), receiver in self.receivers: if r_senderkey == none_senderkey or r_senderkey == senderkey: if isinstance(receiver, WEAKREF_TYPES): # Dereference the weak reference. receiver = receiver() if receiver is not None: receivers.append(receiver) else: receivers.append(receiver) return receivers def _remove_receiver(self, receiver): """ Remove dead receivers from connections. """ with self.lock: to_remove = [] for key, connected_receiver in self.receivers: if connected_receiver == receiver: to_remove.append(key) for key in to_remove: last_idx = len(self.receivers) - 1 # enumerate in reverse order so that indexes are valid even # after we delete some items for idx, (r_key, _) in enumerate(reversed(self.receivers)): if r_key == key: del self.receivers[last_idx-idx] def receiver(signal, **kwargs): """ A decorator for connecting receivers to signals. Used by passing in the signal (or list of signals) and keyword arguments to connect:: @receiver(post_save, sender=MyModel) def signal_receiver(sender, **kwargs): ... @receiver([post_save, post_delete], sender=MyModel) def signals_receiver(sender, **kwargs): ... """ def _decorator(func): if isinstance(signal, (list, tuple)): for s in signal: s.connect(func, **kwargs) else: signal.connect(func, **kwargs) return func return _decorator
gpl-2.0
[ 646, 13852, 199, 646, 5796, 199, 199, 504, 1639, 14, 6052, 492, 5048, 1121, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 199, 199, 5408, 7872, 8279, 63, 7893, 275, 334, 21330, 14, 5083, 804, 12, 5048, 1121, 14, 8934, 3767, 18889, 1121, 9, 199, 199, 318, 485, 1875, 63, 344, 8, 1375, 304, 272, 340, 2688, 8, 1375, 12, 2560, 1532, 12168, 267, 372, 334, 344, 8, 1375, 855, 277, 10139, 1305, 8, 1375, 855, 1532, 8964, 272, 372, 1305, 8, 1375, 9, 199, 199, 533, 18288, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 1006, 10166, 339, 12624, 3004, 26, 398, 13035, 83, 288, 469, 295, 2247, 4380, 498, 334, 344, 9, 520, 13852, 8, 10244, 9, 789, 272, 408, 339, 347, 636, 826, 721, 277, 12, 13070, 63, 589, 29, 403, 304, 267, 408, 267, 2790, 282, 892, 4673, 14, 398, 13070, 63, 589, 288, 437, 769, 402, 314, 2368, 642, 4673, 883, 986, 3180, 315, 282, 3222, 342, 1240, 14, 267, 408, 267, 291, 14, 29494, 275, 942, 267, 340, 13070, 63, 589, 365, 488, 26, 288, 13070, 63, 589, 275, 942, 267, 291, 14, 496, 11604, 63, 589, 275, 663, 8, 496, 11604, 63, 589, 9, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 339, 347, 4907, 8, 277, 12, 13035, 12, 8904, 29, 403, 12, 9282, 29, 549, 12, 7634, 63, 1535, 29, 403, 304, 267, 408, 267, 15175, 13035, 370, 8904, 367, 4673, 14, 398, 7628, 26, 953, 13035, 355, 437, 805, 503, 376, 1256, 1083, 1314, 365, 370, 9128, 10166, 14, 355, 799, 6594, 83, 1471, 506, 21197, 2251, 14, 2234, 982, 9282, 365, 715, 12, 2066, 13035, 1471, 506, 9282, 13, 264, 1485, 67, 461, 334, 6878, 355, 28334, 590, 5048, 1121, 14, 3489, 2891, 342, 1471, 506, 7688, 370, 1218, 282, 3659, 355, 370, 314, 13035, 680, 2234, 799, 6594, 83, 1471, 506, 7688, 370, 4729, 4252, 2368, 14, 2234, 982, 13035, 83, 1172, 282, 7634, 63, 1535, 2225, 12, 314, 13035, 911, 355, 440, 506, 3483, 340, 4573, 13035, 2575, 3495, 543, 626, 355, 7634, 63, 1535, 14, 953, 8904, 355, 710, 8904, 370, 1314, 314, 13035, 1077, 22722, 14, 9498, 1902, 506, 355, 402, 730, 18288, 12, 503, 488, 370, 9128, 4474, 687, 1263, 8904, 14, 953, 9282, 355, 7480, 370, 675, 9282, 6941, 370, 314, 13035, 14, 4885, 849, 12, 314, 355, 859, 911, 7427, 370, 675, 9282, 6941, 370, 314, 13035, 355, 2251, 14, 982, 642, 2725, 365, 3055, 12, 2066, 16925, 6941, 911, 355, 506, 1202, 14, 953, 7634, 63, 1535, 355, 1626, 5148, 1202, 370, 28727, 10405, 282, 6770, 1256, 402, 355, 282, 13035, 14, 961, 911, 9987, 506, 282, 1059, 12, 10617, 652, 1443, 506, 355, 7003, 21197, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 398, 327, 982, 10990, 365, 641, 12, 1104, 626, 781, 4788, 282, 6954, 13035, 267, 340, 2202, 14, 5287, 26, 288, 492, 6485, 288, 702, 4550, 8, 10244, 395, 298, 11274, 13035, 83, 1471, 506, 4550, 2122, 953, 327, 2670, 367, 1011, 958, 288, 327, 2832, 1006, 28041, 787, 6485, 461, 543, 664, 15644, 12, 880, 781, 7171, 288, 327, 862, 282, 17535, 3365, 15217, 1325, 315, 314, 1284, 11264, 1771, 641, 18002, 288, 327, 652, 365, 1553, 781, 2793, 1133, 2934, 370, 7981, 10991, 402, 1686, 1325, 22965, 288, 327, 28041, 14, 288, 862, 26, 355, 26632, 275, 6485, 14, 29836, 8, 10244, 9, 288, 871, 3146, 26, 355, 862, 26, 490, 26632, 275, 6485, 14, 29836, 8, 10244, 855, 1250, 3368, 355, 871, 334, 4333, 12, 4281, 304, 490, 26632, 275, 488, 288, 340, 26632, 26, 355, 702, 26632, 59, 18, 61, 365, 440, 488, 12, 971, 490, 298, 11274, 13035, 83, 1471, 4729, 4252, 2368, 334, 538, 958, 17617, 398, 340, 7634, 63, 1535, 26, 288, 4237, 63, 498, 275, 334, 6052, 63, 1535, 12, 485, 1875, 63, 344, 8, 8114, 430, 267, 587, 26, 288, 4237, 63, 498, 275, 6110, 1875, 63, 344, 8, 10244, 395, 485, 1875, 63, 344, 8, 8114, 430, 398, 340, 9282, 26, 288, 13035, 275, 5048, 1121, 14, 3489, 2891, 8, 10244, 12, 641, 5392, 29, 277, 423, 2168, 63, 10244, 9, 398, 543, 291, 14, 831, 26, 288, 367, 519, 63, 498, 12, 485, 315, 291, 14, 29494, 26, 355, 340, 519, 63, 498, 508, 4237, 63, 498, 26, 490, 2059, 288, 587, 26, 355, 291, 14, 29494, 14, 740, 1332, 3892, 63, 498, 12, 13035, 430, 339, 347, 17639, 8, 277, 12, 13035, 29, 403, 12, 8904, 29, 403, 12, 9282, 29, 549, 12, 7634, 63, 1535, 29, 403, 304, 267, 408, 267, 5289, 2242, 13035, 687, 8904, 367, 4673, 14, 398, 982, 9282, 6941, 787, 1202, 12, 17639, 1929, 440, 506, 2797, 14, 710, 13035, 267, 911, 506, 2813, 687, 7634, 5847, 14, 398, 7628, 26, 953, 13035, 355, 710, 7264, 13035, 370, 17639, 14, 10162, 506, 7179, 340, 355, 7634, 63, 1535, 365, 2013, 14, 953, 8904, 355, 710, 7264, 8904, 370, 17639, 953, 9282, 355, 710, 13852, 1174, 370, 17639, 953, 7634, 63, 1535, 355, 314, 3747, 5148, 402, 314, 13035, 370, 17639, 267, 408, 267, 340, 7634, 63, 1535, 26, 288, 4237, 63, 498, 275, 334, 6052, 63, 1535, 12, 485, 1875, 63, 344, 8, 8114, 430, 267, 587, 26, 288, 4237, 63, 498, 275, 6110, 1875, 63, 344, 8, 10244, 395, 485, 1875, 63, 344, 8, 8114, 430, 398, 543, 291, 14, 831, 26, 288, 367, 1478, 315, 4945, 8, 552, 8, 277, 14, 29494, 2298, 355, 334, 82, 63, 498, 12, 20795, 275, 291, 14, 29494, 59, 1080, 61, 355, 340, 519, 63, 498, 508, 4237, 63, 498, 26, 490, 2150, 291, 14, 29494, 59, 1080, 61, 490, 2059, 339, 347, 965, 63, 17301, 8, 277, 12, 8904, 29, 403, 304, 267, 372, 2155, 8, 277, 423, 6442, 63, 29494, 1547, 1875, 63, 344, 8, 8114, 1724, 339, 347, 3222, 8, 277, 12, 8904, 12, 1011, 4579, 304, 267, 408, 267, 10217, 4673, 687, 8904, 370, 1006, 8539, 13035, 83, 14, 398, 982, 1263, 13035, 6534, 376, 1125, 12, 314, 1125, 20796, 2335, 1771, 4012, 3222, 12 ]
[ 13852, 199, 646, 5796, 199, 199, 504, 1639, 14, 6052, 492, 5048, 1121, 199, 504, 1639, 14, 1208, 14, 4174, 14, 4912, 492, 4945, 199, 199, 5408, 7872, 8279, 63, 7893, 275, 334, 21330, 14, 5083, 804, 12, 5048, 1121, 14, 8934, 3767, 18889, 1121, 9, 199, 199, 318, 485, 1875, 63, 344, 8, 1375, 304, 272, 340, 2688, 8, 1375, 12, 2560, 1532, 12168, 267, 372, 334, 344, 8, 1375, 855, 277, 10139, 1305, 8, 1375, 855, 1532, 8964, 272, 372, 1305, 8, 1375, 9, 199, 199, 533, 18288, 8, 785, 304, 272, 408, 272, 3523, 1021, 367, 1006, 10166, 339, 12624, 3004, 26, 398, 13035, 83, 288, 469, 295, 2247, 4380, 498, 334, 344, 9, 520, 13852, 8, 10244, 9, 789, 272, 408, 339, 347, 636, 826, 721, 277, 12, 13070, 63, 589, 29, 403, 304, 267, 408, 267, 2790, 282, 892, 4673, 14, 398, 13070, 63, 589, 288, 437, 769, 402, 314, 2368, 642, 4673, 883, 986, 3180, 315, 282, 3222, 342, 1240, 14, 267, 408, 267, 291, 14, 29494, 275, 942, 267, 340, 13070, 63, 589, 365, 488, 26, 288, 13070, 63, 589, 275, 942, 267, 291, 14, 496, 11604, 63, 589, 275, 663, 8, 496, 11604, 63, 589, 9, 267, 291, 14, 831, 275, 5796, 14, 6432, 342, 339, 347, 4907, 8, 277, 12, 13035, 12, 8904, 29, 403, 12, 9282, 29, 549, 12, 7634, 63, 1535, 29, 403, 304, 267, 408, 267, 15175, 13035, 370, 8904, 367, 4673, 14, 398, 7628, 26, 953, 13035, 355, 437, 805, 503, 376, 1256, 1083, 1314, 365, 370, 9128, 10166, 14, 355, 799, 6594, 83, 1471, 506, 21197, 2251, 14, 2234, 982, 9282, 365, 715, 12, 2066, 13035, 1471, 506, 9282, 13, 264, 1485, 67, 461, 334, 6878, 355, 28334, 590, 5048, 1121, 14, 3489, 2891, 342, 1471, 506, 7688, 370, 1218, 282, 3659, 355, 370, 314, 13035, 680, 2234, 799, 6594, 83, 1471, 506, 7688, 370, 4729, 4252, 2368, 14, 2234, 982, 13035, 83, 1172, 282, 7634, 63, 1535, 2225, 12, 314, 13035, 911, 355, 440, 506, 3483, 340, 4573, 13035, 2575, 3495, 543, 626, 355, 7634, 63, 1535, 14, 953, 8904, 355, 710, 8904, 370, 1314, 314, 13035, 1077, 22722, 14, 9498, 1902, 506, 355, 402, 730, 18288, 12, 503, 488, 370, 9128, 4474, 687, 1263, 8904, 14, 953, 9282, 355, 7480, 370, 675, 9282, 6941, 370, 314, 13035, 14, 4885, 849, 12, 314, 355, 859, 911, 7427, 370, 675, 9282, 6941, 370, 314, 13035, 355, 2251, 14, 982, 642, 2725, 365, 3055, 12, 2066, 16925, 6941, 911, 355, 506, 1202, 14, 953, 7634, 63, 1535, 355, 1626, 5148, 1202, 370, 28727, 10405, 282, 6770, 1256, 402, 355, 282, 13035, 14, 961, 911, 9987, 506, 282, 1059, 12, 10617, 652, 1443, 506, 355, 7003, 21197, 14, 267, 408, 267, 687, 1639, 14, 2190, 492, 2202, 398, 327, 982, 10990, 365, 641, 12, 1104, 626, 781, 4788, 282, 6954, 13035, 267, 340, 2202, 14, 5287, 26, 288, 492, 6485, 288, 702, 4550, 8, 10244, 395, 298, 11274, 13035, 83, 1471, 506, 4550, 2122, 953, 327, 2670, 367, 1011, 958, 288, 327, 2832, 1006, 28041, 787, 6485, 461, 543, 664, 15644, 12, 880, 781, 7171, 288, 327, 862, 282, 17535, 3365, 15217, 1325, 315, 314, 1284, 11264, 1771, 641, 18002, 288, 327, 652, 365, 1553, 781, 2793, 1133, 2934, 370, 7981, 10991, 402, 1686, 1325, 22965, 288, 327, 28041, 14, 288, 862, 26, 355, 26632, 275, 6485, 14, 29836, 8, 10244, 9, 288, 871, 3146, 26, 355, 862, 26, 490, 26632, 275, 6485, 14, 29836, 8, 10244, 855, 1250, 3368, 355, 871, 334, 4333, 12, 4281, 304, 490, 26632, 275, 488, 288, 340, 26632, 26, 355, 702, 26632, 59, 18, 61, 365, 440, 488, 12, 971, 490, 298, 11274, 13035, 83, 1471, 4729, 4252, 2368, 334, 538, 958, 17617, 398, 340, 7634, 63, 1535, 26, 288, 4237, 63, 498, 275, 334, 6052, 63, 1535, 12, 485, 1875, 63, 344, 8, 8114, 430, 267, 587, 26, 288, 4237, 63, 498, 275, 6110, 1875, 63, 344, 8, 10244, 395, 485, 1875, 63, 344, 8, 8114, 430, 398, 340, 9282, 26, 288, 13035, 275, 5048, 1121, 14, 3489, 2891, 8, 10244, 12, 641, 5392, 29, 277, 423, 2168, 63, 10244, 9, 398, 543, 291, 14, 831, 26, 288, 367, 519, 63, 498, 12, 485, 315, 291, 14, 29494, 26, 355, 340, 519, 63, 498, 508, 4237, 63, 498, 26, 490, 2059, 288, 587, 26, 355, 291, 14, 29494, 14, 740, 1332, 3892, 63, 498, 12, 13035, 430, 339, 347, 17639, 8, 277, 12, 13035, 29, 403, 12, 8904, 29, 403, 12, 9282, 29, 549, 12, 7634, 63, 1535, 29, 403, 304, 267, 408, 267, 5289, 2242, 13035, 687, 8904, 367, 4673, 14, 398, 982, 9282, 6941, 787, 1202, 12, 17639, 1929, 440, 506, 2797, 14, 710, 13035, 267, 911, 506, 2813, 687, 7634, 5847, 14, 398, 7628, 26, 953, 13035, 355, 710, 7264, 13035, 370, 17639, 14, 10162, 506, 7179, 340, 355, 7634, 63, 1535, 365, 2013, 14, 953, 8904, 355, 710, 7264, 8904, 370, 17639, 953, 9282, 355, 710, 13852, 1174, 370, 17639, 953, 7634, 63, 1535, 355, 314, 3747, 5148, 402, 314, 13035, 370, 17639, 267, 408, 267, 340, 7634, 63, 1535, 26, 288, 4237, 63, 498, 275, 334, 6052, 63, 1535, 12, 485, 1875, 63, 344, 8, 8114, 430, 267, 587, 26, 288, 4237, 63, 498, 275, 6110, 1875, 63, 344, 8, 10244, 395, 485, 1875, 63, 344, 8, 8114, 430, 398, 543, 291, 14, 831, 26, 288, 367, 1478, 315, 4945, 8, 552, 8, 277, 14, 29494, 2298, 355, 334, 82, 63, 498, 12, 20795, 275, 291, 14, 29494, 59, 1080, 61, 355, 340, 519, 63, 498, 508, 4237, 63, 498, 26, 490, 2150, 291, 14, 29494, 59, 1080, 61, 490, 2059, 339, 347, 965, 63, 17301, 8, 277, 12, 8904, 29, 403, 304, 267, 372, 2155, 8, 277, 423, 6442, 63, 29494, 1547, 1875, 63, 344, 8, 8114, 1724, 339, 347, 3222, 8, 277, 12, 8904, 12, 1011, 4579, 304, 267, 408, 267, 10217, 4673, 687, 8904, 370, 1006, 8539, 13035, 83, 14, 398, 982, 1263, 13035, 6534, 376, 1125, 12, 314, 1125, 20796, 2335, 1771, 4012, 3222, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
liuzheng712/Misago
misago/core/utils.py
7
3105
from datetime import timedelta from unidecode import unidecode from django.http import Http404 from django.core.urlresolvers import resolve, reverse from django.template.defaultfilters import slugify as django_slugify from django.utils import html, timezone from django.utils.translation import ugettext_lazy as _, ungettext_lazy def slugify(string): string = unicode(string) string = unidecode(string) return django_slugify(string.replace('_', ' ').strip()) def format_plaintext_for_html(string): return html.linebreaks(html.urlize(html.escape(string))) """ Mark request as having sensitive parameters We can't use decorator because of DRF uses custom HttpRequest that is incompatibile with Django's decorator """ def hide_post_parameters(request): request.sensitive_post_parameters = '__ALL__' """ Return path utility """ def clean_return_path(request): if request.method == 'POST' and 'return_path' in request.POST: return _get_return_path_from_post(request) else: return _get_return_path_from_referer(request) def _get_return_path_from_post(request): return_path = request.POST.get('return_path') try: if not return_path: raise ValueError() if not return_path.startswith('/'): raise ValueError() resolve(return_path) return return_path except (Http404, ValueError): return None def _get_return_path_from_referer(request): referer = request.META.get('HTTP_REFERER') try: if not referer: raise ValueError() if not referer.startswith(request.scheme): raise ValueError() referer = referer[len(request.scheme) + 3:] if not referer.startswith(request.META['HTTP_HOST']): raise ValueError() referer = referer[len(request.META['HTTP_HOST'].rstrip('/')):] if not referer.startswith('/'): raise ValueError() resolve(referer) return referer except (Http404, KeyError, ValueError): return None """ Utils for resolving requests destination """ def _is_request_path_under_misago(request): # We are assuming that forum_index link is root of all Misago links forum_index = reverse('misago:index') path_info = request.path_info if len(forum_index) > len(path_info): return False return path_info[:len(forum_index)] == forum_index def is_request_to_misago(request): try: return request._request_to_misago except AttributeError: request._request_to_misago = _is_request_path_under_misago(request) return request._request_to_misago def is_referer_local(request): referer = request.META.get('HTTP_REFERER') if not referer: return False if not referer.startswith(request.scheme): return False referer = referer[len(request.scheme) + 3:] if not referer.startswith(request.META['HTTP_HOST']): return False referer = referer[len(request.META['HTTP_HOST'].rstrip('/')):] if not referer.startswith('/'): return False return True
gpl-2.0
[ 504, 2197, 492, 6871, 199, 199, 504, 625, 2655, 600, 492, 625, 2655, 600, 199, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1018, 14, 16522, 492, 7512, 12, 3837, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 29864, 465, 1639, 63, 5464, 2021, 199, 504, 1639, 14, 1208, 492, 3517, 12, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 5501, 26843, 63, 6395, 421, 199, 318, 29864, 8, 875, 304, 272, 1059, 275, 2649, 8, 875, 9, 272, 1059, 275, 625, 2655, 600, 8, 875, 9, 272, 372, 1639, 63, 5464, 2021, 8, 875, 14, 1814, 20928, 283, 27274, 1913, 1012, 421, 199, 318, 1475, 63, 17426, 63, 509, 63, 1360, 8, 875, 304, 272, 372, 3517, 14, 604, 18566, 8, 1360, 14, 300, 13559, 8, 1360, 14, 3765, 8, 875, 1724, 421, 199, 624, 199, 6470, 1056, 465, 9445, 18423, 2633, 199, 6004, 883, 1133, 675, 7531, 2952, 402, 577, 11778, 4440, 3537, 20730, 199, 9099, 365, 315, 863, 2159, 9381, 543, 5634, 1159, 7531, 199, 624, 199, 318, 13714, 63, 1932, 63, 3214, 8, 1069, 304, 272, 1056, 14, 7361, 63, 1932, 63, 3214, 275, 2560, 1761, 12217, 421, 199, 624, 199, 1767, 931, 11420, 199, 624, 199, 318, 3633, 63, 1107, 63, 515, 8, 1069, 304, 272, 340, 1056, 14, 765, 508, 283, 4030, 7, 436, 283, 1107, 63, 515, 7, 315, 1056, 14, 4030, 26, 267, 372, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 1932, 8, 1069, 9, 272, 587, 26, 267, 372, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 20996, 8, 1069, 9, 421, 199, 318, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 1932, 8, 1069, 304, 272, 372, 63, 515, 275, 1056, 14, 4030, 14, 362, 360, 1107, 63, 515, 358, 272, 862, 26, 267, 340, 440, 372, 63, 515, 26, 288, 746, 1722, 342, 267, 340, 440, 372, 63, 515, 14, 2460, 18265, 288, 746, 1722, 342, 267, 7512, 8, 1107, 63, 515, 9, 267, 372, 372, 63, 515, 272, 871, 334, 5779, 5188, 12, 1722, 304, 267, 372, 488, 421, 199, 318, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 20996, 8, 1069, 304, 272, 25104, 275, 1056, 14, 10614, 14, 362, 360, 2856, 63, 19494, 540, 358, 272, 862, 26, 267, 340, 440, 25104, 26, 288, 746, 1722, 342, 267, 340, 440, 25104, 14, 2460, 8, 1069, 14, 5512, 304, 288, 746, 1722, 342, 267, 25104, 275, 25104, 59, 552, 8, 1069, 14, 5512, 9, 435, 650, 2938, 267, 340, 440, 25104, 14, 2460, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 9090, 288, 746, 1722, 342, 267, 25104, 275, 25104, 59, 552, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 2278, 6735, 7825, 15405, 267, 340, 440, 25104, 14, 2460, 18265, 288, 746, 1722, 342, 267, 7512, 8, 20996, 9, 267, 372, 25104, 272, 871, 334, 5779, 5188, 12, 4067, 12, 1722, 304, 267, 372, 488, 421, 199, 624, 199, 7535, 367, 30685, 4145, 5724, 199, 624, 199, 318, 485, 374, 63, 1069, 63, 515, 63, 7138, 63, 1292, 14315, 8, 1069, 304, 272, 327, 2136, 787, 18002, 626, 21575, 63, 1080, 2142, 365, 1738, 402, 1006, 12481, 14315, 6220, 272, 21575, 63, 1080, 275, 3837, 360, 1292, 14315, 26, 1080, 358, 272, 931, 63, 815, 275, 1056, 14, 515, 63, 815, 339, 340, 822, 8, 10044, 63, 1080, 9, 690, 822, 8, 515, 63, 815, 304, 267, 372, 756, 272, 372, 931, 63, 815, 1491, 552, 8, 10044, 63, 1080, 1874, 508, 21575, 63, 1080, 421, 199, 318, 365, 63, 1069, 63, 475, 63, 1292, 14315, 8, 1069, 304, 272, 862, 26, 267, 372, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 272, 871, 4281, 26, 267, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 275, 485, 374, 63, 1069, 63, 515, 63, 7138, 63, 1292, 14315, 8, 1069, 9, 267, 372, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 421, 199, 318, 365, 63, 20996, 63, 1832, 8, 1069, 304, 272, 25104, 275, 1056, 14, 10614, 14, 362, 360, 2856, 63, 19494, 540, 358, 339, 340, 440, 25104, 26, 267, 372, 756, 272, 340, 440, 25104, 14, 2460, 8, 1069, 14, 5512, 304, 267, 372, 756, 272, 25104, 275, 25104, 59, 552, 8, 1069, 14, 5512, 9, 435, 650, 2938, 272, 340, 440, 25104, 14, 2460, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 9090, 267, 372, 756, 272, 25104, 275, 25104, 59, 552, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 2278, 6735, 7825, 15405, 272, 340, 440, 25104, 14, 2460, 18265, 267, 372, 756, 339, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2197, 492, 6871, 199, 199, 504, 625, 2655, 600, 492, 625, 2655, 600, 199, 199, 504, 1639, 14, 1014, 492, 4760, 5188, 199, 504, 1639, 14, 1018, 14, 16522, 492, 7512, 12, 3837, 199, 504, 1639, 14, 1160, 14, 885, 4273, 492, 29864, 465, 1639, 63, 5464, 2021, 199, 504, 1639, 14, 1208, 492, 3517, 12, 7137, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 5501, 26843, 63, 6395, 421, 199, 318, 29864, 8, 875, 304, 272, 1059, 275, 2649, 8, 875, 9, 272, 1059, 275, 625, 2655, 600, 8, 875, 9, 272, 372, 1639, 63, 5464, 2021, 8, 875, 14, 1814, 20928, 283, 27274, 1913, 1012, 421, 199, 318, 1475, 63, 17426, 63, 509, 63, 1360, 8, 875, 304, 272, 372, 3517, 14, 604, 18566, 8, 1360, 14, 300, 13559, 8, 1360, 14, 3765, 8, 875, 1724, 421, 199, 624, 199, 6470, 1056, 465, 9445, 18423, 2633, 199, 6004, 883, 1133, 675, 7531, 2952, 402, 577, 11778, 4440, 3537, 20730, 199, 9099, 365, 315, 863, 2159, 9381, 543, 5634, 1159, 7531, 199, 624, 199, 318, 13714, 63, 1932, 63, 3214, 8, 1069, 304, 272, 1056, 14, 7361, 63, 1932, 63, 3214, 275, 2560, 1761, 12217, 421, 199, 624, 199, 1767, 931, 11420, 199, 624, 199, 318, 3633, 63, 1107, 63, 515, 8, 1069, 304, 272, 340, 1056, 14, 765, 508, 283, 4030, 7, 436, 283, 1107, 63, 515, 7, 315, 1056, 14, 4030, 26, 267, 372, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 1932, 8, 1069, 9, 272, 587, 26, 267, 372, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 20996, 8, 1069, 9, 421, 199, 318, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 1932, 8, 1069, 304, 272, 372, 63, 515, 275, 1056, 14, 4030, 14, 362, 360, 1107, 63, 515, 358, 272, 862, 26, 267, 340, 440, 372, 63, 515, 26, 288, 746, 1722, 342, 267, 340, 440, 372, 63, 515, 14, 2460, 18265, 288, 746, 1722, 342, 267, 7512, 8, 1107, 63, 515, 9, 267, 372, 372, 63, 515, 272, 871, 334, 5779, 5188, 12, 1722, 304, 267, 372, 488, 421, 199, 318, 485, 362, 63, 1107, 63, 515, 63, 504, 63, 20996, 8, 1069, 304, 272, 25104, 275, 1056, 14, 10614, 14, 362, 360, 2856, 63, 19494, 540, 358, 272, 862, 26, 267, 340, 440, 25104, 26, 288, 746, 1722, 342, 267, 340, 440, 25104, 14, 2460, 8, 1069, 14, 5512, 304, 288, 746, 1722, 342, 267, 25104, 275, 25104, 59, 552, 8, 1069, 14, 5512, 9, 435, 650, 2938, 267, 340, 440, 25104, 14, 2460, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 9090, 288, 746, 1722, 342, 267, 25104, 275, 25104, 59, 552, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 2278, 6735, 7825, 15405, 267, 340, 440, 25104, 14, 2460, 18265, 288, 746, 1722, 342, 267, 7512, 8, 20996, 9, 267, 372, 25104, 272, 871, 334, 5779, 5188, 12, 4067, 12, 1722, 304, 267, 372, 488, 421, 199, 624, 199, 7535, 367, 30685, 4145, 5724, 199, 624, 199, 318, 485, 374, 63, 1069, 63, 515, 63, 7138, 63, 1292, 14315, 8, 1069, 304, 272, 327, 2136, 787, 18002, 626, 21575, 63, 1080, 2142, 365, 1738, 402, 1006, 12481, 14315, 6220, 272, 21575, 63, 1080, 275, 3837, 360, 1292, 14315, 26, 1080, 358, 272, 931, 63, 815, 275, 1056, 14, 515, 63, 815, 339, 340, 822, 8, 10044, 63, 1080, 9, 690, 822, 8, 515, 63, 815, 304, 267, 372, 756, 272, 372, 931, 63, 815, 1491, 552, 8, 10044, 63, 1080, 1874, 508, 21575, 63, 1080, 421, 199, 318, 365, 63, 1069, 63, 475, 63, 1292, 14315, 8, 1069, 304, 272, 862, 26, 267, 372, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 272, 871, 4281, 26, 267, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 275, 485, 374, 63, 1069, 63, 515, 63, 7138, 63, 1292, 14315, 8, 1069, 9, 267, 372, 1056, 423, 1069, 63, 475, 63, 1292, 14315, 421, 199, 318, 365, 63, 20996, 63, 1832, 8, 1069, 304, 272, 25104, 275, 1056, 14, 10614, 14, 362, 360, 2856, 63, 19494, 540, 358, 339, 340, 440, 25104, 26, 267, 372, 756, 272, 340, 440, 25104, 14, 2460, 8, 1069, 14, 5512, 304, 267, 372, 756, 272, 25104, 275, 25104, 59, 552, 8, 1069, 14, 5512, 9, 435, 650, 2938, 272, 340, 440, 25104, 14, 2460, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 9090, 267, 372, 756, 272, 25104, 275, 25104, 59, 552, 8, 1069, 14, 10614, 459, 2856, 63, 5449, 2278, 6735, 7825, 15405, 272, 340, 440, 25104, 14, 2460, 18265, 267, 372, 756, 339, 372, 715, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
naltatis/kryptonite
node_modules/grunt/node_modules/js-yaml/support/pyyaml-src/__init__.py
96
9607
from .error import * from .tokens import * from .events import * from .nodes import * from .loader import * from .dumper import * __version__ = '3.10' try: from .cyaml import * __with_libyaml__ = True except ImportError: __with_libyaml__ = False import io def scan(stream, Loader=Loader): """ Scan a YAML stream and produce scanning tokens. """ loader = Loader(stream) try: while loader.check_token(): yield loader.get_token() finally: loader.dispose() def parse(stream, Loader=Loader): """ Parse a YAML stream and produce parsing events. """ loader = Loader(stream) try: while loader.check_event(): yield loader.get_event() finally: loader.dispose() def compose(stream, Loader=Loader): """ Parse the first YAML document in a stream and produce the corresponding representation tree. """ loader = Loader(stream) try: return loader.get_single_node() finally: loader.dispose() def compose_all(stream, Loader=Loader): """ Parse all YAML documents in a stream and produce corresponding representation trees. """ loader = Loader(stream) try: while loader.check_node(): yield loader.get_node() finally: loader.dispose() def load(stream, Loader=Loader): """ Parse the first YAML document in a stream and produce the corresponding Python object. """ loader = Loader(stream) try: return loader.get_single_data() finally: loader.dispose() def load_all(stream, Loader=Loader): """ Parse all YAML documents in a stream and produce corresponding Python objects. """ loader = Loader(stream) try: while loader.check_data(): yield loader.get_data() finally: loader.dispose() def safe_load(stream): """ Parse the first YAML document in a stream and produce the corresponding Python object. Resolve only basic YAML tags. """ return load(stream, SafeLoader) def safe_load_all(stream): """ Parse all YAML documents in a stream and produce corresponding Python objects. Resolve only basic YAML tags. """ return load_all(stream, SafeLoader) def emit(events, stream=None, Dumper=Dumper, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None): """ Emit YAML parsing events into a stream. If stream is None, return the produced string instead. """ getvalue = None if stream is None: stream = io.StringIO() getvalue = stream.getvalue dumper = Dumper(stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) try: for event in events: dumper.emit(event) finally: dumper.dispose() if getvalue: return getvalue() def serialize_all(nodes, stream=None, Dumper=Dumper, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): """ Serialize a sequence of representation trees into a YAML stream. If stream is None, return the produced string instead. """ getvalue = None if stream is None: if encoding is None: stream = io.StringIO() else: stream = io.BytesIO() getvalue = stream.getvalue dumper = Dumper(stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break, encoding=encoding, version=version, tags=tags, explicit_start=explicit_start, explicit_end=explicit_end) try: dumper.open() for node in nodes: dumper.serialize(node) dumper.close() finally: dumper.dispose() if getvalue: return getvalue() def serialize(node, stream=None, Dumper=Dumper, **kwds): """ Serialize a representation tree into a YAML stream. If stream is None, return the produced string instead. """ return serialize_all([node], stream, Dumper=Dumper, **kwds) def dump_all(documents, stream=None, Dumper=Dumper, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None): """ Serialize a sequence of Python objects into a YAML stream. If stream is None, return the produced string instead. """ getvalue = None if stream is None: if encoding is None: stream = io.StringIO() else: stream = io.BytesIO() getvalue = stream.getvalue dumper = Dumper(stream, default_style=default_style, default_flow_style=default_flow_style, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break, encoding=encoding, version=version, tags=tags, explicit_start=explicit_start, explicit_end=explicit_end) try: dumper.open() for data in documents: dumper.represent(data) dumper.close() finally: dumper.dispose() if getvalue: return getvalue() def dump(data, stream=None, Dumper=Dumper, **kwds): """ Serialize a Python object into a YAML stream. If stream is None, return the produced string instead. """ return dump_all([data], stream, Dumper=Dumper, **kwds) def safe_dump_all(documents, stream=None, **kwds): """ Serialize a sequence of Python objects into a YAML stream. Produce only basic YAML tags. If stream is None, return the produced string instead. """ return dump_all(documents, stream, Dumper=SafeDumper, **kwds) def safe_dump(data, stream=None, **kwds): """ Serialize a Python object into a YAML stream. Produce only basic YAML tags. If stream is None, return the produced string instead. """ return dump_all([data], stream, Dumper=SafeDumper, **kwds) def add_implicit_resolver(tag, regexp, first=None, Loader=Loader, Dumper=Dumper): """ Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar. first is a sequence of possible initial characters or None. """ Loader.add_implicit_resolver(tag, regexp, first) Dumper.add_implicit_resolver(tag, regexp, first) def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper): """ Add a path based resolver for the given tag. A path is a list of keys that forms a path to a node in the representation tree. Keys can be string values, integers, or None. """ Loader.add_path_resolver(tag, path, kind) Dumper.add_path_resolver(tag, path, kind) def add_constructor(tag, constructor, Loader=Loader): """ Add a constructor for the given tag. Constructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object. """ Loader.add_constructor(tag, constructor) def add_multi_constructor(tag_prefix, multi_constructor, Loader=Loader): """ Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object. """ Loader.add_multi_constructor(tag_prefix, multi_constructor) def add_representer(data_type, representer, Dumper=Dumper): """ Add a representer for the given type. Representer is a function accepting a Dumper instance and an instance of the given data type and producing the corresponding representation node. """ Dumper.add_representer(data_type, representer) def add_multi_representer(data_type, multi_representer, Dumper=Dumper): """ Add a representer for the given type. Multi-representer is a function accepting a Dumper instance and an instance of the given data type or subtype and producing the corresponding representation node. """ Dumper.add_multi_representer(data_type, multi_representer) class YAMLObjectMetaclass(type): """ The metaclass for YAMLObject. """ def __init__(cls, name, bases, kwds): super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None: cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) cls.yaml_dumper.add_representer(cls, cls.to_yaml) class YAMLObject(metaclass=YAMLObjectMetaclass): """ An object that can dump itself to a YAML stream and load itself from a YAML stream. """ __slots__ = () # no direct instantiation, so allow immutable subclasses yaml_loader = Loader yaml_dumper = Dumper yaml_tag = None yaml_flow_style = None @classmethod def from_yaml(cls, loader, node): """ Convert a representation node to a Python object. """ return loader.construct_yaml_object(node, cls) @classmethod def to_yaml(cls, dumper, data): """ Convert a Python object to a representation node. """ return dumper.represent_yaml_object(cls.yaml_tag, data, cls, flow_style=cls.yaml_flow_style)
mit
[ 199, 504, 1275, 705, 492, 627, 199, 199, 504, 1275, 4504, 492, 627, 199, 504, 1275, 4368, 492, 627, 199, 504, 1275, 2415, 492, 627, 199, 199, 504, 1275, 3422, 492, 627, 199, 504, 1275, 2724, 281, 492, 627, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 709, 7, 199, 893, 26, 272, 687, 1275, 1480, 3935, 492, 627, 272, 636, 1045, 63, 773, 5963, 363, 275, 715, 199, 2590, 3545, 26, 272, 636, 1045, 63, 773, 5963, 363, 275, 756, 199, 199, 646, 5890, 199, 199, 318, 8000, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 24833, 282, 18916, 2547, 436, 7389, 24928, 4645, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 1418, 837, 288, 1995, 5077, 14, 362, 63, 1418, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2198, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 282, 18916, 2547, 436, 7389, 6057, 4474, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 1430, 837, 288, 1995, 5077, 14, 362, 63, 1430, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 23366, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 6025, 3123, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 372, 5077, 14, 362, 63, 4780, 63, 932, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 23366, 63, 452, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 6025, 14416, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 932, 837, 288, 1995, 5077, 14, 362, 63, 932, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2248, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 2018, 909, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 372, 5077, 14, 362, 63, 4780, 63, 576, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2248, 63, 452, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 2018, 2251, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 576, 837, 288, 1995, 5077, 14, 362, 63, 576, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 5048, 63, 912, 8, 1745, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 2018, 909, 14, 272, 31096, 1454, 5678, 18916, 3762, 14, 272, 408, 272, 372, 2248, 8, 1745, 12, 14969, 5455, 9, 199, 199, 318, 5048, 63, 912, 63, 452, 8, 1745, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 2018, 2251, 14, 272, 31096, 1454, 5678, 18916, 3762, 14, 272, 408, 272, 372, 2248, 63, 452, 8, 1745, 12, 14969, 5455, 9, 199, 199, 318, 8689, 8, 4368, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 267, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 267, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 304, 272, 408, 272, 662, 1147, 18916, 6057, 4474, 1901, 282, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 664, 585, 275, 488, 272, 340, 2547, 365, 488, 26, 267, 2547, 275, 5890, 14, 6424, 342, 267, 664, 585, 275, 2547, 14, 7150, 272, 5461, 281, 275, 19460, 281, 8, 1745, 12, 11358, 29, 13109, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 288, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 272, 862, 26, 267, 367, 1566, 315, 4474, 26, 288, 5461, 281, 14, 8159, 8, 1430, 9, 272, 3753, 26, 267, 5461, 281, 14, 29842, 342, 272, 340, 664, 585, 26, 267, 372, 664, 585, 342, 199, 199, 318, 8437, 63, 452, 8, 2415, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 267, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 267, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 267, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 267, 1015, 29, 403, 12, 3762, 29, 403, 304, 272, 408, 272, 11973, 794, 282, 3414, 402, 6025, 14416, 1901, 282, 18916, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 664, 585, 275, 488, 272, 340, 2547, 365, 488, 26, 267, 340, 2644, 365, 488, 26, 288, 2547, 275, 5890, 14, 6424, 342, 267, 587, 26, 288, 2547, 275, 5890, 14, 15466, 342, 267, 664, 585, 275, 2547, 14, 7150, 272, 5461, 281, 275, 19460, 281, 8, 1745, 12, 11358, 29, 13109, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 288, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 12, 288, 2644, 29, 2991, 12, 1015, 29, 1023, 12, 3762, 29, 2969, 12, 288, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 9, 272, 862, 26, 267, 5461, 281, 14, 1490, 342, 267, 367, 1031, 315, 3380, 26, 288, 5461, 281, 14, 3549, 8, 932, 9, 267, 5461, 281, 14, 1600, 342, 272, 3753, 26, 267, 5461, 281, 14, 29842, 342, 272, 340, 664, 585, 26, 267, 372, 664, 585, 342, 199, 199, 318, 8437, 8, 932, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 1011, 10340, 304, 272, 408, 272, 11973, 794, 282, 6025, 3123, 1901, 282, 18916, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 372, 8437, 63, 452 ]
[ 504, 1275, 705, 492, 627, 199, 199, 504, 1275, 4504, 492, 627, 199, 504, 1275, 4368, 492, 627, 199, 504, 1275, 2415, 492, 627, 199, 199, 504, 1275, 3422, 492, 627, 199, 504, 1275, 2724, 281, 492, 627, 199, 199, 363, 1023, 363, 275, 283, 19, 14, 709, 7, 199, 893, 26, 272, 687, 1275, 1480, 3935, 492, 627, 272, 636, 1045, 63, 773, 5963, 363, 275, 715, 199, 2590, 3545, 26, 272, 636, 1045, 63, 773, 5963, 363, 275, 756, 199, 199, 646, 5890, 199, 199, 318, 8000, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 24833, 282, 18916, 2547, 436, 7389, 24928, 4645, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 1418, 837, 288, 1995, 5077, 14, 362, 63, 1418, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2198, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 282, 18916, 2547, 436, 7389, 6057, 4474, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 1430, 837, 288, 1995, 5077, 14, 362, 63, 1430, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 23366, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 6025, 3123, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 372, 5077, 14, 362, 63, 4780, 63, 932, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 23366, 63, 452, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 6025, 14416, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 932, 837, 288, 1995, 5077, 14, 362, 63, 932, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2248, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 2018, 909, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 372, 5077, 14, 362, 63, 4780, 63, 576, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 2248, 63, 452, 8, 1745, 12, 22865, 29, 5455, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 2018, 2251, 14, 272, 408, 272, 5077, 275, 22865, 8, 1745, 9, 272, 862, 26, 267, 1830, 5077, 14, 1074, 63, 576, 837, 288, 1995, 5077, 14, 362, 63, 576, 342, 272, 3753, 26, 267, 5077, 14, 29842, 342, 199, 199, 318, 5048, 63, 912, 8, 1745, 304, 272, 408, 272, 6077, 314, 1642, 18916, 2213, 315, 282, 2547, 272, 436, 7389, 314, 5226, 2018, 909, 14, 272, 31096, 1454, 5678, 18916, 3762, 14, 272, 408, 272, 372, 2248, 8, 1745, 12, 14969, 5455, 9, 199, 199, 318, 5048, 63, 912, 63, 452, 8, 1745, 304, 272, 408, 272, 6077, 1006, 18916, 8247, 315, 282, 2547, 272, 436, 7389, 5226, 2018, 2251, 14, 272, 31096, 1454, 5678, 18916, 3762, 14, 272, 408, 272, 372, 2248, 63, 452, 8, 1745, 12, 14969, 5455, 9, 199, 199, 318, 8689, 8, 4368, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 267, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 267, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 304, 272, 408, 272, 662, 1147, 18916, 6057, 4474, 1901, 282, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 664, 585, 275, 488, 272, 340, 2547, 365, 488, 26, 267, 2547, 275, 5890, 14, 6424, 342, 267, 664, 585, 275, 2547, 14, 7150, 272, 5461, 281, 275, 19460, 281, 8, 1745, 12, 11358, 29, 13109, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 288, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 9, 272, 862, 26, 267, 367, 1566, 315, 4474, 26, 288, 5461, 281, 14, 8159, 8, 1430, 9, 272, 3753, 26, 267, 5461, 281, 14, 29842, 342, 272, 340, 664, 585, 26, 267, 372, 664, 585, 342, 199, 199, 318, 8437, 63, 452, 8, 2415, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 267, 11358, 29, 403, 12, 4363, 29, 403, 12, 3462, 29, 403, 12, 267, 2040, 63, 2975, 29, 403, 12, 1004, 63, 4785, 29, 403, 12, 267, 2644, 29, 403, 12, 5027, 63, 928, 29, 403, 12, 5027, 63, 500, 29, 403, 12, 267, 1015, 29, 403, 12, 3762, 29, 403, 304, 272, 408, 272, 11973, 794, 282, 3414, 402, 6025, 14416, 1901, 282, 18916, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 664, 585, 275, 488, 272, 340, 2547, 365, 488, 26, 267, 340, 2644, 365, 488, 26, 288, 2547, 275, 5890, 14, 6424, 342, 267, 587, 26, 288, 2547, 275, 5890, 14, 15466, 342, 267, 664, 585, 275, 2547, 14, 7150, 272, 5461, 281, 275, 19460, 281, 8, 1745, 12, 11358, 29, 13109, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 288, 2040, 63, 2975, 29, 3306, 63, 2975, 12, 1004, 63, 4785, 29, 604, 63, 4785, 12, 288, 2644, 29, 2991, 12, 1015, 29, 1023, 12, 3762, 29, 2969, 12, 288, 5027, 63, 928, 29, 10306, 63, 928, 12, 5027, 63, 500, 29, 10306, 63, 500, 9, 272, 862, 26, 267, 5461, 281, 14, 1490, 342, 267, 367, 1031, 315, 3380, 26, 288, 5461, 281, 14, 3549, 8, 932, 9, 267, 5461, 281, 14, 1600, 342, 272, 3753, 26, 267, 5461, 281, 14, 29842, 342, 272, 340, 664, 585, 26, 267, 372, 664, 585, 342, 199, 199, 318, 8437, 8, 932, 12, 2547, 29, 403, 12, 19460, 281, 29, 28593, 12, 1011, 10340, 304, 272, 408, 272, 11973, 794, 282, 6025, 3123, 1901, 282, 18916, 2547, 14, 272, 982, 2547, 365, 488, 12, 372, 314, 13584, 1059, 3140, 14, 272, 408, 272, 372, 8437, 63, 452, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
yoer/hue
desktop/core/ext-py/tablib-0.10.0/tablib/packages/xlwt3/ExcelFormulaLexer.py
46
4311
import sys from .antlr import EOF, CommonToken as Tok, TokenStream, TokenStreamException import struct from . import ExcelFormulaParser from re import compile as recompile, match, LOCALE, UNICODE, IGNORECASE, VERBOSE int_const_pattern = r"\d+\b" flt_const_pattern = r""" (?: (?: \d* \. \d+ ) # .1 .12 .123 etc 9.1 etc 98.1 etc | (?: \d+ \. ) # 1. 12. 123. etc ) # followed by optional exponent part (?: [Ee] [+-]? \d+ ) ? """ str_const_pattern = r'"(?:[^"]|"")*"' #range2d_pattern = recompile(r"\$?[A-I]?[A-Z]\$?\d+:\$?[A-I]?[A-Z]\$?\d+" ref2d_r1c1_pattern = r"[Rr]0*[1-9][0-9]*[Cc]0*[1-9][0-9]*" ref2d_pattern = r"\$?[A-I]?[A-Z]\$?0*[1-9][0-9]*" true_pattern = r"TRUE\b" false_pattern = r"FALSE\b" if_pattern = r"IF\b" choose_pattern = r"CHOOSE\b" name_pattern = r"\w[\.\w]*" quotename_pattern = r"'(?:[^']|'')*'" #### It's essential that this bracket be non-grouping. ne_pattern = r"<>" ge_pattern = r">=" le_pattern = r"<=" pattern_type_tuples = ( (flt_const_pattern, ExcelFormulaParser.NUM_CONST), (int_const_pattern, ExcelFormulaParser.INT_CONST), (str_const_pattern, ExcelFormulaParser.STR_CONST), # (range2d_pattern , ExcelFormulaParser.RANGE2D), (ref2d_r1c1_pattern, ExcelFormulaParser.REF2D_R1C1), (ref2d_pattern , ExcelFormulaParser.REF2D), (true_pattern , ExcelFormulaParser.TRUE_CONST), (false_pattern , ExcelFormulaParser.FALSE_CONST), (if_pattern , ExcelFormulaParser.FUNC_IF), (choose_pattern , ExcelFormulaParser.FUNC_CHOOSE), (name_pattern , ExcelFormulaParser.NAME), (quotename_pattern, ExcelFormulaParser.QUOTENAME), (ne_pattern, ExcelFormulaParser.NE), (ge_pattern, ExcelFormulaParser.GE), (le_pattern, ExcelFormulaParser.LE), ) _re = recompile( '(' + ')|('.join([i[0] for i in pattern_type_tuples]) + ')', VERBOSE+LOCALE+IGNORECASE) _toktype = [None] + [i[1] for i in pattern_type_tuples] # need dummy at start because re.MatchObject.lastindex counts from 1 single_char_lookup = { '=': ExcelFormulaParser.EQ, '<': ExcelFormulaParser.LT, '>': ExcelFormulaParser.GT, '+': ExcelFormulaParser.ADD, '-': ExcelFormulaParser.SUB, '*': ExcelFormulaParser.MUL, '/': ExcelFormulaParser.DIV, ':': ExcelFormulaParser.COLON, ';': ExcelFormulaParser.SEMICOLON, ',': ExcelFormulaParser.COMMA, '(': ExcelFormulaParser.LP, ')': ExcelFormulaParser.RP, '&': ExcelFormulaParser.CONCAT, '%': ExcelFormulaParser.PERCENT, '^': ExcelFormulaParser.POWER, '!': ExcelFormulaParser.BANG, } class Lexer(TokenStream): def __init__(self, text): self._text = text[:] self._pos = 0 self._line = 0 def isEOF(self): return len(self._text) <= self._pos def curr_ch(self): return self._text[self._pos] def next_ch(self, n = 1): self._pos += n def is_whitespace(self): return self.curr_ch() in " \t\n\r\f\v" def match_pattern(self): m = _re.match(self._text, self._pos) if not m: return None self._pos = m.end(0) return Tok(type = _toktype[m.lastindex], text = m.group(0), col = m.start(0) + 1) def nextToken(self): # skip whitespace while not self.isEOF() and self.is_whitespace(): self.next_ch() if self.isEOF(): return Tok(type = EOF) # first, try to match token with 2 or more chars t = self.match_pattern() if t: return t # second, we want 1-char tokens te = self.curr_ch() try: ty = single_char_lookup[te] except KeyError: raise TokenStreamException( "Unexpected char %r in column %u." % (self.curr_ch(), self._pos)) self.next_ch() return Tok(type=ty, text=te, col=self._pos) if __name__ == '__main__': try: for t in Lexer(""" 1.23 456 "abcd" R2C2 a1 iv65536 true false if choose a_name 'qname' <> >= <= """): print(t) except TokenStreamException as e: print("error:", e)
apache-2.0
[ 646, 984, 202, 199, 504, 1275, 867, 7493, 492, 9027, 12, 13964, 3264, 465, 377, 745, 12, 8767, 3296, 12, 8767, 3296, 1726, 202, 199, 646, 2702, 202, 199, 504, 1275, 492, 27832, 28533, 2842, 202, 199, 504, 295, 492, 6555, 465, 295, 2014, 12, 1336, 12, 20639, 37, 12, 6778, 948, 9125, 12, 27499, 5788, 11320, 12, 12348, 14607, 8065, 199, 442, 63, 1297, 63, 3401, 275, 519, 3212, 68, 7896, 66, 2, 202, 199, 26057, 63, 1297, 63, 3401, 275, 519, 624, 1128, 16697, 1039, 16697, 971, 68, 10, 971, 14, 971, 68, 11, 776, 327, 1275, 17, 1275, 713, 1275, 4288, 5423, 1749, 14, 17, 5423, 16096, 14, 17, 5423, 1039, 1204, 1039, 16697, 971, 68, 11, 971, 14, 776, 327, 413, 14, 3144, 14, 11869, 14, 5423, 1128, 776, 1128, 327, 9437, 701, 2716, 16588, 1777, 1128, 16697, 359, 37, 69, 61, 359, 16341, 11843, 971, 68, 11, 776, 5805, 1128, 408, 202, 199, 495, 63, 1297, 63, 3401, 275, 519, 4065, 5169, 25153, 92, 341, 3342, 4507, 202, 199, 3, 1842, 18, 68, 63, 3401, 257, 275, 295, 2014, 8, 82, 3212, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 8995, 68, 11, 3427, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 8995, 68, 5207, 202, 199, 1121, 18, 68, 63, 82, 17, 67, 17, 63, 3401, 275, 519, 22774, 50, 82, 61, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 59, 21426, 61, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 2, 202, 199, 1121, 18, 68, 63, 3401, 258, 275, 519, 3212, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 31, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 2, 202, 199, 2052, 63, 3401, 420, 275, 519, 2, 15064, 60, 66, 2, 202, 199, 3910, 63, 3401, 258, 275, 519, 2, 19823, 60, 66, 2, 202, 199, 692, 63, 3401, 263, 275, 519, 2, 4656, 60, 66, 2, 202, 199, 16143, 63, 3401, 259, 275, 519, 2, 1244, 5757, 899, 60, 66, 2, 202, 199, 354, 63, 3401, 420, 275, 519, 3212, 87, 7023, 3134, 87, 3672, 2, 202, 199, 3513, 354, 63, 3401, 275, 519, 4507, 5169, 4735, 418, 5227, 358, 10, 4065, 14055, 2779, 1159, 22829, 1009, 626, 642, 14540, 506, 2222, 13, 22390, 14, 202, 199, 685, 63, 3401, 263, 275, 519, 17030, 4335, 202, 199, 303, 63, 3401, 263, 275, 519, 1743, 628, 202, 199, 274, 63, 3401, 263, 275, 519, 17030, 628, 2999, 199, 3401, 63, 466, 63, 11760, 275, 334, 1128, 334, 26057, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 7125, 63, 13310, 395, 1128, 334, 442, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 2919, 63, 13310, 395, 1128, 334, 495, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 3027, 63, 13310, 395, 202, 199, 3, 259, 334, 1842, 18, 68, 63, 3401, 221, 2360, 27832, 28533, 2842, 14, 15167, 18, 36, 395, 1128, 334, 1121, 18, 68, 63, 82, 17, 67, 17, 63, 3401, 12, 27832, 28533, 2842, 14, 8279, 18, 36, 63, 50, 17, 35, 17, 395, 1128, 334, 1121, 18, 68, 63, 3401, 259, 2360, 27832, 28533, 2842, 14, 8279, 18, 36, 395, 1128, 334, 2052, 63, 3401, 258, 2360, 27832, 28533, 2842, 14, 15064, 63, 13310, 395, 1128, 334, 3910, 63, 3401, 259, 2360, 27832, 28533, 2842, 14, 19823, 63, 13310, 395, 1128, 334, 692, 63, 3401, 755, 2360, 27832, 28533, 2842, 14, 19587, 63, 4656, 395, 1128, 334, 16143, 63, 3401, 257, 2360, 27832, 28533, 2842, 14, 19587, 63, 1244, 5757, 899, 395, 1128, 334, 354, 63, 3401, 258, 2360, 27832, 28533, 2842, 14, 2339, 395, 1128, 334, 3513, 354, 63, 3401, 12, 27832, 28533, 2842, 14, 18654, 11536, 395, 1128, 334, 685, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 6388, 395, 1128, 334, 303, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 4962, 395, 1128, 334, 274, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 906, 395, 202, 199, 9, 2999, 199, 63, 264, 275, 295, 2014, 8, 1128, 16746, 435, 5320, 92, 5175, 904, 779, 73, 59, 16, 61, 367, 284, 315, 3851, 63, 466, 63, 11760, 566, 435, 283, 3196, 1128, 12348, 14607, 11, 20828, 11, 15434, 9, 2999, 199, 63, 9305, 466, 275, 359, 403, 61, 435, 359, 73, 59, 17, 61, 367, 284, 315, 3851, 63, 466, 63, 11760, 61, 202, 199, 3, 1929, 7283, 737, 1343, 2952, 295, 14, 4486, 1692, 14, 2019, 1080, 8242, 687, 413, 2999, 199, 4780, 63, 1560, 63, 3892, 275, 469, 1128, 283, 18749, 27832, 28533, 2842, 14, 17420, 12, 1128, 2650, 356, 27832, 28533, 2842, 14, 17090, 12, 1128, 12696, 356, 27832, 28533, 2842, 14, 8391, 12, 1128, 6681, 356, 27832, 28533, 2842, 14, 9732, 12, 1128, 20905, 27832, 28533, 2842, 14, 6348, 12, 1128, 22969, 27832, 28533, 2842, 14, 45, 1293, 12, 1128, 20549, 27832, 28533, 2842, 14, 27051, 12, 1128, 7596, 356, 27832, 28533, 2842, 14, 3978, 615, 12, 1128, 283, 6015, 27832, 28533, 2842, 14, 899, 17233, 22670, 12, 1128, 1656, 356, 27832, 28533, 2842, 14, 11265, 2054, 12, 1128, 283, 6176, 27832, 28533, 2842, 14, 9257, 12, 1128, 5320, 356, 27832, 28533, 2842, 14, 18612, 12, 1128, 7673, 356, 27832, 28533, 2842, 14, 1864, 11206, 12, 1128, 1543, 356, 27832, 28533, 2842, 14, 4227, 17349, 12, 1128, 14452, 356, 27832, 28533, 2842, 14, 16064, 12, 1128, 14597, 356, 27832, 28533, 2842, 14, 34, 3986, 12, 1128, 789, 2999, 199, 533, 21125, 8, 3264, 3296, 304, 1128, 347, 636, 826, 721, 277, 12, 1318, 304, 1039, 291, 423, 505, 275, 1318, 5873, 1039, 291, 423, 1712, 275, 378, 1039, 291, 423, 604, 275, 378, 2958, 347, 365, 13178, 8, 277, 304, 1039, 372, 822, 8, 277, 423, 505, 9, 2695, 291, 423, 1712, 2958, 347, 8230, 63, 335, 8, 277, 304, 1039, 372, 291, 423, 505, 59, 277, 423, 1712, 61, 2958, 347, 2163, 63, 335, 8, 277, 12, 302, 275, 413, 304, 1039, 291, 423, 1712, 847, 302, 2958, 347, 365, 63, 8506, 8, 277, 304, 1039, 372, 291, 14, 9808, 63, 335, 342, 315, 298, 971, 84 ]
[ 984, 202, 199, 504, 1275, 867, 7493, 492, 9027, 12, 13964, 3264, 465, 377, 745, 12, 8767, 3296, 12, 8767, 3296, 1726, 202, 199, 646, 2702, 202, 199, 504, 1275, 492, 27832, 28533, 2842, 202, 199, 504, 295, 492, 6555, 465, 295, 2014, 12, 1336, 12, 20639, 37, 12, 6778, 948, 9125, 12, 27499, 5788, 11320, 12, 12348, 14607, 8065, 199, 442, 63, 1297, 63, 3401, 275, 519, 3212, 68, 7896, 66, 2, 202, 199, 26057, 63, 1297, 63, 3401, 275, 519, 624, 1128, 16697, 1039, 16697, 971, 68, 10, 971, 14, 971, 68, 11, 776, 327, 1275, 17, 1275, 713, 1275, 4288, 5423, 1749, 14, 17, 5423, 16096, 14, 17, 5423, 1039, 1204, 1039, 16697, 971, 68, 11, 971, 14, 776, 327, 413, 14, 3144, 14, 11869, 14, 5423, 1128, 776, 1128, 327, 9437, 701, 2716, 16588, 1777, 1128, 16697, 359, 37, 69, 61, 359, 16341, 11843, 971, 68, 11, 776, 5805, 1128, 408, 202, 199, 495, 63, 1297, 63, 3401, 275, 519, 4065, 5169, 25153, 92, 341, 3342, 4507, 202, 199, 3, 1842, 18, 68, 63, 3401, 257, 275, 295, 2014, 8, 82, 3212, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 8995, 68, 11, 3427, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 8995, 68, 5207, 202, 199, 1121, 18, 68, 63, 82, 17, 67, 17, 63, 3401, 275, 519, 22774, 50, 82, 61, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 59, 21426, 61, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 2, 202, 199, 1121, 18, 68, 63, 3401, 258, 275, 519, 3212, 4, 26736, 33, 13, 41, 21852, 33, 13, 58, 7272, 4, 31, 16, 23033, 17, 13, 25, 1527, 16, 13, 25, 3672, 2, 202, 199, 2052, 63, 3401, 420, 275, 519, 2, 15064, 60, 66, 2, 202, 199, 3910, 63, 3401, 258, 275, 519, 2, 19823, 60, 66, 2, 202, 199, 692, 63, 3401, 263, 275, 519, 2, 4656, 60, 66, 2, 202, 199, 16143, 63, 3401, 259, 275, 519, 2, 1244, 5757, 899, 60, 66, 2, 202, 199, 354, 63, 3401, 420, 275, 519, 3212, 87, 7023, 3134, 87, 3672, 2, 202, 199, 3513, 354, 63, 3401, 275, 519, 4507, 5169, 4735, 418, 5227, 358, 10, 4065, 14055, 2779, 1159, 22829, 1009, 626, 642, 14540, 506, 2222, 13, 22390, 14, 202, 199, 685, 63, 3401, 263, 275, 519, 17030, 4335, 202, 199, 303, 63, 3401, 263, 275, 519, 1743, 628, 202, 199, 274, 63, 3401, 263, 275, 519, 17030, 628, 2999, 199, 3401, 63, 466, 63, 11760, 275, 334, 1128, 334, 26057, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 7125, 63, 13310, 395, 1128, 334, 442, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 2919, 63, 13310, 395, 1128, 334, 495, 63, 1297, 63, 3401, 12, 27832, 28533, 2842, 14, 3027, 63, 13310, 395, 202, 199, 3, 259, 334, 1842, 18, 68, 63, 3401, 221, 2360, 27832, 28533, 2842, 14, 15167, 18, 36, 395, 1128, 334, 1121, 18, 68, 63, 82, 17, 67, 17, 63, 3401, 12, 27832, 28533, 2842, 14, 8279, 18, 36, 63, 50, 17, 35, 17, 395, 1128, 334, 1121, 18, 68, 63, 3401, 259, 2360, 27832, 28533, 2842, 14, 8279, 18, 36, 395, 1128, 334, 2052, 63, 3401, 258, 2360, 27832, 28533, 2842, 14, 15064, 63, 13310, 395, 1128, 334, 3910, 63, 3401, 259, 2360, 27832, 28533, 2842, 14, 19823, 63, 13310, 395, 1128, 334, 692, 63, 3401, 755, 2360, 27832, 28533, 2842, 14, 19587, 63, 4656, 395, 1128, 334, 16143, 63, 3401, 257, 2360, 27832, 28533, 2842, 14, 19587, 63, 1244, 5757, 899, 395, 1128, 334, 354, 63, 3401, 258, 2360, 27832, 28533, 2842, 14, 2339, 395, 1128, 334, 3513, 354, 63, 3401, 12, 27832, 28533, 2842, 14, 18654, 11536, 395, 1128, 334, 685, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 6388, 395, 1128, 334, 303, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 4962, 395, 1128, 334, 274, 63, 3401, 12, 263, 27832, 28533, 2842, 14, 906, 395, 202, 199, 9, 2999, 199, 63, 264, 275, 295, 2014, 8, 1128, 16746, 435, 5320, 92, 5175, 904, 779, 73, 59, 16, 61, 367, 284, 315, 3851, 63, 466, 63, 11760, 566, 435, 283, 3196, 1128, 12348, 14607, 11, 20828, 11, 15434, 9, 2999, 199, 63, 9305, 466, 275, 359, 403, 61, 435, 359, 73, 59, 17, 61, 367, 284, 315, 3851, 63, 466, 63, 11760, 61, 202, 199, 3, 1929, 7283, 737, 1343, 2952, 295, 14, 4486, 1692, 14, 2019, 1080, 8242, 687, 413, 2999, 199, 4780, 63, 1560, 63, 3892, 275, 469, 1128, 283, 18749, 27832, 28533, 2842, 14, 17420, 12, 1128, 2650, 356, 27832, 28533, 2842, 14, 17090, 12, 1128, 12696, 356, 27832, 28533, 2842, 14, 8391, 12, 1128, 6681, 356, 27832, 28533, 2842, 14, 9732, 12, 1128, 20905, 27832, 28533, 2842, 14, 6348, 12, 1128, 22969, 27832, 28533, 2842, 14, 45, 1293, 12, 1128, 20549, 27832, 28533, 2842, 14, 27051, 12, 1128, 7596, 356, 27832, 28533, 2842, 14, 3978, 615, 12, 1128, 283, 6015, 27832, 28533, 2842, 14, 899, 17233, 22670, 12, 1128, 1656, 356, 27832, 28533, 2842, 14, 11265, 2054, 12, 1128, 283, 6176, 27832, 28533, 2842, 14, 9257, 12, 1128, 5320, 356, 27832, 28533, 2842, 14, 18612, 12, 1128, 7673, 356, 27832, 28533, 2842, 14, 1864, 11206, 12, 1128, 1543, 356, 27832, 28533, 2842, 14, 4227, 17349, 12, 1128, 14452, 356, 27832, 28533, 2842, 14, 16064, 12, 1128, 14597, 356, 27832, 28533, 2842, 14, 34, 3986, 12, 1128, 789, 2999, 199, 533, 21125, 8, 3264, 3296, 304, 1128, 347, 636, 826, 721, 277, 12, 1318, 304, 1039, 291, 423, 505, 275, 1318, 5873, 1039, 291, 423, 1712, 275, 378, 1039, 291, 423, 604, 275, 378, 2958, 347, 365, 13178, 8, 277, 304, 1039, 372, 822, 8, 277, 423, 505, 9, 2695, 291, 423, 1712, 2958, 347, 8230, 63, 335, 8, 277, 304, 1039, 372, 291, 423, 505, 59, 277, 423, 1712, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
JioCloud/tempest
tempest/api/identity/admin/v2/test_roles_negative.py
11
11459
# Copyright 2013 Huawei Technologies Co.,LTD. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import uuid from tempest_lib.common.utils import data_utils from tempest_lib import exceptions as lib_exc from tempest.api.identity import base from tempest import test class RolesNegativeTestJSON(base.BaseIdentityV2AdminTest): def _get_role_params(self): self.data.setup_test_user() self.data.setup_test_role() user = self.get_user_by_name(self.data.test_user) tenant = self.get_tenant_by_name(self.data.test_tenant) role = self.get_role_by_name(self.data.test_role) return (user, tenant, role) @test.attr(type=['negative']) @test.idempotent_id('d5d5f1df-f8ca-4de0-b2ef-259c1cc67025') def test_list_roles_by_unauthorized_user(self): # Non-administrator user should not be able to list roles self.assertRaises(lib_exc.Forbidden, self.non_admin_client.list_roles) @test.attr(type=['negative']) @test.idempotent_id('11a3c7da-df6c-40c2-abc2-badd682edf9f') def test_list_roles_request_without_token(self): # Request to list roles without a valid token should fail token = self.client.auth_provider.get_token() self.client.delete_token(token) self.assertRaises(lib_exc.Unauthorized, self.client.list_roles) self.client.auth_provider.clear_auth() @test.attr(type=['negative']) @test.idempotent_id('c0b89e56-accc-4c73-85f8-9c0f866104c1') def test_role_create_blank_name(self): # Should not be able to create a role with a blank name self.assertRaises(lib_exc.BadRequest, self.client.create_role, '') @test.attr(type=['negative']) @test.idempotent_id('585c8998-a8a4-4641-a5dd-abef7a8ced00') def test_create_role_by_unauthorized_user(self): # Non-administrator user should not be able to create role role_name = data_utils.rand_name(name='role') self.assertRaises(lib_exc.Forbidden, self.non_admin_client.create_role, role_name) @test.attr(type=['negative']) @test.idempotent_id('a7edd17a-e34a-4aab-8bb7-fa6f498645b8') def test_create_role_request_without_token(self): # Request to create role without a valid token should fail token = self.client.auth_provider.get_token() self.client.delete_token(token) role_name = data_utils.rand_name(name='role') self.assertRaises(lib_exc.Unauthorized, self.client.create_role, role_name) self.client.auth_provider.clear_auth() @test.attr(type=['negative']) @test.idempotent_id('c0cde2c8-81c1-4bb0-8fe2-cf615a3547a8') def test_role_create_duplicate(self): # Role names should be unique role_name = data_utils.rand_name(name='role-dup') body = self.client.create_role(role_name) role1_id = body.get('id') self.addCleanup(self.client.delete_role, role1_id) self.assertRaises(lib_exc.Conflict, self.client.create_role, role_name) @test.attr(type=['negative']) @test.idempotent_id('15347635-b5b1-4a87-a280-deb2bd6d865e') def test_delete_role_by_unauthorized_user(self): # Non-administrator user should not be able to delete role role_name = data_utils.rand_name(name='role') body = self.client.create_role(role_name) self.data.roles.append(body) role_id = body.get('id') self.assertRaises(lib_exc.Forbidden, self.non_admin_client.delete_role, role_id) @test.attr(type=['negative']) @test.idempotent_id('44b60b20-70de-4dac-beaf-a3fc2650a16b') def test_delete_role_request_without_token(self): # Request to delete role without a valid token should fail role_name = data_utils.rand_name(name='role') body = self.client.create_role(role_name) self.data.roles.append(body) role_id = body.get('id') token = self.client.auth_provider.get_token() self.client.delete_token(token) self.assertRaises(lib_exc.Unauthorized, self.client.delete_role, role_id) self.client.auth_provider.clear_auth() @test.attr(type=['negative']) @test.idempotent_id('38373691-8551-453a-b074-4260ad8298ef') def test_delete_role_non_existent(self): # Attempt to delete a non existent role should fail non_existent_role = str(uuid.uuid4().hex) self.assertRaises(lib_exc.NotFound, self.client.delete_role, non_existent_role) @test.attr(type=['negative']) @test.idempotent_id('391df5cf-3ec3-46c9-bbe5-5cb58dd4dc41') def test_assign_user_role_by_unauthorized_user(self): # Non-administrator user should not be authorized to # assign a role to user (user, tenant, role) = self._get_role_params() self.assertRaises(lib_exc.Forbidden, self.non_admin_client.assign_user_role, tenant['id'], user['id'], role['id']) @test.attr(type=['negative']) @test.idempotent_id('f0d2683c-5603-4aee-95d7-21420e87cfd8') def test_assign_user_role_request_without_token(self): # Request to assign a role to a user without a valid token (user, tenant, role) = self._get_role_params() token = self.client.auth_provider.get_token() self.client.delete_token(token) self.assertRaises(lib_exc.Unauthorized, self.client.assign_user_role, tenant['id'], user['id'], role['id']) self.client.auth_provider.clear_auth() @test.attr(type=['negative']) @test.idempotent_id('99b297f6-2b5d-47c7-97a9-8b6bb4f91042') def test_assign_user_role_for_non_existent_role(self): # Attempt to assign a non existent role to user should fail (user, tenant, role) = self._get_role_params() non_existent_role = str(uuid.uuid4().hex) self.assertRaises(lib_exc.NotFound, self.client.assign_user_role, tenant['id'], user['id'], non_existent_role) @test.attr(type=['negative']) @test.idempotent_id('b2285aaa-9e76-4704-93a9-7a8acd0a6c8f') def test_assign_user_role_for_non_existent_tenant(self): # Attempt to assign a role on a non existent tenant should fail (user, tenant, role) = self._get_role_params() non_existent_tenant = str(uuid.uuid4().hex) self.assertRaises(lib_exc.NotFound, self.client.assign_user_role, non_existent_tenant, user['id'], role['id']) @test.attr(type=['negative']) @test.idempotent_id('5c3132cd-c4c8-4402-b5ea-71eb44e97793') def test_assign_duplicate_user_role(self): # Duplicate user role should not get assigned (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) self.assertRaises(lib_exc.Conflict, self.client.assign_user_role, tenant['id'], user['id'], role['id']) @test.attr(type=['negative']) @test.idempotent_id('d0537987-0977-448f-a435-904c15de7298') def test_remove_user_role_by_unauthorized_user(self): # Non-administrator user should not be authorized to # remove a user's role (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) self.assertRaises(lib_exc.Forbidden, self.non_admin_client.remove_user_role, tenant['id'], user['id'], role['id']) @test.attr(type=['negative']) @test.idempotent_id('cac81cf4-c1d2-47dc-90d3-f2b7eb572286') def test_remove_user_role_request_without_token(self): # Request to remove a user's role without a valid token (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) token = self.client.auth_provider.get_token() self.client.delete_token(token) self.assertRaises(lib_exc.Unauthorized, self.client.remove_user_role, tenant['id'], user['id'], role['id']) self.client.auth_provider.clear_auth() @test.attr(type=['negative']) @test.idempotent_id('ab32d759-cd16-41f1-a86e-44405fa9f6d2') def test_remove_user_role_non_existent_role(self): # Attempt to delete a non existent role from a user should fail (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) non_existent_role = str(uuid.uuid4().hex) self.assertRaises(lib_exc.NotFound, self.client.remove_user_role, tenant['id'], user['id'], non_existent_role) @test.attr(type=['negative']) @test.idempotent_id('67a679ec-03dd-4551-bbfc-d1c93284f023') def test_remove_user_role_non_existent_tenant(self): # Attempt to remove a role from a non existent tenant should fail (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) non_existent_tenant = str(uuid.uuid4().hex) self.assertRaises(lib_exc.NotFound, self.client.remove_user_role, non_existent_tenant, user['id'], role['id']) @test.attr(type=['negative']) @test.idempotent_id('7391ab4c-06f3-477a-a64a-c8e55ce89837') def test_list_user_roles_by_unauthorized_user(self): # Non-administrator user should not be authorized to list # a user's roles (user, tenant, role) = self._get_role_params() self.client.assign_user_role(tenant['id'], user['id'], role['id']) self.assertRaises(lib_exc.Forbidden, self.non_admin_client.list_user_roles, tenant['id'], user['id']) @test.attr(type=['negative']) @test.idempotent_id('682adfb2-fd5f-4b0a-a9ca-322e9bebb907') def test_list_user_roles_request_without_token(self): # Request to list user's roles without a valid token should fail (user, tenant, role) = self._get_role_params() token = self.client.auth_provider.get_token() self.client.delete_token(token) try: self.assertRaises(lib_exc.Unauthorized, self.client.list_user_roles, tenant['id'], user['id']) finally: self.client.auth_provider.clear_auth()
apache-2.0
[ 3, 1898, 6171, 869, 1458, 21431, 19215, 1849, 2020, 44, 13449, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 5377, 199, 199, 504, 24076, 63, 773, 14, 2330, 14, 1208, 492, 666, 63, 1208, 199, 504, 24076, 63, 773, 492, 4967, 465, 1973, 63, 2804, 199, 199, 504, 24076, 14, 1246, 14, 5582, 492, 1300, 199, 504, 24076, 492, 511, 421, 199, 533, 6848, 2978, 15562, 774, 6243, 8, 1095, 14, 1563, 10193, 54, 18, 4880, 774, 304, 339, 347, 485, 362, 63, 3756, 63, 1162, 8, 277, 304, 267, 291, 14, 576, 14, 2758, 63, 396, 63, 751, 342, 267, 291, 14, 576, 14, 2758, 63, 396, 63, 3756, 342, 267, 922, 275, 291, 14, 362, 63, 751, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 751, 9, 267, 8261, 275, 291, 14, 362, 63, 4647, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 4647, 9, 267, 4719, 275, 291, 14, 362, 63, 3756, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 3756, 9, 267, 372, 334, 751, 12, 8261, 12, 4719, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 68, 21, 68, 21, 70, 17, 1587, 13, 70, 24, 696, 13, 20, 271, 16, 13, 66, 18, 2829, 13, 11990, 67, 17, 2055, 1822, 18823, 358, 272, 347, 511, 63, 513, 63, 8050, 63, 991, 63, 324, 11497, 63, 751, 8, 277, 304, 267, 327, 10172, 13, 2113, 14710, 922, 1077, 440, 506, 7688, 370, 769, 11689, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 17454, 12, 2079, 291, 14, 2865, 63, 2113, 63, 1258, 14, 513, 63, 8050, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 845, 65, 19, 67, 23, 983, 13, 1587, 22, 67, 13, 2167, 67, 18, 13, 3175, 18, 13, 66, 525, 24255, 27680, 25, 70, 358, 272, 347, 511, 63, 513, 63, 8050, 63, 1069, 63, 7395, 63, 1418, 8, 277, 304, 267, 327, 4784, 370, 769, 11689, 1928, 282, 1686, 1526, 1077, 2449, 267, 1526, 275, 291, 14, 1258, 14, 1178, 63, 3780, 14, 362, 63, 1418, 342, 267, 291, 14, 1258, 14, 1807, 63, 1418, 8, 1418, 9, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 28290, 12, 291, 14, 1258, 14, 513, 63, 8050, 9, 267, 291, 14, 1258, 14, 1178, 63, 3780, 14, 3584, 63, 1178, 342, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 67, 16, 66, 1407, 69, 1367, 13, 645, 2055, 13, 20, 67, 2898, 13, 2426, 70, 24, 13, 25, 67, 16, 70, 13465, 6785, 67, 17, 358, 272, 347, 511, 63, 3756, 63, 981, 63, 2500, 63, 354, 8, 277, 304, 267, 327, 7719, 440, 506, 7688, 370, 1218, 282, 4719, 543, 282, 4596, 536, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 12380, 12, 291, 14, 1258, 14, 981, 63, 3756, 12, 4074, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 15959, 67, 24, 13830, 13, 65, 24, 65, 20, 13, 20, 15233, 13, 65, 21, 617, 13, 371, 2829, 23, 65, 24, 6867, 383, 358, 272, 347, 511, 63, 981, 63, 3756, 63, 991, 63, 324, 11497, 63, 751, 8, 277, 304, 267, 327, 10172, 13, 2113, 14710, 922, 1077, 440, 506, 7688, 370, 1218, 4719, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 358, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 17454, 12, 2079, 291, 14, 2865, 63, 2113, 63, 1258, 14, 981, 63, 3756, 12, 4719, 63, 354, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 65, 23, 31151, 1196, 65, 13, 69, 1082, 65, 13, 20, 65, 371, 13, 24, 2501, 23, 13, 667, 22, 70, 20537, 13067, 66, 24, 358, 272, 347, 511, 63, 981, 63, 3756, 63, 1069, 63, 7395, 63, 1418, 8, 277, 304, 267, 327, 4784, 370, 1218, 4719, 1928, 282, 1686, 1526, 1077, 2449, 267, 1526, 275, 291, 14, 1258, 14, 1178, 63, 3780, 14, 362, 63, 1418, 342, 267, 291, 14, 1258, 14, 1807, 63, 1418, 8, 1418, 9, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 358, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 28290, 12, 2079, 291, 14, 1258, 14, 981, 63, 3756, 12, 4719, 63, 354, 9, 267, 291, 14, 1258, 14, 1178, 63, 3780, 14, 3584, 63, 1178, 342, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 67, 16, 31414, 18, 67, 24, 13, 2835, 67, 17, 13, 20, 2501, 16, 13, 24, 771, 18, 13, 2177, 28249, 65, 1276, 2417, 65, 24, 358, 272, 347, 511, 63, 3756, 63, 981, 63, 11081, 8, 277, 304, 267, 327, 18033, 1561, 1077, 506, 3747, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 13, 11048, 358, 267, 2396, 275, 291, 14, 1258, 14, 981, 63, 3756, 8, 3756, 63, 354, 9, 267, 4719, 17, 63, 344, 275, 2396, 14, 362 ]
[ 1898, 6171, 869, 1458, 21431, 19215, 1849, 2020, 44, 13449, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 5377, 199, 199, 504, 24076, 63, 773, 14, 2330, 14, 1208, 492, 666, 63, 1208, 199, 504, 24076, 63, 773, 492, 4967, 465, 1973, 63, 2804, 199, 199, 504, 24076, 14, 1246, 14, 5582, 492, 1300, 199, 504, 24076, 492, 511, 421, 199, 533, 6848, 2978, 15562, 774, 6243, 8, 1095, 14, 1563, 10193, 54, 18, 4880, 774, 304, 339, 347, 485, 362, 63, 3756, 63, 1162, 8, 277, 304, 267, 291, 14, 576, 14, 2758, 63, 396, 63, 751, 342, 267, 291, 14, 576, 14, 2758, 63, 396, 63, 3756, 342, 267, 922, 275, 291, 14, 362, 63, 751, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 751, 9, 267, 8261, 275, 291, 14, 362, 63, 4647, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 4647, 9, 267, 4719, 275, 291, 14, 362, 63, 3756, 63, 991, 63, 354, 8, 277, 14, 576, 14, 396, 63, 3756, 9, 267, 372, 334, 751, 12, 8261, 12, 4719, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 68, 21, 68, 21, 70, 17, 1587, 13, 70, 24, 696, 13, 20, 271, 16, 13, 66, 18, 2829, 13, 11990, 67, 17, 2055, 1822, 18823, 358, 272, 347, 511, 63, 513, 63, 8050, 63, 991, 63, 324, 11497, 63, 751, 8, 277, 304, 267, 327, 10172, 13, 2113, 14710, 922, 1077, 440, 506, 7688, 370, 769, 11689, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 17454, 12, 2079, 291, 14, 2865, 63, 2113, 63, 1258, 14, 513, 63, 8050, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 845, 65, 19, 67, 23, 983, 13, 1587, 22, 67, 13, 2167, 67, 18, 13, 3175, 18, 13, 66, 525, 24255, 27680, 25, 70, 358, 272, 347, 511, 63, 513, 63, 8050, 63, 1069, 63, 7395, 63, 1418, 8, 277, 304, 267, 327, 4784, 370, 769, 11689, 1928, 282, 1686, 1526, 1077, 2449, 267, 1526, 275, 291, 14, 1258, 14, 1178, 63, 3780, 14, 362, 63, 1418, 342, 267, 291, 14, 1258, 14, 1807, 63, 1418, 8, 1418, 9, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 28290, 12, 291, 14, 1258, 14, 513, 63, 8050, 9, 267, 291, 14, 1258, 14, 1178, 63, 3780, 14, 3584, 63, 1178, 342, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 67, 16, 66, 1407, 69, 1367, 13, 645, 2055, 13, 20, 67, 2898, 13, 2426, 70, 24, 13, 25, 67, 16, 70, 13465, 6785, 67, 17, 358, 272, 347, 511, 63, 3756, 63, 981, 63, 2500, 63, 354, 8, 277, 304, 267, 327, 7719, 440, 506, 7688, 370, 1218, 282, 4719, 543, 282, 4596, 536, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 12380, 12, 291, 14, 1258, 14, 981, 63, 3756, 12, 4074, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 15959, 67, 24, 13830, 13, 65, 24, 65, 20, 13, 20, 15233, 13, 65, 21, 617, 13, 371, 2829, 23, 65, 24, 6867, 383, 358, 272, 347, 511, 63, 981, 63, 3756, 63, 991, 63, 324, 11497, 63, 751, 8, 277, 304, 267, 327, 10172, 13, 2113, 14710, 922, 1077, 440, 506, 7688, 370, 1218, 4719, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 358, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 17454, 12, 2079, 291, 14, 2865, 63, 2113, 63, 1258, 14, 981, 63, 3756, 12, 4719, 63, 354, 9, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 65, 23, 31151, 1196, 65, 13, 69, 1082, 65, 13, 20, 65, 371, 13, 24, 2501, 23, 13, 667, 22, 70, 20537, 13067, 66, 24, 358, 272, 347, 511, 63, 981, 63, 3756, 63, 1069, 63, 7395, 63, 1418, 8, 277, 304, 267, 327, 4784, 370, 1218, 4719, 1928, 282, 1686, 1526, 1077, 2449, 267, 1526, 275, 291, 14, 1258, 14, 1178, 63, 3780, 14, 362, 63, 1418, 342, 267, 291, 14, 1258, 14, 1807, 63, 1418, 8, 1418, 9, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 358, 267, 291, 14, 1855, 8, 773, 63, 2804, 14, 28290, 12, 2079, 291, 14, 1258, 14, 981, 63, 3756, 12, 4719, 63, 354, 9, 267, 291, 14, 1258, 14, 1178, 63, 3780, 14, 3584, 63, 1178, 342, 339, 768, 396, 14, 962, 8, 466, 2968, 7371, 1105, 272, 768, 396, 14, 21307, 63, 344, 360, 67, 16, 31414, 18, 67, 24, 13, 2835, 67, 17, 13, 20, 2501, 16, 13, 24, 771, 18, 13, 2177, 28249, 65, 1276, 2417, 65, 24, 358, 272, 347, 511, 63, 3756, 63, 981, 63, 11081, 8, 277, 304, 267, 327, 18033, 1561, 1077, 506, 3747, 267, 4719, 63, 354, 275, 666, 63, 1208, 14, 3759, 63, 354, 8, 354, 534, 3756, 13, 11048, 358, 267, 2396, 275, 291, 14, 1258, 14, 981, 63, 3756, 8, 3756, 63, 354, 9, 267, 4719, 17, 63, 344, 275, 2396, 14, 362, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
datacratic/mongo-cxx-driver
src/mongo/db/auth/generate_action_types.py
19
7459
#!/usr/bin/python # Copyright 2012 10gen Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """Generate action_type.{h,cpp} Usage: python generate_action_types.py <path to action_types.txt> <header file path> <source file path> """ import sys headerFileTemplate = """// AUTO-GENERATED FILE DO NOT EDIT // See src/mongo/db/auth/generate_action_types.py /* Copyright 2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <iosfwd> #include <map> #include <string> #include "mongo/base/status.h" #include "mongo/platform/cstdint.h" namespace mongo { struct ActionType { public: explicit ActionType(uint32_t identifier) : _identifier(identifier) {}; ActionType() {}; uint32_t getIdentifier() const { return _identifier; } bool operator==(const ActionType& rhs) const; std::string toString() const; // Takes the string representation of a single action type and returns the corresponding // ActionType enum. static Status parseActionFromString(const std::string& actionString, ActionType* result); // Takes an ActionType and returns the string representation static std::string actionToString(const ActionType& action); %(actionTypeConstants)s enum ActionTypeIdentifier { %(actionTypeIdentifiers)s actionTypeEndValue, // Should always be last in this enum }; static const int NUM_ACTION_TYPES = actionTypeEndValue; private: uint32_t _identifier; // unique identifier for this action. }; // String stream operator for ActionType std::ostream& operator<<(std::ostream& os, const ActionType& at); } // namespace mongo """ sourceFileTemplate = """// AUTO-GENERATED FILE DO NOT EDIT // See src/mongo/db/auth/generate_action_types.py /* Copyright 2012 10gen Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "mongo/pch.h" #include "mongo/db/auth/action_type.h" #include <iostream> #include <string> #include "mongo/base/status.h" #include "mongo/platform/cstdint.h" #include "mongo/util/mongoutils/str.h" namespace mongo { %(actionTypeConstants)s bool ActionType::operator==(const ActionType& rhs) const { return _identifier == rhs._identifier; } std::ostream& operator<<(std::ostream& os, const ActionType& at) { os << ActionType::actionToString(at); return os; } std::string ActionType::toString() const { return actionToString(*this); } Status ActionType::parseActionFromString(const std::string& action, ActionType* result) { %(fromStringIfStatements)s return Status(ErrorCodes::FailedToParse, mongoutils::str::stream() << "Unrecognized action privilege string: " << action, 0); } // Takes an ActionType and returns the string representation std::string ActionType::actionToString(const ActionType& action) { switch (action.getIdentifier()) { %(toStringCaseStatements)s default: return ""; } } } // namespace mongo """ def writeSourceFile(actionTypes, sourceOutputFile): actionTypeConstants = "" fromStringIfStatements = "" toStringCaseStatements = "" for actionType in actionTypes: actionTypeConstants += (" const ActionType ActionType::%(actionType)s" "(%(actionType)sValue);\n" % dict(actionType=actionType)) fromStringIfStatements += """ if (action == "%(actionType)s") { *result = %(actionType)s; return Status::OK(); }\n""" % dict(actionType=actionType) toStringCaseStatements += """ case %(actionType)sValue: return "%(actionType)s";\n""" % dict(actionType=actionType) formattedSourceFile = sourceFileTemplate % dict(actionTypeConstants=actionTypeConstants, fromStringIfStatements=fromStringIfStatements, toStringCaseStatements=toStringCaseStatements) sourceOutputFile.write(formattedSourceFile) pass def writeHeaderFile(actionTypes, headerOutputFile): actionTypeConstants = "" actionTypeIdentifiers = "" for actionType in actionTypes: actionTypeConstants += " static const ActionType %s;\n" % (actionType) actionTypeIdentifiers += " %sValue,\n" % (actionType) formattedHeaderFile = headerFileTemplate % dict(actionTypeConstants=actionTypeConstants, actionTypeIdentifiers=actionTypeIdentifiers) headerOutputFile.write(formattedHeaderFile) def hasDuplicateActionTypes(actionTypes): sortedActionTypes = sorted(actionTypes) didFail = False prevActionType = sortedActionTypes[0] for actionType in sortedActionTypes[1:]: if actionType == prevActionType: print 'Duplicate actionType %s\n' % actionType didFail = True prevActionType = actionType return didFail def parseActionTypesFromFile(actionTypesFilename): actionTypesFile = open(actionTypesFilename, 'r') actionTypes = eval(actionTypesFile.read()) return actionTypes if __name__ == "__main__": if len(sys.argv) != 4: print "Usage: generate_action_types.py <path to action_types.txt> <header file path> <source file path>" sys.exit(-1) actionTypes = parseActionTypesFromFile(sys.argv[1]) if hasDuplicateActionTypes(actionTypes): sys.exit(-1) headerOutputFile = open(sys.argv[2], 'w') sourceOutputFile = open(sys.argv[3], 'w') writeHeaderFile(actionTypes, headerOutputFile) writeSourceFile(actionTypes, sourceOutputFile)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 3, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 259, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 6864, 1595, 63, 466, 23379, 72, 12, 5910, 93, 199, 199, 7692, 26, 272, 2366, 3550, 63, 1287, 63, 1313, 14, 647, 665, 515, 370, 1595, 63, 1313, 14, 2424, 30, 665, 1291, 570, 931, 30, 665, 1365, 570, 931, 30, 199, 624, 199, 199, 646, 984, 421, 199, 1291, 1173, 4231, 275, 408, 501, 25420, 13, 12795, 6989, 13024, 3506, 2845, 24981, 199, 501, 1666, 2928, 15, 9217, 15, 697, 15, 1178, 15, 4208, 63, 1287, 63, 1313, 14, 647, 199, 6331, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 627, 199, 627, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 627, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 627, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 627, 199, 627, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 627, 199, 627, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 627, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 627, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 627, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 627, 259, 4204, 1334, 314, 844, 14, 199, 11589, 199, 199, 3, 25852, 5403, 199, 199, 3, 2613, 665, 9207, 27912, 30, 199, 3, 2613, 665, 1130, 30, 199, 3, 2613, 665, 875, 30, 199, 199, 3, 2613, 298, 9217, 15, 1095, 15, 1205, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 3246, 15, 67, 1516, 442, 14, 72, 2, 199, 199, 3251, 18006, 469, 339, 2702, 10033, 804, 469, 272, 4575, 26, 398, 5027, 10033, 804, 8, 1635, 708, 63, 84, 5148, 9, 520, 485, 5364, 8, 5364, 9, 27978, 267, 10033, 804, 342, 27978, 398, 3152, 708, 63, 84, 664, 7544, 342, 950, 469, 288, 372, 485, 5364, 27, 267, 789, 398, 2155, 4182, 389, 8, 1297, 10033, 804, 6, 9085, 9, 950, 27, 398, 2418, 447, 875, 370, 1558, 342, 950, 27, 398, 5001, 17415, 314, 1059, 6025, 402, 282, 2849, 1595, 730, 436, 2529, 314, 5226, 267, 5001, 10033, 804, 4952, 14, 267, 2955, 9795, 2198, 3310, 7671, 8, 1297, 2418, 447, 875, 6, 1595, 1558, 12, 10033, 804, 10, 754, 2736, 398, 5001, 17415, 376, 10033, 804, 436, 2529, 314, 1059, 6025, 267, 2955, 2418, 447, 875, 1595, 7756, 8, 1297, 10033, 804, 6, 1595, 2736, 199, 199, 2840, 1287, 804, 22185, 9, 83, 267, 4952, 10033, 804, 7544, 469, 199, 2840, 1287, 804, 41, 8577, 9, 83, 288, 1595, 804, 3005, 1110, 12, 5001, 7719, 3544, 506, 2061, 315, 642, 4952, 267, 16735, 398, 2955, 950, 1109, 11576, 63, 10052, 63, 7893, 275, 1595, 804, 3005, 1110, 27, 339, 5726, 26, 398, 3152, 708, 63, 84, 485, 5364, 27, 5001, 3747, 5148, 367, 642, 1595, 14, 272, 16735, 339, 5001, 2624, 2547, 4182, 367, 10033, 804, 272, 2418, 447, 9015, 6, 4182, 8999, 8, 1516, 447, 9015, 6, 747, 12, 950, 10033, 804, 6, 737, 2736, 199, 199, 93, 5001, 3231, 18006, 199, 624, 199, 199, 1365, 1173, 4231, 275, 408, 501, 25420, 13, 12795, 6989, 13024, 3506, 2845, 24981, 199, 501, 1666, 2928, 15, 9217, 15, 697, 15, 1178, 15, 4208, 63, 1287, 63, 1313, 14, 647, 199, 6331, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 627, 199, 627, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 627, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 627, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 627, 199, 627, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 627, 199, 627, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 627, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 627, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 627, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 627, 259, 4204, 1334, 314, 844, 14, 199, 11589, 199, 199, 3, 2613, 298, 9217, 15, 23938, 14, 72, 2, 199, 199, 3, 2613, 298, 9217, 15, 697, 15, 1178, 15, 1287, 63, 466, 14, 72, 2, 199, 199, 3, 2613, 665, 73, 9015, 30, 199, 3, 2613, 665, 875, 30, 199, 199, 3, 2613, 298, 9217, 15, 1095, 15, 1205, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 3246, 15, 67, 1516, 442, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 1974, 15, 22130, 810, 3024, 15, 495, 14, 72, 2, 199, 199, 3251, 18006, 469, 199, 199, 2840, 1287, 804, 22185, 9, 83, 272, 2155, 10033, 804, 447, 3856, 389, 8, 1297, 10033, 804, 6, 9085, 9, 950, 469, 267, 372, 485, 5364, 508, 9085, 423, 5364, 27, 272, 789, 339, 2418, 447, 9015, 6, 4182, 8999, 8, 1516, 447, 9015, 6, 747, 12, 950, 10033, 804, 6, 737, 9, 469, 267 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 3, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 259, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 6864, 1595, 63, 466, 23379, 72, 12, 5910, 93, 199, 199, 7692, 26, 272, 2366, 3550, 63, 1287, 63, 1313, 14, 647, 665, 515, 370, 1595, 63, 1313, 14, 2424, 30, 665, 1291, 570, 931, 30, 665, 1365, 570, 931, 30, 199, 624, 199, 199, 646, 984, 421, 199, 1291, 1173, 4231, 275, 408, 501, 25420, 13, 12795, 6989, 13024, 3506, 2845, 24981, 199, 501, 1666, 2928, 15, 9217, 15, 697, 15, 1178, 15, 4208, 63, 1287, 63, 1313, 14, 647, 199, 6331, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 627, 199, 627, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 627, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 627, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 627, 199, 627, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 627, 199, 627, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 627, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 627, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 627, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 627, 259, 4204, 1334, 314, 844, 14, 199, 11589, 199, 199, 3, 25852, 5403, 199, 199, 3, 2613, 665, 9207, 27912, 30, 199, 3, 2613, 665, 1130, 30, 199, 3, 2613, 665, 875, 30, 199, 199, 3, 2613, 298, 9217, 15, 1095, 15, 1205, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 3246, 15, 67, 1516, 442, 14, 72, 2, 199, 199, 3251, 18006, 469, 339, 2702, 10033, 804, 469, 272, 4575, 26, 398, 5027, 10033, 804, 8, 1635, 708, 63, 84, 5148, 9, 520, 485, 5364, 8, 5364, 9, 27978, 267, 10033, 804, 342, 27978, 398, 3152, 708, 63, 84, 664, 7544, 342, 950, 469, 288, 372, 485, 5364, 27, 267, 789, 398, 2155, 4182, 389, 8, 1297, 10033, 804, 6, 9085, 9, 950, 27, 398, 2418, 447, 875, 370, 1558, 342, 950, 27, 398, 5001, 17415, 314, 1059, 6025, 402, 282, 2849, 1595, 730, 436, 2529, 314, 5226, 267, 5001, 10033, 804, 4952, 14, 267, 2955, 9795, 2198, 3310, 7671, 8, 1297, 2418, 447, 875, 6, 1595, 1558, 12, 10033, 804, 10, 754, 2736, 398, 5001, 17415, 376, 10033, 804, 436, 2529, 314, 1059, 6025, 267, 2955, 2418, 447, 875, 1595, 7756, 8, 1297, 10033, 804, 6, 1595, 2736, 199, 199, 2840, 1287, 804, 22185, 9, 83, 267, 4952, 10033, 804, 7544, 469, 199, 2840, 1287, 804, 41, 8577, 9, 83, 288, 1595, 804, 3005, 1110, 12, 5001, 7719, 3544, 506, 2061, 315, 642, 4952, 267, 16735, 398, 2955, 950, 1109, 11576, 63, 10052, 63, 7893, 275, 1595, 804, 3005, 1110, 27, 339, 5726, 26, 398, 3152, 708, 63, 84, 485, 5364, 27, 5001, 3747, 5148, 367, 642, 1595, 14, 272, 16735, 339, 5001, 2624, 2547, 4182, 367, 10033, 804, 272, 2418, 447, 9015, 6, 4182, 8999, 8, 1516, 447, 9015, 6, 747, 12, 950, 10033, 804, 6, 737, 2736, 199, 199, 93, 5001, 3231, 18006, 199, 624, 199, 199, 1365, 1173, 4231, 275, 408, 501, 25420, 13, 12795, 6989, 13024, 3506, 2845, 24981, 199, 501, 1666, 2928, 15, 9217, 15, 697, 15, 1178, 15, 4208, 63, 1287, 63, 1313, 14, 647, 199, 6331, 259, 1898, 6029, 1616, 2268, 3277, 14, 199, 627, 199, 627, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 627, 259, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 627, 259, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 627, 199, 627, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 627, 199, 627, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 627, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 627, 259, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 627, 259, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 627, 259, 4204, 1334, 314, 844, 14, 199, 11589, 199, 199, 3, 2613, 298, 9217, 15, 23938, 14, 72, 2, 199, 199, 3, 2613, 298, 9217, 15, 697, 15, 1178, 15, 1287, 63, 466, 14, 72, 2, 199, 199, 3, 2613, 665, 73, 9015, 30, 199, 3, 2613, 665, 875, 30, 199, 199, 3, 2613, 298, 9217, 15, 1095, 15, 1205, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 3246, 15, 67, 1516, 442, 14, 72, 2, 199, 3, 2613, 298, 9217, 15, 1974, 15, 22130, 810, 3024, 15, 495, 14, 72, 2, 199, 199, 3251, 18006, 469, 199, 199, 2840, 1287, 804, 22185, 9, 83, 272, 2155, 10033, 804, 447, 3856, 389, 8, 1297, 10033, 804, 6, 9085, 9, 950, 469, 267, 372, 485, 5364, 508, 9085, 423, 5364, 27, 272, 789, 339, 2418, 447, 9015, 6, 4182, 8999, 8, 1516, 447, 9015, 6, 747, 12, 950, 10033, 804, 6, 737, 9, 469, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alokotosh/mm-master
mm/commands/metadata.py
3
24125
import sys import json import os import mm.util as util import mm.xmltodict as xmltodict import mm.config as config import shutil import urllib import re import threading from operator import itemgetter from xml.dom import minidom import webbrowser from mm.sfdc_client import MavensMateClient from mm.exceptions import * from mm.basecommand import Command debug = config.logger.debug class NewMetadataCommand(Command): """ Creates a new element of metadata """ def execute(self): project = config.project sfdc_client = config.sfdc_client metadata_type = self.params.get('metadata_type', None) github_template = self.params.get('github_template', None) params = self.params.get('params', None) if params == None: raise MMException('The payload to create metadata has recently changed. If you are using Sublime Text, you likely need to update your MavensMate plugin to 3.4.8+') if "api_name" not in params or params["api_name"] == None or params["api_name"] == '': return util.generate_error_response("You must provide a name for the new metadata.") api_name = params.get('api_name') if sfdc_client.does_metadata_exist(object_type=metadata_type, name=api_name) == True: mt = util.get_meta_type_by_name(metadata_type) filepath = os.path.join(project.location, 'src', mt['directoryName'], api_name+'.'+mt['suffix']) fetched = "" if not os.path.exists(filepath): self.params['files'] = [filepath] RefreshSelectedMetadataCommand(params=self.params,args=self.args).execute() fetched = ", fetched metadata file from server" raise MMException("This API name is already in use in your org" + fetched + ".") tmp, tmp_unpackaged = util.put_tmp_directory_on_disk(True) util.put_skeleton_files_on_disk(metadata_type, tmp_unpackaged, github_template, params) package_xml_body = util.get_package_xml_contents({metadata_type : [ api_name ]}) util.put_package_xml_in_directory(tmp_unpackaged, package_xml_body) zip_file = util.zip_directory(tmp, tmp) deploy_params = { "zip_file" : zip_file, "rollback_on_error" : True, "ret_xml" : True } deploy_result = sfdc_client.deploy(deploy_params) d = xmltodict.parse(deploy_result,postprocessor=util.xmltodict_postprocessor) meta_dir = "" files = [] path = None for dirname, dirnames, filenames in os.walk(tmp_unpackaged): for filename in filenames: if 'package.xml' in filename: continue full_file_path = os.path.join(dirname, filename) if '-meta.xml' in filename: extension = filename.replace('-meta.xml','').split(".")[-1] else: extension = filename.split(".")[-1] mt = util.get_meta_type_by_suffix(extension) if mt != None: meta_dir = mt['directoryName'] path = os.path.join(project.location, 'src', meta_dir) if not os.path.exists(path): os.makedirs(path) files.append(os.path.join(path, filename)) elif extension != "xml": continue; # only apex files and meta.xml files should make it to here shutil.copy(full_file_path, path) shutil.rmtree(tmp) project.update_package_xml_with_metadata(metadata_type, api_name) project.conflict_manager.refresh_local_store(files=files) return json.dumps(d["soapenv:Envelope"]["soapenv:Body"]['checkDeployStatusResponse']['result']) class DeleteSelectedMetadataCommand(Command): aliases=["delete"] """ Deletes metadata from the Salesforce.com server """ def execute(self): project = config.project sfdc_client = config.sfdc_client files = self.params.get('files', None) for f in files: if '-meta.xml' in f: corresponding_file = f.split('-meta.xml')[0] if corresponding_file not in files: files.append(corresponding_file) for f in files: if '-meta.xml' in f: continue file_ext = f.split('.')[-1] metadata_type = util.get_meta_type_by_suffix(file_ext) if metadata_type['metaFile'] == True: corresponding_file = f + '-meta.xml' if corresponding_file not in files: files.append(corresponding_file) metadata_package_dict = util.get_metadata_hash(files) tmp, tmp_unpackaged = util.put_tmp_directory_on_disk(True) package_xml = util.get_package_xml_contents(metadata_package_dict) util.put_package_xml_in_directory(tmp_unpackaged, package_xml, True) empty_package_xml = util.get_empty_package_xml_contents() util.put_empty_package_xml_in_directory(tmp_unpackaged, empty_package_xml) zip_file = util.zip_directory(tmp, tmp) purge_on_delete_setting = config.connection.get_plugin_client_setting("mm_purge_on_delete", False); if purge_on_delete_setting: describe_result = config.sfdc_client.describeMetadata(retXml=False) if describe_result.testRequired == True: purge_on_delete_setting = False deploy_params = { "zip_file" : zip_file, "rollback_on_error" : True, "ret_xml" : True, "purge_on_delete" : purge_on_delete_setting } delete_result = sfdc_client.delete(deploy_params) d = xmltodict.parse(delete_result,postprocessor=util.xmltodict_postprocessor) shutil.rmtree(tmp) result = d["soapenv:Envelope"]["soapenv:Body"]['checkDeployStatusResponse']['result'] if result['success'] == True: removed = [] for f in files: try: file_ext = f.split('.')[-1] metadata_type = util.get_meta_type_by_suffix(file_ext) if metadata_type == None or not 'directoryName' in metadata_type: continue; directory = metadata_type['directoryName'] filepath = os.path.join(project.location, "src", directory, f) metapath = os.path.join(project.location, "src", directory, f + '-meta.xml') os.remove(filepath) os.remove(metapath) # remove the entry in file properties project.conflict_manager.remove_from_local_store(f) removed.append(f) except Exception, e: print e.message return util.generate_success_response("Removed metadata files: " + (",".join(removed))) else: return json.dumps(result) class RefreshSelectedMetadataCommand(Command): """ Refreshes metadata from the Salesforce.com server """ name="refresh" def execute(self): project = config.project if 'directories' in self.params and len(self.params['directories']) == 1 and os.path.basename(self.params['directories'][0]) == "src": return project.clean(reset_metadata_container=False) else: retrieve_result = project.get_retrieve_result(self.params) #take this opportunity to freshen the cache project.conflict_manager.refresh_local_store(retrieve_result.fileProperties) util.extract_base64_encoded_zip(retrieve_result.zipFile, project.location) #TODO: handle exception that could render the project unusable bc of lost files #replace project metadata with retrieved metadata for dirname, dirnames, filenames in os.walk(os.path.join(project.location,"unpackaged")): for filename in filenames: full_file_path = os.path.join(dirname, filename) if '/unpackaged/package.xml' in full_file_path or '\\unpackaged\\package.xml' in full_file_path: continue if 'win32' in sys.platform: destination = full_file_path.replace('\\unpackaged\\', '\\src\\') else: destination = full_file_path.replace('/unpackaged/', '/src/') destination_directory = os.path.dirname(destination) if not os.path.exists(destination_directory): os.makedirs(destination_directory) shutil.move(full_file_path, destination) shutil.rmtree(os.path.join(project.location,"unpackaged")) if os.path.exists(os.path.join(project.location,"metadata.zip")): os.remove(os.path.join(project.location,"metadata.zip")) return util.generate_success_response("Refresh Completed Successfully") class OpenSelectedMetadataCommand(Command): aliases=["open_sfdc_url"] """ Open selected file in SFDC """ def execute(self): project = config.project sfdc_client = config.sfdc_client if "files" in self.params: if "type" in self.params: open_type = self.params.get("type", None) else: open_type = "edit" files = self.params.get("files", None) if len(files) > 0: apex_file_properties = util.parse_json_from_file(os.path.join(project.location,"config",".local_store")) opened = [] urls = [] pages = [] for fileabs in files: basename = os.path.basename(fileabs) if basename not in apex_file_properties: # make sure we have meta data and then get the object type if os.path.isfile(fileabs+"-meta.xml"): xmldoc = minidom.parse(fileabs+"-meta.xml") root = xmldoc.firstChild object_type = root.nodeName else: continue object_id = sfdc_client.get_apex_entity_id_by_name(object_type=object_type, name=basename) if not object_id: continue else: props = apex_file_properties[basename] object_type = props['type'] object_id = props['id'] # only ApexClasses that are global and have webservice scope have WSDL files if open_type == "wsdl": if object_type != "ApexClass": continue with open(fileabs, 'r') as content_file: content = content_file.read() p = re.compile("global\s+(abstract\s+)?class\s", re.I + re.M) if not p.search(content): continue p = re.compile("\swebservice\s", re.I + re.M) if not p.search(content): continue # get the server instance url and set the redirect url frontdoor = "https://" + sfdc_client.server_url.split('/')[2] + "/secur/frontdoor.jsp?sid=" + sfdc_client.sid + "&retURL=" if open_type == "wsdl": f, e = os.path.splitext(basename) ret_url = "/services/wsdl/class/" + f elif open_type == "preview" and object_type == "ApexPage": f, e = os.path.splitext(basename) ret_url = "/apex/"+f else: f, ext = os.path.splitext(basename) if object_type == "CustomObject" and not f.endswith('__c'): # standard object? ret_url = "/p/setup/layout/LayoutFieldList?type=" + f + "%23CustomFieldRelatedList_target" else: ret_url = "/" + object_id if open_type == "preview": urls.append(frontdoor+ret_url) pages.append(basename) else: # open the browser window for this file and track it webbrowser.open(frontdoor+ret_url, new=2) opened.append(basename) if len(opened) == 0 and open_type != 'preview': return util.generate_error_response("There were no valid files to open.") if open_type == 'preview': result = util.generate_success_response("Opened "+(", ".join(opened))+" on server.") result['urls'] = urls result['pages'] = pages return result else: return util.generate_success_response("Opened "+(", ".join(opened))+" on server.") return util.generate_error_response("Unable to open file on server.") else: raise MMException("To open on Salesforce, you must provide an array of 'files'") class SyncMetadataWithServerCommand(Command): """ Syncs local copy of file with server copy """ def execute(self): project = config.project files = self.params.get('files', None) msg = config.project.conflict_manager.sync_with_server(files) if msg != None: return msg else: return util.generate_error_response('Unable to find file in local store.') class CompileSelectedMetadataCommand(Command): """ Compiles metadata """ name="compile" def execute(self): project = config.project files = self.params.get('files', None) use_tooling_api = config.connection.get_plugin_client_setting('mm_compile_with_tooling_api', False) check_for_conflicts = config.connection.get_plugin_client_setting('mm_compile_check_conflicts', False) compiling_apex_metadata = True for f in files: if f.split('.')[-1] not in util.TOOLING_API_EXTENSIONS: #cannot use tooling api compiling_apex_metadata = False break #when compiling apex metadata, check to see if it is newer on the server if check_for_conflicts and compiling_apex_metadata: if 'action' not in self.params or self.params['action'] != 'overwrite': has_conflict, msg = config.project.conflict_manager.check_for_conflicts(files) if has_conflict: return msg #use tooling api here, if possible if use_tooling_api == True and compiling_apex_metadata and int(float(util.SFDC_API_VERSION)) >= 27: if 'metadata_container' not in project.settings or project.settings['metadata_container'] == None: container_id = project.sfdc_client.get_metadata_container_id() new_settings = project.settings new_settings['metadata_container'] = container_id project.put_settings_file(new_settings) else: container_id = project.settings['metadata_container'] file_ext = files[0].split('.')[-1] try: result = project.sfdc_client.compile_with_tooling_api(files, container_id) except MetadataContainerException as e: project.sfdc_client.delete_mavensmate_metadatacontainers_for_this_user() response = project.sfdc_client.new_metadatacontainer_for_this_user() project.update_setting("metadata_container",response["id"]) #return CompileSelectedMetadataCommand(params=self.params,args=self.args).execute() #ensure only a single retry result = project.sfdc_client.compile_with_tooling_api(files, response["id"]) if 'Id' in result and 'State' in result: if result['State'] == 'Completed': project.conflict_manager.refresh_local_store(files=files) return util.generate_response(result) #the user has either chosen not to use the tooling api, or it's non apex metadata else: try: for f in files: if '-meta.xml' in f: corresponding_file = f.split('-meta.xml')[0] if corresponding_file not in files: files.append(corresponding_file) for f in files: if '-meta.xml' in f: continue file_ext = f.split('.')[-1] metadata_type = util.get_meta_type_by_suffix(file_ext) if metadata_type == None: if sys.platform == "win32": dir_parts = f.split("\\") else: dir_parts = f.split("/") if 'documents' in dir_parts: metadata_type = util.get_meta_type_by_name("Document") if metadata_type != None and 'metaFile' in metadata_type and metadata_type['metaFile'] == True: corresponding_file = f + '-meta.xml' if corresponding_file not in files: files.append(corresponding_file) metadata_package_dict = util.get_metadata_hash(files) #debug(metadata_package_dict) tmp = util.put_tmp_directory_on_disk() os.makedirs(os.path.join(tmp,"unpackaged")) #copy files from project directory to tmp for full_file_path in files: if 'package.xml' in full_file_path: continue if config.is_windows: destination = os.path.join(tmp,'unpackaged',full_file_path.split('\src\\')[1]) else: destination = os.path.join(tmp,'unpackaged',full_file_path.split('/src/')[1]) destination_directory = os.path.dirname(destination) if not os.path.exists(destination_directory): os.makedirs(destination_directory) shutil.copy2(full_file_path, destination_directory) package_xml = util.get_package_xml_contents(metadata_package_dict) util.put_package_xml_in_directory(os.path.join(tmp,"unpackaged"), package_xml) zip_file = util.zip_directory(tmp, tmp) deploy_params = { "zip_file" : zip_file, "rollback_on_error" : True, "ret_xml" : True } deploy_result = project.sfdc_client.deploy(deploy_params) d = xmltodict.parse(deploy_result,postprocessor=util.xmltodict_postprocessor) result = d["soapenv:Envelope"]["soapenv:Body"]['checkDeployStatusResponse']['result'] shutil.rmtree(tmp) # Get new properties for the files we just compiled if result['success'] == True: project.conflict_manager.refresh_local_store(files=files) return json.dumps(result) except Exception, e: try: shutil.rmtree(tmp) except: pass return util.generate_error_response(e.message) class ListMetadataCommand(Command): def execute(self): if 'sid' in self.params: debug('executing list metadata!!') debug(self.params) client = MavensMateClient(credentials={ "sid" : self.params.get('sid', None), "metadata_server_url" : urllib.unquote(self.params.get('metadata_server_url', None)), "server_url" : urllib.unquote(self.params.get('server_url', None)), }) elif 'username' in self.params: client = MavensMateClient(credentials={ "username" : self.params.get('username', None), "password" : self.params.get('password', None), "org_type" : self.params.get('org_type', None), "org_url" : self.params.get('org_url', None) }) return json.dumps(client.list_metadata(self.params['metadata_type'])) class RefreshMetadataIndexCommand(Command): def execute(self): IndexMetadataCommand(params=self.params).execute() return util.generate_success_response("Metadata refreshed successfully.") class GetMetadataIndexCommand(Command): aliases=["get_indexed_metadata"] """ Called by the MavensMate edit project dialog to display org metadata in tree """ def execute(self): if 'keyword' in self.params or 'ids' in self.params: return config.project.filter_indexed_metadata(self.params) elif 'package_location' in self.params: return get_org_metadata(True, True, package_location=self.params["package_location"]) else: return get_org_metadata(True, True) def get_org_metadata(raw=False, selectBasedOnPackageXml=False, selectedIds=[], keyword=None, **kwargs): # debug('getting org metadata!'); # debug(raw) # debug(selectBasedOnPackageXml) # debug(kwargs.get('package_location', None)) project = config.project if project.get_is_metadata_indexed(): if raw: org_metadata_raw = util.get_file_as_string(os.path.join(project.location,"config",".org_metadata")) org_index = json.loads(org_metadata_raw) if kwargs.get('package_location', None) != None: project.select_metadata_based_on_package_xml(org_index, kwargs.get('package_location')) elif selectBasedOnPackageXml: project.select_metadata_based_on_package_xml(org_index) elif len(selectedIds) > 0 or keyword != None: if keyword != None: crawlJson.setVisibility(org_index, keyword) if len(selectedIds) > 0: crawlJson.setChecked(org_index, selectedIds) return json.dumps(org_index) else: org_index = util.parse_json_from_file(os.path.join(project.location,"config",".org_metadata")) if selectBasedOnPackageXml: project.select_metadata_based_on_package_xml(org_index) elif len(selectedIds) > 0 or keyword != None: if keyword != None: crawlJson.setVisibility(org_index, keyword) if len(selectedIds) > 0: crawlJson.setChecked(org_index, selectedIds) return org_index else: IndexMetadataCommand(params=self.params).execute() org_index = util.parse_json_from_file(os.path.join(project.location,"config",".org_metadata")) project.select_metadata_based_on_package_xml(org_index) return org_index class IndexMetadataCommand(Command): """ compiles a list of all metadata in the org and places in .org_metadata file """ def execute(self): mtypes = self.params.get('mtypes', None) return config.project.index_metadata(mtypes)
gpl-2.0
[ 646, 984, 199, 646, 2022, 199, 646, 747, 199, 646, 8562, 14, 1974, 465, 4884, 199, 646, 8562, 14, 1652, 475, 807, 465, 2748, 475, 807, 199, 646, 8562, 14, 888, 465, 1101, 199, 646, 5145, 199, 646, 4011, 199, 646, 295, 199, 646, 5796, 199, 504, 4182, 492, 1242, 7416, 199, 504, 2748, 14, 4556, 492, 19165, 199, 646, 781, 29063, 199, 504, 8562, 14, 83, 32186, 63, 1258, 492, 603, 1214, 8764, 45, 323, 3041, 199, 504, 8562, 14, 3924, 492, 627, 199, 504, 8562, 14, 1095, 1531, 492, 5817, 199, 199, 1757, 275, 1101, 14, 2921, 14, 1757, 199, 199, 533, 7053, 5142, 3110, 8, 3110, 304, 272, 408, 267, 10560, 282, 892, 1819, 402, 3341, 272, 408, 272, 347, 5341, 8, 277, 304, 267, 2199, 275, 1101, 14, 1715, 267, 308, 32186, 63, 1258, 275, 1101, 14, 83, 32186, 63, 1258, 398, 3341, 63, 466, 7861, 275, 291, 14, 1162, 14, 362, 360, 2343, 63, 466, 297, 488, 9, 267, 12869, 63, 1160, 463, 275, 291, 14, 1162, 14, 362, 360, 5031, 63, 1160, 297, 488, 9, 267, 1862, 14516, 275, 291, 14, 1162, 14, 362, 360, 1162, 297, 488, 9, 398, 340, 1862, 508, 488, 26, 288, 746, 603, 45, 1726, 360, 1918, 4886, 370, 1218, 3341, 965, 23568, 2896, 14, 982, 1265, 787, 1808, 4804, 18687, 4516, 12, 1265, 12060, 1929, 370, 1678, 2195, 603, 1214, 8764, 45, 323, 3589, 370, 650, 14, 20, 14, 24, 13854, 398, 340, 298, 1246, 63, 354, 2, 440, 315, 1862, 503, 1862, 905, 1246, 63, 354, 937, 508, 488, 503, 1862, 905, 1246, 63, 354, 937, 508, 8061, 288, 372, 4884, 14, 4208, 63, 705, 63, 1310, 480, 5556, 1471, 5647, 282, 536, 367, 314, 892, 3341, 2685, 398, 2986, 63, 354, 275, 1862, 14, 362, 360, 1246, 63, 354, 358, 398, 340, 308, 32186, 63, 1258, 14, 9105, 63, 2343, 63, 4494, 8, 785, 63, 466, 29, 2343, 63, 466, 12, 536, 29, 1246, 63, 354, 9, 508, 715, 26, 288, 19592, 275, 4884, 14, 362, 63, 2024, 63, 466, 63, 991, 63, 354, 8, 2343, 63, 466, 9, 288, 9911, 275, 747, 14, 515, 14, 904, 8, 1715, 14, 1985, 12, 283, 2164, 297, 19592, 459, 3619, 985, 995, 2986, 63, 354, 18098, 6828, 2037, 459, 4511, 1105, 288, 19251, 275, 3087, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 7218, 304, 355, 291, 14, 1162, 459, 1725, 418, 275, 359, 7218, 61, 355, 30345, 12461, 5142, 3110, 8, 1162, 29, 277, 14, 1162, 12, 589, 29, 277, 14, 589, 680, 2526, 342, 355, 19251, 275, 3872, 19251, 3341, 570, 687, 1654, 2, 288, 746, 603, 45, 1726, 480, 2765, 3261, 536, 365, 2575, 315, 675, 315, 2195, 5981, 2, 435, 19251, 435, 298, 2685, 755, 398, 3529, 12, 3529, 63, 324, 2491, 68, 275, 4884, 14, 524, 63, 2791, 63, 3619, 63, 265, 63, 4032, 8, 549, 9, 2728, 4884, 14, 524, 63, 29250, 63, 1725, 63, 265, 63, 4032, 8, 2343, 63, 466, 12, 3529, 63, 324, 2491, 68, 12, 12869, 63, 1160, 12, 1862, 9, 267, 2559, 63, 1652, 63, 2030, 275, 4884, 14, 362, 63, 2491, 63, 1652, 63, 4407, 2561, 2343, 63, 466, 520, 359, 2986, 63, 354, 1622, 1552, 267, 4884, 14, 524, 63, 2491, 63, 1652, 63, 262, 63, 3619, 8, 2791, 63, 324, 2491, 68, 12, 2559, 63, 1652, 63, 2030, 9, 267, 3482, 63, 493, 275, 4884, 14, 3065, 63, 3619, 8, 2791, 12, 3529, 9, 267, 12287, 63, 1162, 275, 469, 288, 298, 3065, 63, 493, 2, 3515, 520, 3482, 63, 493, 12, 288, 298, 10437, 63, 265, 63, 705, 2, 520, 715, 12, 288, 298, 3292, 63, 1652, 2, 3698, 520, 715, 267, 789, 267, 12287, 63, 1099, 275, 308, 32186, 63, 1258, 14, 11060, 8, 11060, 63, 1162, 9, 267, 366, 275, 2748, 475, 807, 14, 1122, 8, 11060, 63, 1099, 12, 1932, 6459, 29, 1974, 14, 1652, 475, 807, 63, 1932, 6459, 9, 267, 3404, 63, 694, 275, 3087, 267, 1584, 275, 942, 267, 931, 275, 488, 267, 367, 9017, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2791, 63, 324, 2491, 68, 304, 288, 367, 1788, 315, 6203, 26, 355, 340, 283, 2491, 14, 1652, 7, 315, 1788, 26, 490, 1980, 355, 2615, 63, 493, 63, 515, 275, 747, 14, 515, 14, 904, 8, 3475, 12, 1788, 9, 355, 340, 2475, 2024, 14, 1652, 7, 315, 1788, 26, 490, 3329, 275, 1788, 14, 1814, 3654, 2024, 14, 1652, 26516, 1294, 15857, 1988, 17, 61, 355, 587, 26, 490, 3329, 275, 1788, 14, 1294, 15857, 1988, 17, 61, 355, 19592, 275, 4884, 14, 362, 63, 2024, 63, 466, 63, 991, 63, 4511, 8, 3435, 9, 355, 340, 19592, 1137, 488, 26, 15324, 3404, 63, 694, 275, 19592, 459, 3619, 985, 418, 490, 931, 275, 747, 14, 515, 14, 904, 8, 1715, 14, 1985, 12, 283, 2164, 297, 3404, 63, 694, 9, 490, 340, 440, 747, 14, 515, 14, 2444, 8, 515, 304, 717, 747, 14, 8347, 8, 515, 9, 490, 1584, 14, 740, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1788, 430, 355, 916, 3329, 1137, 298, 1652, 582, 490, 1980, 27, 355, 327, 1454, 282, 16531, 1584, 436, 3404, 14, 1652, 1584, 1077, 1852, 652, 370, 2348, 355, 5145, 14, 1574, 8, 2861, 63, 493, 63, 515, 12, 931, 9, 267, 5145, 14, 9242, 8, 2791, 9, 2728, 2199, 14, 873, 63, 2491, 63, 1652, 63, 1045, 63, 2343, 8, 2343, 63, 466, 12, 2986, 63, 354, 9, 267, 2199, 14, 15207, 63, 2609, 14, 6635, 63, 1832, 63, 1617, 8, 1725, 29, 1725, 9, 398, 372, 2022, 14, 4180, 8, 68, 905, 21818, 1813, 26, 28278, 6611, 21818, 1813, 26, 8173, 937, 459, 1074, 27597, 3694, 2364, 2545, 1099, 1105, 199, 199, 533, 8496, 12461, 5142, 3110, 8, 3110, 304, 272, 5481, 6270, 1807, 937, 272, 408, 267, 28382, 3341, 687, 314, 428, 7098, 3990, 14, 957, 1654, 272, 408, 272, 347, 5341, 8, 277, 304, 267, 2199, 275, 1101, 14, 1715, 267, 308, 32186, 63, 1258, 275, 1101, 14, 83, 32186, 63, 1258, 267, 1584, 275, 291, 14, 1162 ]
[ 984, 199, 646, 2022, 199, 646, 747, 199, 646, 8562, 14, 1974, 465, 4884, 199, 646, 8562, 14, 1652, 475, 807, 465, 2748, 475, 807, 199, 646, 8562, 14, 888, 465, 1101, 199, 646, 5145, 199, 646, 4011, 199, 646, 295, 199, 646, 5796, 199, 504, 4182, 492, 1242, 7416, 199, 504, 2748, 14, 4556, 492, 19165, 199, 646, 781, 29063, 199, 504, 8562, 14, 83, 32186, 63, 1258, 492, 603, 1214, 8764, 45, 323, 3041, 199, 504, 8562, 14, 3924, 492, 627, 199, 504, 8562, 14, 1095, 1531, 492, 5817, 199, 199, 1757, 275, 1101, 14, 2921, 14, 1757, 199, 199, 533, 7053, 5142, 3110, 8, 3110, 304, 272, 408, 267, 10560, 282, 892, 1819, 402, 3341, 272, 408, 272, 347, 5341, 8, 277, 304, 267, 2199, 275, 1101, 14, 1715, 267, 308, 32186, 63, 1258, 275, 1101, 14, 83, 32186, 63, 1258, 398, 3341, 63, 466, 7861, 275, 291, 14, 1162, 14, 362, 360, 2343, 63, 466, 297, 488, 9, 267, 12869, 63, 1160, 463, 275, 291, 14, 1162, 14, 362, 360, 5031, 63, 1160, 297, 488, 9, 267, 1862, 14516, 275, 291, 14, 1162, 14, 362, 360, 1162, 297, 488, 9, 398, 340, 1862, 508, 488, 26, 288, 746, 603, 45, 1726, 360, 1918, 4886, 370, 1218, 3341, 965, 23568, 2896, 14, 982, 1265, 787, 1808, 4804, 18687, 4516, 12, 1265, 12060, 1929, 370, 1678, 2195, 603, 1214, 8764, 45, 323, 3589, 370, 650, 14, 20, 14, 24, 13854, 398, 340, 298, 1246, 63, 354, 2, 440, 315, 1862, 503, 1862, 905, 1246, 63, 354, 937, 508, 488, 503, 1862, 905, 1246, 63, 354, 937, 508, 8061, 288, 372, 4884, 14, 4208, 63, 705, 63, 1310, 480, 5556, 1471, 5647, 282, 536, 367, 314, 892, 3341, 2685, 398, 2986, 63, 354, 275, 1862, 14, 362, 360, 1246, 63, 354, 358, 398, 340, 308, 32186, 63, 1258, 14, 9105, 63, 2343, 63, 4494, 8, 785, 63, 466, 29, 2343, 63, 466, 12, 536, 29, 1246, 63, 354, 9, 508, 715, 26, 288, 19592, 275, 4884, 14, 362, 63, 2024, 63, 466, 63, 991, 63, 354, 8, 2343, 63, 466, 9, 288, 9911, 275, 747, 14, 515, 14, 904, 8, 1715, 14, 1985, 12, 283, 2164, 297, 19592, 459, 3619, 985, 995, 2986, 63, 354, 18098, 6828, 2037, 459, 4511, 1105, 288, 19251, 275, 3087, 288, 340, 440, 747, 14, 515, 14, 2444, 8, 7218, 304, 355, 291, 14, 1162, 459, 1725, 418, 275, 359, 7218, 61, 355, 30345, 12461, 5142, 3110, 8, 1162, 29, 277, 14, 1162, 12, 589, 29, 277, 14, 589, 680, 2526, 342, 355, 19251, 275, 3872, 19251, 3341, 570, 687, 1654, 2, 288, 746, 603, 45, 1726, 480, 2765, 3261, 536, 365, 2575, 315, 675, 315, 2195, 5981, 2, 435, 19251, 435, 298, 2685, 755, 398, 3529, 12, 3529, 63, 324, 2491, 68, 275, 4884, 14, 524, 63, 2791, 63, 3619, 63, 265, 63, 4032, 8, 549, 9, 2728, 4884, 14, 524, 63, 29250, 63, 1725, 63, 265, 63, 4032, 8, 2343, 63, 466, 12, 3529, 63, 324, 2491, 68, 12, 12869, 63, 1160, 12, 1862, 9, 267, 2559, 63, 1652, 63, 2030, 275, 4884, 14, 362, 63, 2491, 63, 1652, 63, 4407, 2561, 2343, 63, 466, 520, 359, 2986, 63, 354, 1622, 1552, 267, 4884, 14, 524, 63, 2491, 63, 1652, 63, 262, 63, 3619, 8, 2791, 63, 324, 2491, 68, 12, 2559, 63, 1652, 63, 2030, 9, 267, 3482, 63, 493, 275, 4884, 14, 3065, 63, 3619, 8, 2791, 12, 3529, 9, 267, 12287, 63, 1162, 275, 469, 288, 298, 3065, 63, 493, 2, 3515, 520, 3482, 63, 493, 12, 288, 298, 10437, 63, 265, 63, 705, 2, 520, 715, 12, 288, 298, 3292, 63, 1652, 2, 3698, 520, 715, 267, 789, 267, 12287, 63, 1099, 275, 308, 32186, 63, 1258, 14, 11060, 8, 11060, 63, 1162, 9, 267, 366, 275, 2748, 475, 807, 14, 1122, 8, 11060, 63, 1099, 12, 1932, 6459, 29, 1974, 14, 1652, 475, 807, 63, 1932, 6459, 9, 267, 3404, 63, 694, 275, 3087, 267, 1584, 275, 942, 267, 931, 275, 488, 267, 367, 9017, 12, 22310, 12, 6203, 315, 747, 14, 7757, 8, 2791, 63, 324, 2491, 68, 304, 288, 367, 1788, 315, 6203, 26, 355, 340, 283, 2491, 14, 1652, 7, 315, 1788, 26, 490, 1980, 355, 2615, 63, 493, 63, 515, 275, 747, 14, 515, 14, 904, 8, 3475, 12, 1788, 9, 355, 340, 2475, 2024, 14, 1652, 7, 315, 1788, 26, 490, 3329, 275, 1788, 14, 1814, 3654, 2024, 14, 1652, 26516, 1294, 15857, 1988, 17, 61, 355, 587, 26, 490, 3329, 275, 1788, 14, 1294, 15857, 1988, 17, 61, 355, 19592, 275, 4884, 14, 362, 63, 2024, 63, 466, 63, 991, 63, 4511, 8, 3435, 9, 355, 340, 19592, 1137, 488, 26, 15324, 3404, 63, 694, 275, 19592, 459, 3619, 985, 418, 490, 931, 275, 747, 14, 515, 14, 904, 8, 1715, 14, 1985, 12, 283, 2164, 297, 3404, 63, 694, 9, 490, 340, 440, 747, 14, 515, 14, 2444, 8, 515, 304, 717, 747, 14, 8347, 8, 515, 9, 490, 1584, 14, 740, 8, 736, 14, 515, 14, 904, 8, 515, 12, 1788, 430, 355, 916, 3329, 1137, 298, 1652, 582, 490, 1980, 27, 355, 327, 1454, 282, 16531, 1584, 436, 3404, 14, 1652, 1584, 1077, 1852, 652, 370, 2348, 355, 5145, 14, 1574, 8, 2861, 63, 493, 63, 515, 12, 931, 9, 267, 5145, 14, 9242, 8, 2791, 9, 2728, 2199, 14, 873, 63, 2491, 63, 1652, 63, 1045, 63, 2343, 8, 2343, 63, 466, 12, 2986, 63, 354, 9, 267, 2199, 14, 15207, 63, 2609, 14, 6635, 63, 1832, 63, 1617, 8, 1725, 29, 1725, 9, 398, 372, 2022, 14, 4180, 8, 68, 905, 21818, 1813, 26, 28278, 6611, 21818, 1813, 26, 8173, 937, 459, 1074, 27597, 3694, 2364, 2545, 1099, 1105, 199, 199, 533, 8496, 12461, 5142, 3110, 8, 3110, 304, 272, 5481, 6270, 1807, 937, 272, 408, 267, 28382, 3341, 687, 314, 428, 7098, 3990, 14, 957, 1654, 272, 408, 272, 347, 5341, 8, 277, 304, 267, 2199, 275, 1101, 14, 1715, 267, 308, 32186, 63, 1258, 275, 1101, 14, 83, 32186, 63, 1258, 267, 1584, 275, 291, 14, 1162, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wilfeli/DMGameBasic
ExternalTools/Eigen/debug/gdb/printers.py
143
6360
# -*- coding: utf-8 -*- # This file is part of Eigen, a lightweight C++ template library # for linear algebra. # # Copyright (C) 2009 Benjamin Schindler <bschindler@inf.ethz.ch> # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # Pretty printers for Eigen::Matrix # This is still pretty basic as the python extension to gdb is still pretty basic. # It cannot handle complex eigen types and it doesn't support any of the other eigen types # Such as quaternion or some other type. # This code supports fixed size as well as dynamic size matrices # To use it: # # * Create a directory and put the file as well as an empty __init__.py in # that directory. # * Create a ~/.gdbinit file, that contains the following: # python # import sys # sys.path.insert(0, '/path/to/eigen/printer/directory') # from printers import register_eigen_printers # register_eigen_printers (None) # end import gdb import re import itertools class EigenMatrixPrinter: "Print Eigen Matrix or Array of some kind" def __init__(self, variety, val): "Extract all the necessary information" # Save the variety (presumably "Matrix" or "Array") for later usage self.variety = variety # The gdb extension does not support value template arguments - need to extract them by hand type = val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() self.type = type.unqualified().strip_typedefs() tag = self.type.tag regex = re.compile('\<.*\>') m = regex.findall(tag)[0][1:-1] template_params = m.split(',') template_params = map(lambda x:x.replace(" ", ""), template_params) if template_params[1] == '-0x00000000000000001' or template_params[1] == '-0x000000001' or template_params[1] == '-1': self.rows = val['m_storage']['m_rows'] else: self.rows = int(template_params[1]) if template_params[2] == '-0x00000000000000001' or template_params[2] == '-0x000000001' or template_params[2] == '-1': self.cols = val['m_storage']['m_cols'] else: self.cols = int(template_params[2]) self.options = 0 # default value if len(template_params) > 3: self.options = template_params[3]; self.rowMajor = (int(self.options) & 0x1) self.innerType = self.type.template_argument(0) self.val = val # Fixed size matrices have a struct as their storage, so we need to walk through this self.data = self.val['m_storage']['m_data'] if self.data.type.code == gdb.TYPE_CODE_STRUCT: self.data = self.data['array'] self.data = self.data.cast(self.innerType.pointer()) class _iterator: def __init__ (self, rows, cols, dataPtr, rowMajor): self.rows = rows self.cols = cols self.dataPtr = dataPtr self.currentRow = 0 self.currentCol = 0 self.rowMajor = rowMajor def __iter__ (self): return self def next(self): row = self.currentRow col = self.currentCol if self.rowMajor == 0: if self.currentCol >= self.cols: raise StopIteration self.currentRow = self.currentRow + 1 if self.currentRow >= self.rows: self.currentRow = 0 self.currentCol = self.currentCol + 1 else: if self.currentRow >= self.rows: raise StopIteration self.currentCol = self.currentCol + 1 if self.currentCol >= self.cols: self.currentCol = 0 self.currentRow = self.currentRow + 1 item = self.dataPtr.dereference() self.dataPtr = self.dataPtr + 1 if (self.cols == 1): #if it's a column vector return ('[%d]' % (row,), item) elif (self.rows == 1): #if it's a row vector return ('[%d]' % (col,), item) return ('[%d,%d]' % (row, col), item) def children(self): return self._iterator(self.rows, self.cols, self.data, self.rowMajor) def to_string(self): return "Eigen::%s<%s,%d,%d,%s> (data ptr: %s)" % (self.variety, self.innerType, self.rows, self.cols, "RowMajor" if self.rowMajor else "ColMajor", self.data) class EigenQuaternionPrinter: "Print an Eigen Quaternion" def __init__(self, val): "Extract all the necessary information" # The gdb extension does not support value template arguments - need to extract them by hand type = val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() self.type = type.unqualified().strip_typedefs() self.innerType = self.type.template_argument(0) self.val = val # Quaternions have a struct as their storage, so we need to walk through this self.data = self.val['m_coeffs']['m_storage']['m_data']['array'] self.data = self.data.cast(self.innerType.pointer()) class _iterator: def __init__ (self, dataPtr): self.dataPtr = dataPtr self.currentElement = 0 self.elementNames = ['x', 'y', 'z', 'w'] def __iter__ (self): return self def next(self): element = self.currentElement if self.currentElement >= 4: #there are 4 elements in a quanternion raise StopIteration self.currentElement = self.currentElement + 1 item = self.dataPtr.dereference() self.dataPtr = self.dataPtr + 1 return ('[%s]' % (self.elementNames[element],), item) def children(self): return self._iterator(self.data) def to_string(self): return "Eigen::Quaternion<%s> (data ptr: %s)" % (self.innerType, self.data) def build_eigen_dictionary (): pretty_printers_dict[re.compile('^Eigen::Quaternion<.*>$')] = lambda val: EigenQuaternionPrinter(val) pretty_printers_dict[re.compile('^Eigen::Matrix<.*>$')] = lambda val: EigenMatrixPrinter("Matrix", val) pretty_printers_dict[re.compile('^Eigen::Array<.*>$')] = lambda val: EigenMatrixPrinter("Array", val) def register_eigen_printers(obj): "Register eigen pretty-printers with objfile Obj" if obj == None: obj = gdb obj.pretty_printers.append(lookup_function) def lookup_function(val): "Look-up and return a pretty-printer that can print va." type = val.type if type.code == gdb.TYPE_CODE_REF: type = type.target() type = type.unqualified().strip_typedefs() typename = type.tag if typename == None: return None for function in pretty_printers_dict: if function.search(typename): return pretty_printers_dict[function](val) return None pretty_printers_dict = {} build_eigen_dictionary ()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 662, 8478, 12, 282, 10540, 3463, 445, 4176, 1978, 3555, 199, 3, 367, 7798, 741, 19355, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 26844, 16997, 262, 22985, 688, 1435, 665, 1533, 335, 688, 1435, 32, 4904, 14, 12391, 90, 14, 335, 30, 199, 3, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 3, 31651, 5448, 11005, 367, 662, 8478, 447, 6443, 199, 3, 961, 365, 5139, 7268, 5678, 465, 314, 2366, 3329, 370, 12124, 365, 5139, 7268, 5678, 14, 221, 199, 3, 2779, 3913, 2429, 6114, 11471, 2943, 436, 652, 3181, 1133, 2291, 1263, 402, 314, 1163, 11471, 2943, 199, 3, 32753, 465, 2173, 28945, 503, 2005, 1163, 730, 14, 221, 199, 3, 961, 1233, 5171, 6317, 1568, 465, 5521, 465, 8336, 1568, 12627, 199, 199, 3, 4005, 675, 652, 26, 199, 3, 199, 3, 627, 2790, 282, 2082, 436, 5324, 314, 570, 465, 5521, 465, 376, 2701, 636, 826, 4343, 647, 315, 221, 199, 3, 257, 626, 2082, 14, 199, 3, 627, 2790, 282, 25975, 17119, 826, 570, 12, 626, 3509, 314, 2569, 26, 199, 3, 420, 2366, 199, 3, 420, 492, 984, 199, 3, 420, 984, 14, 515, 14, 3176, 8, 16, 12, 1994, 515, 15, 475, 15, 19545, 15, 11835, 15, 3619, 358, 199, 3, 420, 687, 5448, 11005, 492, 2274, 63, 19545, 63, 24858, 199, 3, 420, 2274, 63, 19545, 63, 24858, 334, 403, 9, 199, 3, 420, 1284, 199, 199, 646, 12124, 199, 646, 295, 199, 646, 7975, 421, 199, 533, 662, 8478, 6443, 14131, 26, 199, 198, 2, 5375, 662, 8478, 8449, 503, 8725, 402, 2005, 4928, 2, 421, 198, 318, 636, 826, 721, 277, 12, 32246, 12, 1139, 304, 507, 198, 2, 12147, 1006, 314, 5784, 2556, 2, 9068, 198, 3, 11063, 314, 32246, 334, 24919, 453, 6665, 298, 6443, 2, 503, 298, 3836, 531, 367, 2945, 4503, 507, 198, 277, 14, 3808, 23364, 275, 32246, 9068, 198, 3, 710, 12124, 3329, 1630, 440, 2291, 574, 1978, 2368, 446, 1929, 370, 5536, 3062, 701, 4926, 507, 198, 466, 275, 1139, 14, 466, 507, 198, 692, 730, 14, 600, 508, 12124, 14, 2711, 63, 6012, 63, 8279, 26, 686, 198, 466, 275, 730, 14, 1375, 342, 507, 198, 277, 14, 466, 275, 730, 14, 324, 11661, 1252, 1913, 63, 466, 8710, 342, 507, 198, 1450, 275, 291, 14, 466, 14, 1450, 507, 198, 3821, 275, 295, 14, 2014, 2258, 28, 17910, 5971, 507, 198, 77, 275, 5163, 14, 6452, 8, 1450, 2788, 16, 1527, 17, 6809, 17, 61, 507, 198, 1160, 63, 1162, 275, 333, 14, 1294, 11917, 507, 198, 1160, 63, 1162, 275, 2341, 8, 2734, 671, 26, 88, 14, 1814, 480, 3872, 16241, 1978, 63, 1162, 9, 9068, 198, 692, 1978, 63, 1162, 59, 17, 61, 508, 2475, 16, 88, 9409, 17, 7, 503, 1978, 63, 1162, 59, 17, 61, 508, 2475, 16, 88, 3607, 17, 7, 503, 1978, 63, 1162, 59, 17, 61, 508, 2475, 17, 356, 686, 198, 277, 14, 3838, 275, 1139, 459, 77, 63, 3494, 2545, 77, 63, 3838, 418, 507, 198, 2836, 26, 686, 198, 277, 14, 3838, 275, 1109, 8, 1160, 63, 1162, 59, 17, 566, 9068, 198, 692, 1978, 63, 1162, 59, 18, 61, 508, 2475, 16, 88, 9409, 17, 7, 503, 1978, 63, 1162, 59, 18, 61, 508, 2475, 16, 88, 3607, 17, 7, 503, 1978, 63, 1162, 59, 18, 61, 508, 2475, 17, 356, 686, 198, 277, 14, 4574, 275, 1139, 459, 77, 63, 3494, 2545, 77, 63, 4574, 418, 507, 198, 2836, 26, 686, 198, 277, 14, 4574, 275, 1109, 8, 1160, 63, 1162, 59, 18, 566, 9068, 198, 277, 14, 1419, 275, 378, 327, 849, 574, 507, 198, 692, 822, 8, 1160, 63, 1162, 9, 690, 650, 26, 686, 198, 277, 14, 1419, 275, 1978, 63, 1162, 59, 19, 11566, 9068, 198, 277, 14, 1143, 21657, 275, 334, 442, 8, 277, 14, 1419, 9, 1253, 378, 88, 17, 9, 9068, 198, 277, 14, 5216, 804, 275, 291, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 9068, 198, 277, 14, 637, 275, 1139, 9068, 198, 3, 18659, 1568, 12627, 1172, 282, 2702, 465, 3932, 4887, 12, 880, 781, 1929, 370, 12778, 4012, 642, 507, 198, 277, 14, 576, 275, 291, 14, 637, 459, 77, 63, 3494, 2545, 77, 63, 576, 418, 507, 198, 692, 291, 14, 576, 14, 466, 14, 600, 508, 12124, 14, 2711, 63, 6012, 63, 8893, 26, 686, 198, 277, 14, 576, 275, 291, 14, 576, 459, 1144, 418, 686, 198, 277, 14, 576, 275, 291, 14, 576, 14, 2931, 8, 277, 14, 5216, 804, 14, 3929, 1012, 1585, 199, 198, 533, 485, 5778, 26, 507, 198, 318, 636, 826, 363, 334, 277, 12, 4730, 12, 8850, 12, 666, 2115, 12, 1962, 21657, 304, 686, 198, 277, 14, 3838, 275, 4730, 686, 198, 277, 14, 4574, 275, 8850, 686, 198, 277, 14, 576, 2115, 275, 666, 2115, 686, 198, 277, 14, 1818, 5810, 275, 378, 686, 198, 277, 14, 1818, 2001, 275, 378, 686, 198, 277, 14, 1143, 21657, 275, 1962, 21657, 1585, 507, 198, 318, 636, 1661, 363, 334, 277, 304, 686, 198, 1107, 291, 1585, 507, 198, 318, 2163, 8, 277, 304, 26140, 198, 1143, 275, 291, 14, 1818, 5810, 686, 198, 761, 275, 291, 14, 1818, 2001, 686, 198, 692, 291, 14, 1143, 21657, 508, 378, 26, 1585, 198, 692, 291, 14, 1818, 2001, 2356, 291, 14, 4574, 26, 1871, 198, 3730, 10852, 4671, 1585, 198, 277, 14, 1818, 5810, 275, 291, 14, 1818, 5810, 435, 413, 1585, 198, 692, 291, 14, 1818, 5810, 2356, 291, 14, 3838, 26, 1871, 198, 277, 14, 1818, 5810, 275, 378, 1871, 198, 277, 14, 1818, 2001, 275, 291, 14, 1818, 2001, 435, 413, 686, 198, 2836, 26, 1585, 198, 692, 291, 14, 1818 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 662, 8478, 12, 282, 10540, 3463, 445, 4176, 1978, 3555, 199, 3, 367, 7798, 741, 19355, 14, 199, 3, 199, 3, 1898, 334, 35, 9, 8937, 26844, 16997, 262, 22985, 688, 1435, 665, 1533, 335, 688, 1435, 32, 4904, 14, 12391, 90, 14, 335, 30, 199, 3, 199, 3, 961, 5800, 5495, 8204, 365, 5420, 370, 314, 2895, 402, 314, 17728, 1684, 199, 3, 844, 12, 373, 14, 499, 14, 16, 14, 982, 282, 1331, 402, 314, 28481, 1990, 440, 1854, 543, 642, 199, 3, 570, 12, 2047, 883, 3332, 1373, 737, 1455, 921, 12102, 14, 1308, 15, 3950, 15, 18, 14, 16, 8083, 199, 199, 3, 31651, 5448, 11005, 367, 662, 8478, 447, 6443, 199, 3, 961, 365, 5139, 7268, 5678, 465, 314, 2366, 3329, 370, 12124, 365, 5139, 7268, 5678, 14, 221, 199, 3, 2779, 3913, 2429, 6114, 11471, 2943, 436, 652, 3181, 1133, 2291, 1263, 402, 314, 1163, 11471, 2943, 199, 3, 32753, 465, 2173, 28945, 503, 2005, 1163, 730, 14, 221, 199, 3, 961, 1233, 5171, 6317, 1568, 465, 5521, 465, 8336, 1568, 12627, 199, 199, 3, 4005, 675, 652, 26, 199, 3, 199, 3, 627, 2790, 282, 2082, 436, 5324, 314, 570, 465, 5521, 465, 376, 2701, 636, 826, 4343, 647, 315, 221, 199, 3, 257, 626, 2082, 14, 199, 3, 627, 2790, 282, 25975, 17119, 826, 570, 12, 626, 3509, 314, 2569, 26, 199, 3, 420, 2366, 199, 3, 420, 492, 984, 199, 3, 420, 984, 14, 515, 14, 3176, 8, 16, 12, 1994, 515, 15, 475, 15, 19545, 15, 11835, 15, 3619, 358, 199, 3, 420, 687, 5448, 11005, 492, 2274, 63, 19545, 63, 24858, 199, 3, 420, 2274, 63, 19545, 63, 24858, 334, 403, 9, 199, 3, 420, 1284, 199, 199, 646, 12124, 199, 646, 295, 199, 646, 7975, 421, 199, 533, 662, 8478, 6443, 14131, 26, 199, 198, 2, 5375, 662, 8478, 8449, 503, 8725, 402, 2005, 4928, 2, 421, 198, 318, 636, 826, 721, 277, 12, 32246, 12, 1139, 304, 507, 198, 2, 12147, 1006, 314, 5784, 2556, 2, 9068, 198, 3, 11063, 314, 32246, 334, 24919, 453, 6665, 298, 6443, 2, 503, 298, 3836, 531, 367, 2945, 4503, 507, 198, 277, 14, 3808, 23364, 275, 32246, 9068, 198, 3, 710, 12124, 3329, 1630, 440, 2291, 574, 1978, 2368, 446, 1929, 370, 5536, 3062, 701, 4926, 507, 198, 466, 275, 1139, 14, 466, 507, 198, 692, 730, 14, 600, 508, 12124, 14, 2711, 63, 6012, 63, 8279, 26, 686, 198, 466, 275, 730, 14, 1375, 342, 507, 198, 277, 14, 466, 275, 730, 14, 324, 11661, 1252, 1913, 63, 466, 8710, 342, 507, 198, 1450, 275, 291, 14, 466, 14, 1450, 507, 198, 3821, 275, 295, 14, 2014, 2258, 28, 17910, 5971, 507, 198, 77, 275, 5163, 14, 6452, 8, 1450, 2788, 16, 1527, 17, 6809, 17, 61, 507, 198, 1160, 63, 1162, 275, 333, 14, 1294, 11917, 507, 198, 1160, 63, 1162, 275, 2341, 8, 2734, 671, 26, 88, 14, 1814, 480, 3872, 16241, 1978, 63, 1162, 9, 9068, 198, 692, 1978, 63, 1162, 59, 17, 61, 508, 2475, 16, 88, 9409, 17, 7, 503, 1978, 63, 1162, 59, 17, 61, 508, 2475, 16, 88, 3607, 17, 7, 503, 1978, 63, 1162, 59, 17, 61, 508, 2475, 17, 356, 686, 198, 277, 14, 3838, 275, 1139, 459, 77, 63, 3494, 2545, 77, 63, 3838, 418, 507, 198, 2836, 26, 686, 198, 277, 14, 3838, 275, 1109, 8, 1160, 63, 1162, 59, 17, 566, 9068, 198, 692, 1978, 63, 1162, 59, 18, 61, 508, 2475, 16, 88, 9409, 17, 7, 503, 1978, 63, 1162, 59, 18, 61, 508, 2475, 16, 88, 3607, 17, 7, 503, 1978, 63, 1162, 59, 18, 61, 508, 2475, 17, 356, 686, 198, 277, 14, 4574, 275, 1139, 459, 77, 63, 3494, 2545, 77, 63, 4574, 418, 507, 198, 2836, 26, 686, 198, 277, 14, 4574, 275, 1109, 8, 1160, 63, 1162, 59, 18, 566, 9068, 198, 277, 14, 1419, 275, 378, 327, 849, 574, 507, 198, 692, 822, 8, 1160, 63, 1162, 9, 690, 650, 26, 686, 198, 277, 14, 1419, 275, 1978, 63, 1162, 59, 19, 11566, 9068, 198, 277, 14, 1143, 21657, 275, 334, 442, 8, 277, 14, 1419, 9, 1253, 378, 88, 17, 9, 9068, 198, 277, 14, 5216, 804, 275, 291, 14, 466, 14, 1160, 63, 2094, 8, 16, 9, 9068, 198, 277, 14, 637, 275, 1139, 9068, 198, 3, 18659, 1568, 12627, 1172, 282, 2702, 465, 3932, 4887, 12, 880, 781, 1929, 370, 12778, 4012, 642, 507, 198, 277, 14, 576, 275, 291, 14, 637, 459, 77, 63, 3494, 2545, 77, 63, 576, 418, 507, 198, 692, 291, 14, 576, 14, 466, 14, 600, 508, 12124, 14, 2711, 63, 6012, 63, 8893, 26, 686, 198, 277, 14, 576, 275, 291, 14, 576, 459, 1144, 418, 686, 198, 277, 14, 576, 275, 291, 14, 576, 14, 2931, 8, 277, 14, 5216, 804, 14, 3929, 1012, 1585, 199, 198, 533, 485, 5778, 26, 507, 198, 318, 636, 826, 363, 334, 277, 12, 4730, 12, 8850, 12, 666, 2115, 12, 1962, 21657, 304, 686, 198, 277, 14, 3838, 275, 4730, 686, 198, 277, 14, 4574, 275, 8850, 686, 198, 277, 14, 576, 2115, 275, 666, 2115, 686, 198, 277, 14, 1818, 5810, 275, 378, 686, 198, 277, 14, 1818, 2001, 275, 378, 686, 198, 277, 14, 1143, 21657, 275, 1962, 21657, 1585, 507, 198, 318, 636, 1661, 363, 334, 277, 304, 686, 198, 1107, 291, 1585, 507, 198, 318, 2163, 8, 277, 304, 26140, 198, 1143, 275, 291, 14, 1818, 5810, 686, 198, 761, 275, 291, 14, 1818, 2001, 686, 198, 692, 291, 14, 1143, 21657, 508, 378, 26, 1585, 198, 692, 291, 14, 1818, 2001, 2356, 291, 14, 4574, 26, 1871, 198, 3730, 10852, 4671, 1585, 198, 277, 14, 1818, 5810, 275, 291, 14, 1818, 5810, 435, 413, 1585, 198, 692, 291, 14, 1818, 5810, 2356, 291, 14, 3838, 26, 1871, 198, 277, 14, 1818, 5810, 275, 378, 1871, 198, 277, 14, 1818, 2001, 275, 291, 14, 1818, 2001, 435, 413, 686, 198, 2836, 26, 1585, 198, 692, 291, 14, 1818, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
infoxchange/lettuce
tests/integration/lib/Django-1.2.5/tests/regressiontests/select_related_onetoone/models.py
144
1340
from django.db import models class User(models.Model): username = models.CharField(max_length=100) email = models.EmailField() def __unicode__(self): return self.username class UserProfile(models.Model): user = models.OneToOneField(User) city = models.CharField(max_length=100) state = models.CharField(max_length=2) def __unicode__(self): return "%s, %s" % (self.city, self.state) class UserStatResult(models.Model): results = models.CharField(max_length=50) def __unicode__(self): return 'UserStatResults, results = %s' % (self.results,) class UserStat(models.Model): user = models.OneToOneField(User, primary_key=True) posts = models.IntegerField() results = models.ForeignKey(UserStatResult) def __unicode__(self): return 'UserStat, posts = %s' % (self.posts,) class StatDetails(models.Model): base_stats = models.OneToOneField(UserStat) comments = models.IntegerField() def __unicode__(self): return 'StatDetails, comments = %s' % (self.comments,) class AdvancedUserStat(UserStat): karma = models.IntegerField() class Image(models.Model): name = models.CharField(max_length=100) class Product(models.Model): name = models.CharField(max_length=100) image = models.OneToOneField(Image, null=True)
gpl-3.0
[ 504, 1639, 14, 697, 492, 1709, 421, 199, 533, 2876, 8, 992, 14, 1685, 304, 272, 3434, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 3031, 275, 1709, 14, 16577, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2473, 421, 199, 533, 19037, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 9, 272, 14492, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1174, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 2071, 83, 12, 450, 83, 2, 450, 334, 277, 14, 3690, 12, 291, 14, 929, 9, 421, 199, 533, 2876, 11232, 2889, 8, 992, 14, 1685, 304, 272, 2058, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 1899, 11232, 6579, 12, 2058, 275, 450, 83, 7, 450, 334, 277, 14, 2604, 4258, 421, 199, 533, 2876, 11232, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 12, 5062, 63, 498, 29, 549, 9, 272, 22238, 275, 1709, 14, 3901, 342, 272, 2058, 275, 1709, 14, 3190, 8, 1899, 11232, 2889, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 1899, 11232, 12, 22238, 275, 450, 83, 7, 450, 334, 277, 14, 18084, 4258, 421, 199, 533, 27673, 11347, 8, 992, 14, 1685, 304, 272, 1300, 63, 3200, 275, 1709, 14, 14298, 8, 1899, 11232, 9, 272, 6786, 275, 1709, 14, 3901, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 11232, 11347, 12, 6786, 275, 450, 83, 7, 450, 334, 277, 14, 6223, 4258, 421, 199, 533, 32445, 1899, 11232, 8, 1899, 11232, 304, 272, 1022, 14886, 275, 1709, 14, 3901, 342, 199, 199, 533, 6047, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1834, 275, 1709, 14, 14298, 8, 3491, 12, 2973, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 697, 492, 1709, 421, 199, 533, 2876, 8, 992, 14, 1685, 304, 272, 3434, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 3031, 275, 1709, 14, 16577, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 2473, 421, 199, 533, 19037, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 9, 272, 14492, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1174, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 18, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 2071, 83, 12, 450, 83, 2, 450, 334, 277, 14, 3690, 12, 291, 14, 929, 9, 421, 199, 533, 2876, 11232, 2889, 8, 992, 14, 1685, 304, 272, 2058, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 1899, 11232, 6579, 12, 2058, 275, 450, 83, 7, 450, 334, 277, 14, 2604, 4258, 421, 199, 533, 2876, 11232, 8, 992, 14, 1685, 304, 272, 922, 275, 1709, 14, 14298, 8, 1899, 12, 5062, 63, 498, 29, 549, 9, 272, 22238, 275, 1709, 14, 3901, 342, 272, 2058, 275, 1709, 14, 3190, 8, 1899, 11232, 2889, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 1899, 11232, 12, 22238, 275, 450, 83, 7, 450, 334, 277, 14, 18084, 4258, 421, 199, 533, 27673, 11347, 8, 992, 14, 1685, 304, 272, 1300, 63, 3200, 275, 1709, 14, 14298, 8, 1899, 11232, 9, 272, 6786, 275, 1709, 14, 3901, 342, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 283, 11232, 11347, 12, 6786, 275, 450, 83, 7, 450, 334, 277, 14, 6223, 4258, 421, 199, 533, 32445, 1899, 11232, 8, 1899, 11232, 304, 272, 1022, 14886, 275, 1709, 14, 3901, 342, 199, 199, 533, 6047, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 421, 199, 533, 12705, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 1834, 275, 1709, 14, 14298, 8, 3491, 12, 2973, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ool2016-seclab/quarantineSystem
ryu/tests/unit/ofproto/test_ofproto_v12.py
38
26177
# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation. # # 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. # vim: tabstop=4 shiftwidth=4 softtabstop=4 import unittest import logging from nose.tools import eq_ from ryu.ofproto.ofproto_v1_2 import * LOG = logging.getLogger('test_ofproto_v12') class TestOfprot12(unittest.TestCase): """ Test case for ofproto_v1_2 """ def test_struct_ofp_header(self): eq_(OFP_HEADER_PACK_STR, '!BBHI') eq_(OFP_HEADER_SIZE, 8) def test_enum_ofp_type(self): eq_(OFPT_HELLO, 0) eq_(OFPT_ERROR, 1) eq_(OFPT_ECHO_REQUEST, 2) eq_(OFPT_ECHO_REPLY, 3) eq_(OFPT_EXPERIMENTER, 4) eq_(OFPT_FEATURES_REQUEST, 5) eq_(OFPT_FEATURES_REPLY, 6) eq_(OFPT_GET_CONFIG_REQUEST, 7) eq_(OFPT_GET_CONFIG_REPLY, 8) eq_(OFPT_SET_CONFIG, 9) eq_(OFPT_PACKET_IN, 10) eq_(OFPT_FLOW_REMOVED, 11) eq_(OFPT_PORT_STATUS, 12) eq_(OFPT_PACKET_OUT, 13) eq_(OFPT_FLOW_MOD, 14) eq_(OFPT_GROUP_MOD, 15) eq_(OFPT_PORT_MOD, 16) eq_(OFPT_TABLE_MOD, 17) eq_(OFPT_STATS_REQUEST, 18) eq_(OFPT_STATS_REPLY, 19) eq_(OFPT_BARRIER_REQUEST, 20) eq_(OFPT_BARRIER_REPLY, 21) eq_(OFPT_QUEUE_GET_CONFIG_REQUEST, 22) eq_(OFPT_QUEUE_GET_CONFIG_REPLY, 23) eq_(OFPT_ROLE_REQUEST, 24) eq_(OFPT_ROLE_REPLY, 25) def test_struct_ofp_port(self): eq_(OFP_PORT_PACK_STR, '!I4x6s2x16sIIIIIIII') eq_(OFP_PORT_SIZE, 64) def test_enum_ofp_port_config(self): eq_(OFPPC_PORT_DOWN, 1 << 0) eq_(OFPPC_NO_RECV, 1 << 2) eq_(OFPPC_NO_FWD, 1 << 5) eq_(OFPPC_NO_PACKET_IN, 1 << 6) def test_enum_ofp_port_state(self): eq_(OFPPS_LINK_DOWN, 1 << 0) eq_(OFPPS_BLOCKED, 1 << 1) eq_(OFPPS_LIVE, 1 << 2) def test_enum_ofp_port_no(self): eq_(OFPP_MAX, 0xffffff00) eq_(OFPP_IN_PORT, 0xfffffff8) eq_(OFPP_TABLE, 0xfffffff9) eq_(OFPP_NORMAL, 0xfffffffa) eq_(OFPP_FLOOD, 0xfffffffb) eq_(OFPP_ALL, 0xfffffffc) eq_(OFPP_CONTROLLER, 0xfffffffd) eq_(OFPP_LOCAL, 0xfffffffe) eq_(OFPP_ANY, 0xffffffff) eq_(OFPQ_ALL, 0xffffffff) def test_enum_ofp_port_features(self): eq_(OFPPF_10MB_HD, 1 << 0) eq_(OFPPF_10MB_FD, 1 << 1) eq_(OFPPF_100MB_HD, 1 << 2) eq_(OFPPF_100MB_FD, 1 << 3) eq_(OFPPF_1GB_HD, 1 << 4) eq_(OFPPF_1GB_FD, 1 << 5) eq_(OFPPF_10GB_FD, 1 << 6) eq_(OFPPF_40GB_FD, 1 << 7) eq_(OFPPF_100GB_FD, 1 << 8) eq_(OFPPF_1TB_FD, 1 << 9) eq_(OFPPF_OTHER, 1 << 10) eq_(OFPPF_COPPER, 1 << 11) eq_(OFPPF_FIBER, 1 << 12) eq_(OFPPF_AUTONEG, 1 << 13) eq_(OFPPF_PAUSE, 1 << 14) eq_(OFPPF_PAUSE_ASYM, 1 << 15) def test_struct_ofp_packet_queue(self): eq_(OFP_PACKET_QUEUE_PACK_STR, '!IIH6x') eq_(OFP_PACKET_QUEUE_SIZE, 16) def test_enum_ofp_queue_properties(self): eq_(OFPQT_MIN_RATE, 1) eq_(OFPQT_MAX_RATE, 2) eq_(OFPQT_EXPERIMENTER, 0xffff) def test_struct_ofp_queue_prop_header(self): eq_(OFP_QUEUE_PROP_HEADER_PACK_STR, '!HH4x') eq_(OFP_QUEUE_PROP_HEADER_SIZE, 8) def test_struct_ofp_queue_prop_min_rate(self): eq_(OFP_QUEUE_PROP_MIN_RATE_PACK_STR, '!H6x') eq_(OFP_QUEUE_PROP_MIN_RATE_SIZE, 16) def test_struct_ofp_queue_prop_max_rate(self): eq_(OFP_QUEUE_PROP_MAX_RATE_PACK_STR, '!H6x') eq_(OFP_QUEUE_PROP_MAX_RATE_SIZE, 16) def test_struct_ofp_queue_prop_experimenter(self): eq_(OFP_QUEUE_PROP_EXPERIMENTER_PACK_STR, '!I4x') eq_(OFP_QUEUE_PROP_EXPERIMENTER_SIZE, 16) def test_struct_ofp_match(self): eq_(OFP_MATCH_PACK_STR, '!HHBBBB') eq_(OFP_MATCH_SIZE, 8) def test_enum_ofp_match_type(self): eq_(OFPMT_STANDARD, 0) eq_(OFPMT_OXM, 1) def test_enum_ofp_oxm_class(self): eq_(OFPXMC_NXM_0, 0x0000) eq_(OFPXMC_NXM_1, 0x0001) eq_(OFPXMC_OPENFLOW_BASIC, 0x8000) eq_(OFPXMC_EXPERIMENTER, 0xFFFF) def test_enmu_oxm_ofb_match_fields(self): eq_(OFPXMT_OFB_IN_PORT, 0) eq_(OFPXMT_OFB_IN_PHY_PORT, 1) eq_(OFPXMT_OFB_METADATA, 2) eq_(OFPXMT_OFB_ETH_DST, 3) eq_(OFPXMT_OFB_ETH_SRC, 4) eq_(OFPXMT_OFB_ETH_TYPE, 5) eq_(OFPXMT_OFB_VLAN_VID, 6) eq_(OFPXMT_OFB_VLAN_PCP, 7) eq_(OFPXMT_OFB_IP_DSCP, 8) eq_(OFPXMT_OFB_IP_ECN, 9) eq_(OFPXMT_OFB_IP_PROTO, 10) eq_(OFPXMT_OFB_IPV4_SRC, 11) eq_(OFPXMT_OFB_IPV4_DST, 12) eq_(OFPXMT_OFB_TCP_SRC, 13) eq_(OFPXMT_OFB_TCP_DST, 14) eq_(OFPXMT_OFB_UDP_SRC, 15) eq_(OFPXMT_OFB_UDP_DST, 16) eq_(OFPXMT_OFB_SCTP_SRC, 17) eq_(OFPXMT_OFB_SCTP_DST, 18) eq_(OFPXMT_OFB_ICMPV4_TYPE, 19) eq_(OFPXMT_OFB_ICMPV4_CODE, 20) eq_(OFPXMT_OFB_ARP_OP, 21) eq_(OFPXMT_OFB_ARP_SPA, 22) eq_(OFPXMT_OFB_ARP_TPA, 23) eq_(OFPXMT_OFB_ARP_SHA, 24) eq_(OFPXMT_OFB_ARP_THA, 25) eq_(OFPXMT_OFB_IPV6_SRC, 26) eq_(OFPXMT_OFB_IPV6_DST, 27) eq_(OFPXMT_OFB_IPV6_FLABEL, 28) eq_(OFPXMT_OFB_ICMPV6_TYPE, 29) eq_(OFPXMT_OFB_ICMPV6_CODE, 30) eq_(OFPXMT_OFB_IPV6_ND_TARGET, 31) eq_(OFPXMT_OFB_IPV6_ND_SLL, 32) eq_(OFPXMT_OFB_IPV6_ND_TLL, 33) eq_(OFPXMT_OFB_MPLS_LABEL, 34) eq_(OFPXMT_OFB_MPLS_TC, 35) def test_enum_ofp_vlan_id(self): eq_(OFPVID_PRESENT, 0x1000) eq_(OFPVID_NONE, 0x0000) def test_struct_ofp_oxm_experimenter_header(self): eq_(OFP_OXM_EXPERIMENTER_HEADER_PACK_STR, '!II') eq_(OFP_OXM_EXPERIMENTER_HEADER_SIZE, 8) def test_enum_ofp_instruction_type(self): eq_(OFPIT_GOTO_TABLE, 1) eq_(OFPIT_WRITE_METADATA, 2) eq_(OFPIT_WRITE_ACTIONS, 3) eq_(OFPIT_APPLY_ACTIONS, 4) eq_(OFPIT_CLEAR_ACTIONS, 5) eq_(OFPIT_EXPERIMENTER, 0xFFFF) def test_struct_ofp_instruction_goto_table(self): eq_(OFP_INSTRUCTION_GOTO_TABLE_PACK_STR, '!HHB3x') eq_(OFP_INSTRUCTION_GOTO_TABLE_SIZE, 8) def test_struct_ofp_instruction_write_metadata(self): eq_(OFP_INSTRUCTION_WRITE_METADATA_PACK_STR, '!HH4xQQ') eq_(OFP_INSTRUCTION_WRITE_METADATA_SIZE, 24) def test_struct_ofp_instaruction_actions(self): eq_(OFP_INSTRUCTION_ACTIONS_PACK_STR, '!HH4x') eq_(OFP_INSTRUCTION_ACTIONS_SIZE, 8) def test_enum_ofp_action_type(self): eq_(OFPAT_OUTPUT, 0) eq_(OFPAT_COPY_TTL_OUT, 11) eq_(OFPAT_COPY_TTL_IN, 12) eq_(OFPAT_SET_MPLS_TTL, 15) eq_(OFPAT_DEC_MPLS_TTL, 16) eq_(OFPAT_PUSH_VLAN, 17) eq_(OFPAT_POP_VLAN, 18) eq_(OFPAT_PUSH_MPLS, 19) eq_(OFPAT_POP_MPLS, 20) eq_(OFPAT_SET_QUEUE, 21) eq_(OFPAT_GROUP, 22) eq_(OFPAT_SET_NW_TTL, 23) eq_(OFPAT_DEC_NW_TTL, 24) eq_(OFPAT_SET_FIELD, 25) eq_(OFPAT_EXPERIMENTER, 0xffff) def test_struct_ofp_action_header(self): eq_(OFP_ACTION_HEADER_PACK_STR, '!HH4x') eq_(OFP_ACTION_HEADER_SIZE, 8) def test_struct_ofp_action_output(self): eq_(OFP_ACTION_OUTPUT_PACK_STR, '!HHIH6x') eq_(OFP_ACTION_OUTPUT_SIZE, 16) def test_enum_ofp_controller_max_len(self): eq_(OFPCML_MAX, 0xffe5) eq_(OFPCML_NO_BUFFER, 0xffff) def test_struct_ofp_action_group(self): eq_(OFP_ACTION_GROUP_PACK_STR, '!HHI') eq_(OFP_ACTION_GROUP_SIZE, 8) def test_struct_ofp_action_set_queue(self): eq_(OFP_ACTION_SET_QUEUE_PACK_STR, '!HHI') eq_(OFP_ACTION_SET_QUEUE_SIZE, 8) def test_struct_ofp_aciton_mpls_ttl(self): eq_(OFP_ACTION_MPLS_TTL_PACK_STR, '!HHB3x') eq_(OFP_ACTION_MPLS_TTL_SIZE, 8) def test_struct_ofp_action_nw_ttl(self): eq_(OFP_ACTION_NW_TTL_PACK_STR, '!HHB3x') eq_(OFP_ACTION_NW_TTL_SIZE, 8) def test_struct_ofp_action_push(self): eq_(OFP_ACTION_PUSH_PACK_STR, '!HHH2x') eq_(OFP_ACTION_PUSH_SIZE, 8) def test_struct_ofp_action_pop_mpls(self): eq_(OFP_ACTION_POP_MPLS_PACK_STR, '!HHH2x') eq_(OFP_ACTION_POP_MPLS_SIZE, 8) def test_struct_ofp_action_set_field(self): eq_(OFP_ACTION_SET_FIELD_PACK_STR, '!HH4B') eq_(OFP_ACTION_SET_FIELD_SIZE, 8) def test_struct_ofp_action_experimenter_header(self): eq_(OFP_ACTION_EXPERIMENTER_HEADER_PACK_STR, '!HHI') eq_(OFP_ACTION_EXPERIMENTER_HEADER_SIZE, 8) def test_struct_ofp_switch_feature(self): eq_(OFP_SWITCH_FEATURES_PACK_STR, '!QIB3xII') eq_(OFP_SWITCH_FEATURES_SIZE, 32) def test_enum_ofp_capabilities(self): eq_(OFPC_FLOW_STATS, 1 << 0) eq_(OFPC_TABLE_STATS, 1 << 1) eq_(OFPC_PORT_STATS, 1 << 2) eq_(OFPC_GROUP_STATS, 1 << 3) eq_(OFPC_IP_REASM, 1 << 5) eq_(OFPC_QUEUE_STATS, 1 << 6) eq_(OFPC_PORT_BLOCKED, 1 << 8) def test_struct_ofp_switch_config(self): eq_(OFP_SWITCH_CONFIG_PACK_STR, '!HH') eq_(OFP_SWITCH_CONFIG_SIZE, 12) def test_enum_ofp_config_flags(self): eq_(OFPC_FRAG_NORMAL, 0) eq_(OFPC_FRAG_DROP, 1 << 0) eq_(OFPC_FRAG_REASM, 1 << 1) eq_(OFPC_FRAG_MASK, 3) eq_(OFPC_INVALID_TTL_TO_CONTROLLER, 1 << 2) def test_enum_ofp_table(self): eq_(OFPTT_MAX, 0xfe) eq_(OFPTT_ALL, 0xff) def test_struct_ofp_table_mod(self): eq_(OFP_TABLE_MOD_PACK_STR, '!B3xI') eq_(OFP_TABLE_MOD_SIZE, 16) def test_enum_ofp_table_config(self): eq_(OFPTC_TABLE_MISS_CONTROLLER, 0) eq_(OFPTC_TABLE_MISS_CONTINUE, 1 << 0) eq_(OFPTC_TABLE_MISS_DROP, 1 << 1) eq_(OFPTC_TABLE_MISS_MASK, 3) def test_struct_ofp_flow_mod(self): eq_(OFP_FLOW_MOD_PACK_STR, '!QQBBHHHIIIH2xHHBBBB') eq_(OFP_FLOW_MOD_SIZE, 56) def test_enum_ofp_flow_mod_command(self): eq_(OFPFC_ADD, 0) eq_(OFPFC_MODIFY, 1) eq_(OFPFC_MODIFY_STRICT, 2) eq_(OFPFC_DELETE, 3) eq_(OFPFC_DELETE_STRICT, 4) def test_enum_ofp_flow_mod_flags(self): eq_(OFPFF_SEND_FLOW_REM, 1 << 0) eq_(OFPFF_CHECK_OVERLAP, 1 << 1) eq_(OFPFF_RESET_COUNTS, 1 << 2) def test_struct_ofp_group_mod(self): eq_(OFP_GROUP_MOD_PACK_STR, '!HBxI') eq_(OFP_GROUP_MOD_SIZE, 16) # same to OFPP_* def test_enum_ofp_group(self): eq_(OFPG_MAX, 0xffffff00) eq_(OFPG_ALL, 0xfffffffc) eq_(OFPG_ANY, 0xffffffff) def test_enum_ofp_group_mod_command(self): eq_(OFPGC_ADD, 0) eq_(OFPGC_MODIFY, 1) eq_(OFPGC_DELETE, 2) def test_enum_ofp_group_type(self): eq_(OFPGT_ALL, 0) eq_(OFPGT_SELECT, 1) eq_(OFPGT_INDIRECT, 2) eq_(OFPGT_FF, 3) def test_struct_ofp_bucket(self): eq_(OFP_BUCKET_PACK_STR, '!HHII4x') eq_(OFP_BUCKET_SIZE, 16) def test_struct_ofp_port_mod(self): eq_(OFP_PORT_MOD_PACK_STR, '!I4x6s2xIII4x') eq_(OFP_PORT_MOD_SIZE, 40) def test_sturct_ofp_stats_request(self): eq_(OFP_STATS_REQUEST_PACK_STR, '!HH4x') eq_(OFP_STATS_REQUEST_SIZE, 16) # OFPSF_REQ_* flags (none yet defined). # The only value defined for flags in a reply is whether more # replies will follow this one - this has the value 0x0001. def test_enum_ofp_stats_reply_flags(self): eq_(OFPSF_REPLY_MORE, 0x0001) def test_struct_ofp_stats_reply(self): eq_(OFP_STATS_REPLY_PACK_STR, '!HH4x') eq_(OFP_STATS_REPLY_SIZE, 16) def test_enum_ofp_stats_types(self): eq_(OFPST_DESC, 0) eq_(OFPST_FLOW, 1) eq_(OFPST_AGGREGATE, 2) eq_(OFPST_TABLE, 3) eq_(OFPST_PORT, 4) eq_(OFPST_QUEUE, 5) eq_(OFPST_GROUP, 6) eq_(OFPST_GROUP_DESC, 7) eq_(OFPST_GROUP_FEATURES, 8) eq_(OFPST_EXPERIMENTER, 0xffff) def test_struct_ofp_desc_stats(self): eq_(OFP_DESC_STATS_PACK_STR, '!256s256s256s32s256s') eq_(OFP_DESC_STATS_SIZE, 1056) def test_struct_ofp_flow_stats_request(self): eq_(OFP_FLOW_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') eq_(OFP_FLOW_STATS_REQUEST_SIZE, 40) def test_struct_ofp_flow_stats(self): eq_(OFP_FLOW_STATS_PACK_STR, '!HBxIIHHH6xQQQ') eq_(OFP_FLOW_STATS_SIZE, 56) def test_struct_ofp_aggregate_stats_request(self): eq_(OFP_AGGREGATE_STATS_REQUEST_PACK_STR, '!B3xII4xQQ') eq_(OFP_AGGREGATE_STATS_REQUEST_SIZE, 40) def test_struct_ofp_aggregate_stats_reply(self): eq_(OFP_AGGREGATE_STATS_REPLY_PACK_STR, '!QQI4x') eq_(OFP_AGGREGATE_STATS_REPLY_SIZE, 24) def test_sturct_ofp_table_stats(self): eq_(OFP_TABLE_STATS_PACK_STR, '!B7x32sQQIIQQQQIIIIQQ') eq_(OFP_TABLE_STATS_SIZE, 128) def test_struct_ofp_port_stats_request(self): eq_(OFP_PORT_STATS_REQUEST_PACK_STR, '!I4x') eq_(OFP_PORT_STATS_REQUEST_SIZE, 8) def test_struct_ofp_port_stats(self): eq_(OFP_PORT_STATS_PACK_STR, '!I4xQQQQQQQQQQQQ') eq_(OFP_PORT_STATS_SIZE, 104) def test_struct_ofp_queue_stats_request(self): eq_(OFP_QUEUE_STATS_REQUEST_PACK_STR, '!II') eq_(OFP_QUEUE_STATS_REQUEST_SIZE, 8) def test_struct_ofp_queue_stats(self): eq_(OFP_QUEUE_STATS_PACK_STR, '!IIQQQ') eq_(OFP_QUEUE_STATS_SIZE, 32) def test_struct_ofp_group_stats_request(self): eq_(OFP_GROUP_STATS_REQUEST_PACK_STR, '!I4x') eq_(OFP_GROUP_STATS_REQUEST_SIZE, 8) def test_struct_ofp_group_stats(self): eq_(OFP_GROUP_STATS_PACK_STR, '!H2xII4xQQ') eq_(OFP_GROUP_STATS_SIZE, 32) def test_struct_ofp_bucket_counter(self): eq_(OFP_BUCKET_COUNTER_PACK_STR, '!QQ') eq_(OFP_BUCKET_COUNTER_SIZE, 16) def test_struct_ofp_group_desc_stats(self): eq_(OFP_GROUP_DESC_STATS_PACK_STR, '!HBxI') eq_(OFP_GROUP_DESC_STATS_SIZE, 8) def test_struct_ofp_group_features_stats(self): eq_(OFP_GROUP_FEATURES_STATS_PACK_STR, '!II4I4I') eq_(OFP_GROUP_FEATURES_STATS_SIZE, 40) def test_enmu_ofp_group_capabilities(self): eq_(OFPGFC_SELECT_WEIGHT, 1 << 0) eq_(OFPGFC_SELECT_LIVENESS, 1 << 1) eq_(OFPGFC_CHAINING, 1 << 2) eq_(OFPGFC_CHAINING_CHECKS, 1 << 3) def test_struct_ofp_experimenter_stats_header(self): eq_(OFP_EXPERIMENTER_STATS_HEADER_PACK_STR, '!II') eq_(OFP_EXPERIMENTER_STATS_HEADER_SIZE, 8) def test_struct_opf_queue_get_config_request(self): eq_(OFP_QUEUE_GET_CONFIG_REQUEST_PACK_STR, '!I4x') eq_(OFP_QUEUE_GET_CONFIG_REQUEST_SIZE, 16) def test_struct_ofp_queue_get_config_reply(self): eq_(OFP_QUEUE_GET_CONFIG_REPLY_PACK_STR, '!I4x') eq_(OFP_QUEUE_GET_CONFIG_REPLY_SIZE, 16) def test_struct_ofp_packet_out(self): eq_(OFP_PACKET_OUT_PACK_STR, '!IIH6x') eq_(OFP_PACKET_OUT_SIZE, 24) def test_struct_ofp_role_request(self): eq_(OFP_ROLE_REQUEST_PACK_STR, '!I4xQ') eq_(OFP_ROLE_REQUEST_SIZE, 24) def test_enum_ofp_controller_role(self): eq_(OFPCR_ROLE_NOCHANGE, 0) eq_(OFPCR_ROLE_EQUAL, 1) eq_(OFPCR_ROLE_MASTER, 2) eq_(OFPCR_ROLE_SLAVE, 3) def test_struct_ofp_packet_in(self): eq_(OFP_PACKET_IN_PACK_STR, '!IHBB') eq_(OFP_PACKET_IN_SIZE, 24) def test_enum_ofp_packet_in_reason(self): eq_(OFPR_NO_MATCH, 0) eq_(OFPR_ACTION, 1) eq_(OFPR_INVALID_TTL, 2) def test_struct_ofp_flow_removed(self): eq_(OFP_FLOW_REMOVED_PACK_STR, '!QHBBIIHHQQHHBBBB') eq_(OFP_FLOW_REMOVED_PACK_STR0, '!QHBBIIHHQQ') eq_(OFP_FLOW_REMOVED_SIZE, 56) def test_enum_ofp_flow_removed_reason(self): eq_(OFPRR_IDLE_TIMEOUT, 0) eq_(OFPRR_HARD_TIMEOUT, 1) eq_(OFPRR_DELETE, 2) eq_(OFPRR_GROUP_DELETE, 3) def test_struct_ofp_port_status(self): eq_(OFP_PORT_STATUS_PACK_STR, '!B7xI4x6s2x16sIIIIIIII') eq_(OFP_PORT_STATUS_DESC_OFFSET, 16) eq_(OFP_PORT_STATUS_SIZE, 80) def test_enum_ofp_port_reason(self): eq_(OFPPR_ADD, 0) eq_(OFPPR_DELETE, 1) eq_(OFPPR_MODIFY, 2) def test_struct_ofp_error_msg(self): eq_(OFP_ERROR_MSG_PACK_STR, '!HH') eq_(OFP_ERROR_MSG_SIZE, 12) def test_enum_ofp_error_type(self): eq_(OFPET_HELLO_FAILED, 0) eq_(OFPET_BAD_REQUEST, 1) eq_(OFPET_BAD_ACTION, 2) eq_(OFPET_BAD_INSTRUCTION, 3) eq_(OFPET_BAD_MATCH, 4) eq_(OFPET_FLOW_MOD_FAILED, 5) eq_(OFPET_GROUP_MOD_FAILED, 6) eq_(OFPET_PORT_MOD_FAILED, 7) eq_(OFPET_TABLE_MOD_FAILED, 8) eq_(OFPET_QUEUE_OP_FAILED, 9) eq_(OFPET_SWITCH_CONFIG_FAILED, 10) eq_(OFPET_ROLE_REQUEST_FAILED, 11) eq_(OFPET_EXPERIMENTER, 0xffff) def test_enum_ofp_hello_failed_code(self): eq_(OFPHFC_INCOMPATIBLE, 0) eq_(OFPHFC_EPERM, 1) def test_enum_ofp_bad_request_code(self): eq_(OFPBRC_BAD_VERSION, 0) eq_(OFPBRC_BAD_TYPE, 1) eq_(OFPBRC_BAD_STAT, 2) eq_(OFPBRC_BAD_EXPERIMENTER, 3) eq_(OFPBRC_BAD_EXP_TYPE, 4) eq_(OFPBRC_EPERM, 5) eq_(OFPBRC_BAD_LEN, 6) eq_(OFPBRC_BUFFER_EMPTY, 7) eq_(OFPBRC_BUFFER_UNKNOWN, 8) eq_(OFPBRC_BAD_TABLE_ID, 9) eq_(OFPBRC_IS_SLAVE, 10) eq_(OFPBRC_BAD_PORT, 11) eq_(OFPBRC_BAD_PACKET, 12) def test_enum_ofp_bad_action_code(self): eq_(OFPBAC_BAD_TYPE, 0) eq_(OFPBAC_BAD_LEN, 1) eq_(OFPBAC_BAD_EXPERIMENTER, 2) eq_(OFPBAC_BAD_EXP_TYPE, 3) eq_(OFPBAC_BAD_OUT_PORT, 4) eq_(OFPBAC_BAD_ARGUMENT, 5) eq_(OFPBAC_EPERM, 6) eq_(OFPBAC_TOO_MANY, 7) eq_(OFPBAC_BAD_QUEUE, 8) eq_(OFPBAC_BAD_OUT_GROUP, 9) eq_(OFPBAC_MATCH_INCONSISTENT, 10) eq_(OFPBAC_UNSUPPORTED_ORDER, 11) eq_(OFPBAC_BAD_TAG, 12) eq_(OFPBAC_BAD_SET_TYPE, 13) eq_(OFPBAC_BAD_SET_LEN, 14) eq_(OFPBAC_BAD_SET_ARGUMENT, 15) def test_enum_ofp_bad_instruction_code(self): eq_(OFPBIC_UNKNOWN_INST, 0) eq_(OFPBIC_UNSUP_INST, 1) eq_(OFPBIC_BAD_TABLE_ID, 2) eq_(OFPBIC_UNSUP_METADATA, 3) eq_(OFPBIC_UNSUP_METADATA_MASK, 4) eq_(OFPBIC_BAD_EXPERIMENTER, 5) eq_(OFPBIC_BAD_EXP_TYPE, 6) eq_(OFPBIC_BAD_LEN, 7) eq_(OFPBIC_EPERM, 8) def test_enum_ofp_bad_match_code(self): eq_(OFPBMC_BAD_TYPE, 0) eq_(OFPBMC_BAD_LEN, 1) eq_(OFPBMC_BAD_TAG, 2) eq_(OFPBMC_BAD_DL_ADDR_MASK, 3) eq_(OFPBMC_BAD_NW_ADDR_MASK, 4) eq_(OFPBMC_BAD_WILDCARDS, 5) eq_(OFPBMC_BAD_FIELD, 6) eq_(OFPBMC_BAD_VALUE, 7) eq_(OFPBMC_BAD_MASK, 8) eq_(OFPBMC_BAD_PREREQ, 9) eq_(OFPBMC_DUP_FIELD, 10) eq_(OFPBMC_EPERM, 11) def test_enum_ofp_flow_mod_failed_code(self): eq_(OFPFMFC_UNKNOWN, 0) eq_(OFPFMFC_TABLE_FULL, 1) eq_(OFPFMFC_BAD_TABLE_ID, 2) eq_(OFPFMFC_OVERLAP, 3) eq_(OFPFMFC_EPERM, 4) eq_(OFPFMFC_BAD_TIMEOUT, 5) eq_(OFPFMFC_BAD_COMMAND, 6) eq_(OFPFMFC_BAD_FLAGS, 7) def test_enum_ofp_group_mod_failed_code(self): eq_(OFPGMFC_GROUP_EXISTS, 0) eq_(OFPGMFC_INVALID_GROUP, 1) eq_(OFPGMFC_WEIGHT_UNSUPPORTED, 2) eq_(OFPGMFC_OUT_OF_GROUPS, 3) eq_(OFPGMFC_OUT_OF_BUCKETS, 4) eq_(OFPGMFC_CHAINING_UNSUPPORTED, 5) eq_(OFPGMFC_WATCH_UNSUPPORTED, 6) eq_(OFPGMFC_LOOP, 7) eq_(OFPGMFC_UNKNOWN_GROUP, 8) eq_(OFPGMFC_CHAINED_GROUP, 9) eq_(OFPGMFC_BAD_TYPE, 10) eq_(OFPGMFC_BAD_COMMAND, 11) eq_(OFPGMFC_BAD_BUCKET, 12) eq_(OFPGMFC_BAD_WATCH, 13) eq_(OFPGMFC_EPERM, 14) def test_enum_ofp_port_mod_failed_code(self): eq_(OFPPMFC_BAD_PORT, 0) eq_(OFPPMFC_BAD_HW_ADDR, 1) eq_(OFPPMFC_BAD_CONFIG, 2) eq_(OFPPMFC_BAD_ADVERTISE, 3) eq_(OFPPMFC_EPERM, 4) def test_enum_ofp_table_mod_failed_code(self): eq_(OFPTMFC_BAD_TABLE, 0) eq_(OFPTMFC_BAD_CONFIG, 1) eq_(OFPTMFC_EPERM, 2) def test_enum_ofp_queue_op_failed_code(self): eq_(OFPQOFC_BAD_PORT, 0) eq_(OFPQOFC_BAD_QUEUE, 1) eq_(OFPQOFC_EPERM, 2) def test_enum_ofp_switch_config_failed_code(self): eq_(OFPSCFC_BAD_FLAGS, 0) eq_(OFPSCFC_BAD_LEN, 1) eq_(OFPSCFC_EPERM, 2) def test_enum_ofp_role_request_failed_code(self): eq_(OFPRRFC_STALE, 0) eq_(OFPRRFC_UNSUP, 1) eq_(OFPRRFC_BAD_ROLE, 2) def test_struct_ofp_error_experimenter_msg(self): eq_(OFP_ERROR_EXPERIMENTER_MSG_PACK_STR, '!HHI') eq_(OFP_ERROR_EXPERIMENTER_MSG_SIZE, 16) def test_struct_ofp_experimenter_header(self): eq_(OFP_EXPERIMENTER_HEADER_PACK_STR, '!II') eq_(OFP_EXPERIMENTER_HEADER_SIZE, 16) # OXM is interpreted as a 32-bit word in network byte order. # - oxm_class 17-bit to 32-bit (OFPXMC_*). # - oxm_field 10-bit to 16-bit (OFPXMT_OFB_*). # - oxm_hasmask 9-bit (Set if OXM include a bitmask). # - oxm_length 1-bit to 8-bit (Lenght of OXM payload). def _test_OXM(self, value, class_, field, hasmask, length): virfy = (class_ << 16) | (field << 9) | (hasmask << 8) | length eq_(value >> 32, 0) eq_(value, virfy) def _test_OXM_basic(self, value, field, hasmask, length): self._test_OXM(value, OFPXMC_OPENFLOW_BASIC, field, hasmask, length) def test_OXM_basic(self): self._test_OXM_basic(OXM_OF_IN_PORT, OFPXMT_OFB_IN_PORT, 0, 4) self._test_OXM_basic(OXM_OF_IN_PHY_PORT, OFPXMT_OFB_IN_PHY_PORT, 0, 4) self._test_OXM_basic(OXM_OF_METADATA, OFPXMT_OFB_METADATA, 0, 8) self._test_OXM_basic(OXM_OF_METADATA_W, OFPXMT_OFB_METADATA, 1, 16) self._test_OXM_basic(OXM_OF_ETH_DST, OFPXMT_OFB_ETH_DST, 0, 6) self._test_OXM_basic(OXM_OF_ETH_DST_W, OFPXMT_OFB_ETH_DST, 1, 12) self._test_OXM_basic(OXM_OF_ETH_SRC, OFPXMT_OFB_ETH_SRC, 0, 6) self._test_OXM_basic(OXM_OF_ETH_SRC_W, OFPXMT_OFB_ETH_SRC, 1, 12) self._test_OXM_basic(OXM_OF_ETH_TYPE, OFPXMT_OFB_ETH_TYPE, 0, 2) self._test_OXM_basic(OXM_OF_VLAN_VID, OFPXMT_OFB_VLAN_VID, 0, 2) self._test_OXM_basic(OXM_OF_VLAN_VID_W, OFPXMT_OFB_VLAN_VID, 1, 4) self._test_OXM_basic(OXM_OF_VLAN_PCP, OFPXMT_OFB_VLAN_PCP, 0, 1) self._test_OXM_basic(OXM_OF_IP_DSCP, OFPXMT_OFB_IP_DSCP, 0, 1) self._test_OXM_basic(OXM_OF_IP_ECN, OFPXMT_OFB_IP_ECN, 0, 1) self._test_OXM_basic(OXM_OF_IP_PROTO, OFPXMT_OFB_IP_PROTO, 0, 1) self._test_OXM_basic(OXM_OF_IPV4_SRC, OFPXMT_OFB_IPV4_SRC, 0, 4) self._test_OXM_basic(OXM_OF_IPV4_SRC_W, OFPXMT_OFB_IPV4_SRC, 1, 8) self._test_OXM_basic(OXM_OF_IPV4_DST, OFPXMT_OFB_IPV4_DST, 0, 4) self._test_OXM_basic(OXM_OF_IPV4_DST_W, OFPXMT_OFB_IPV4_DST, 1, 8) self._test_OXM_basic(OXM_OF_TCP_SRC, OFPXMT_OFB_TCP_SRC, 0, 2) self._test_OXM_basic(OXM_OF_TCP_DST, OFPXMT_OFB_TCP_DST, 0, 2) self._test_OXM_basic(OXM_OF_UDP_SRC, OFPXMT_OFB_UDP_SRC, 0, 2) self._test_OXM_basic(OXM_OF_UDP_DST, OFPXMT_OFB_UDP_DST, 0, 2) self._test_OXM_basic(OXM_OF_SCTP_SRC, OFPXMT_OFB_SCTP_SRC, 0, 2) self._test_OXM_basic(OXM_OF_SCTP_DST, OFPXMT_OFB_SCTP_DST, 0, 2) self._test_OXM_basic(OXM_OF_ICMPV4_TYPE, OFPXMT_OFB_ICMPV4_TYPE, 0, 1) self._test_OXM_basic(OXM_OF_ICMPV4_CODE, OFPXMT_OFB_ICMPV4_CODE, 0, 1) self._test_OXM_basic(OXM_OF_ARP_OP, OFPXMT_OFB_ARP_OP, 0, 2) self._test_OXM_basic(OXM_OF_ARP_SPA, OFPXMT_OFB_ARP_SPA, 0, 4) self._test_OXM_basic(OXM_OF_ARP_SPA_W, OFPXMT_OFB_ARP_SPA, 1, 8) self._test_OXM_basic(OXM_OF_ARP_TPA, OFPXMT_OFB_ARP_TPA, 0, 4) self._test_OXM_basic(OXM_OF_ARP_TPA_W, OFPXMT_OFB_ARP_TPA, 1, 8) self._test_OXM_basic(OXM_OF_ARP_SHA, OFPXMT_OFB_ARP_SHA, 0, 6) self._test_OXM_basic(OXM_OF_ARP_SHA_W, OFPXMT_OFB_ARP_SHA, 1, 12) self._test_OXM_basic(OXM_OF_ARP_THA, OFPXMT_OFB_ARP_THA, 0, 6) self._test_OXM_basic(OXM_OF_ARP_THA_W, OFPXMT_OFB_ARP_THA, 1, 12) self._test_OXM_basic(OXM_OF_IPV6_SRC, OFPXMT_OFB_IPV6_SRC, 0, 16) self._test_OXM_basic(OXM_OF_IPV6_SRC_W, OFPXMT_OFB_IPV6_SRC, 1, 32) self._test_OXM_basic(OXM_OF_IPV6_DST, OFPXMT_OFB_IPV6_DST, 0, 16) self._test_OXM_basic(OXM_OF_IPV6_DST_W, OFPXMT_OFB_IPV6_DST, 1, 32) self._test_OXM_basic(OXM_OF_IPV6_FLABEL, OFPXMT_OFB_IPV6_FLABEL, 0, 4) self._test_OXM_basic(OXM_OF_IPV6_FLABEL_W, OFPXMT_OFB_IPV6_FLABEL, 1, 8) self._test_OXM_basic(OXM_OF_ICMPV6_TYPE, OFPXMT_OFB_ICMPV6_TYPE, 0, 1) self._test_OXM_basic(OXM_OF_ICMPV6_CODE, OFPXMT_OFB_ICMPV6_CODE, 0, 1) self._test_OXM_basic(OXM_OF_IPV6_ND_TARGET, OFPXMT_OFB_IPV6_ND_TARGET, 0, 16) self._test_OXM_basic(OXM_OF_IPV6_ND_SLL, OFPXMT_OFB_IPV6_ND_SLL, 0, 6) self._test_OXM_basic(OXM_OF_IPV6_ND_TLL, OFPXMT_OFB_IPV6_ND_TLL, 0, 6) self._test_OXM_basic(OXM_OF_MPLS_LABEL, OFPXMT_OFB_MPLS_LABEL, 0, 4) self._test_OXM_basic(OXM_OF_MPLS_TC, OFPXMT_OFB_MPLS_TC, 0, 1) def test_define_constants(self): eq_(OFP_VERSION, 0x03) eq_(OFP_TCP_PORT, 6633) eq_(MAX_XID, 0xffffffff)
mit
[ 3, 1898, 334, 35, 9, 6029, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 646, 2882, 199, 646, 2050, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 504, 25494, 14, 15129, 14, 15129, 63, 86, 17, 63, 18, 492, 627, 421, 199, 4947, 275, 2050, 14, 5572, 360, 396, 63, 15129, 63, 86, 713, 358, 421, 199, 533, 1379, 3466, 2745, 713, 8, 2796, 14, 1746, 304, 272, 408, 1379, 1930, 367, 14122, 63, 86, 17, 63, 18, 272, 408, 339, 347, 511, 63, 1820, 63, 20943, 63, 1291, 8, 277, 304, 267, 3850, 2531, 6733, 63, 7311, 63, 6961, 63, 3027, 12, 14597, 5342, 11183, 358, 267, 3850, 2531, 6733, 63, 7311, 63, 4305, 12, 1695, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 466, 8, 277, 304, 267, 3850, 2531, 27812, 63, 24771, 1484, 12, 378, 9, 267, 3850, 2531, 27812, 63, 3170, 12, 413, 9, 267, 3850, 2531, 27812, 63, 37, 10465, 63, 6780, 12, 499, 9, 267, 3850, 2531, 27812, 63, 37, 10465, 63, 21130, 12, 650, 9, 267, 3850, 2531, 27812, 63, 28722, 12533, 12, 841, 9, 267, 3850, 2531, 27812, 63, 13313, 63, 6780, 12, 959, 9, 267, 3850, 2531, 27812, 63, 13313, 63, 21130, 12, 1227, 9, 267, 3850, 2531, 27812, 63, 2970, 63, 5569, 63, 6780, 12, 1520, 9, 267, 3850, 2531, 27812, 63, 2970, 63, 5569, 63, 21130, 12, 1695, 9, 267, 3850, 2531, 27812, 63, 3597, 63, 5569, 12, 1749, 9, 267, 3850, 2531, 27812, 63, 18058, 63, 568, 12, 1616, 9, 267, 3850, 2531, 27812, 63, 17114, 63, 907, 2679, 14112, 12, 4119, 9, 267, 3850, 2531, 27812, 63, 3657, 63, 6305, 12, 3144, 9, 267, 3850, 2531, 27812, 63, 18058, 63, 1877, 12, 4944, 9, 267, 3850, 2531, 27812, 63, 17114, 63, 8816, 12, 4329, 9, 267, 3850, 2531, 27812, 63, 7823, 63, 8816, 12, 4114, 9, 267, 3850, 2531, 27812, 63, 3657, 63, 8816, 12, 3193, 9, 267, 3850, 2531, 27812, 63, 8723, 63, 8816, 12, 5557, 9, 267, 3850, 2531, 27812, 63, 19202, 63, 6780, 12, 6155, 9, 267, 3850, 2531, 27812, 63, 19202, 63, 21130, 12, 5851, 9, 267, 3850, 2531, 27812, 63, 34, 27052, 540, 63, 6780, 12, 3388, 9, 267, 3850, 2531, 27812, 63, 34, 27052, 540, 63, 21130, 12, 7829, 9, 267, 3850, 2531, 27812, 63, 15125, 63, 2970, 63, 5569, 63, 6780, 12, 6928, 9, 267, 3850, 2531, 27812, 63, 15125, 63, 2970, 63, 5569, 63, 21130, 12, 6546, 9, 267, 3850, 2531, 27812, 63, 15468, 63, 6780, 12, 5504, 9, 267, 3850, 2531, 27812, 63, 15468, 63, 21130, 12, 5661, 9, 339, 347, 511, 63, 1820, 63, 20943, 63, 719, 8, 277, 304, 267, 3850, 2531, 6733, 63, 3657, 63, 6961, 63, 3027, 12, 14597, 41, 20, 88, 22, 83, 18, 88, 975, 83, 8921, 8921, 8921, 8921, 358, 267, 3850, 2531, 6733, 63, 3657, 63, 4305, 12, 5049, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 888, 8, 277, 304, 267, 3850, 2531, 6733, 4222, 63, 3657, 63, 8819, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 9481, 54, 12, 413, 5213, 499, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 38, 16698, 12, 413, 5213, 959, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 18058, 63, 568, 12, 413, 5213, 1227, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 929, 8, 277, 304, 267, 3850, 2531, 6733, 5067, 63, 7916, 63, 8819, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 5067, 63, 8475, 1149, 12, 413, 5213, 413, 9, 267, 3850, 2531, 6733, 5067, 63, 31541, 12, 413, 5213, 499, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 889, 8, 277, 304, 267, 3850, 2531, 6733, 48, 63, 4283, 12, 378, 3581, 4717, 383, 9, 267, 3850, 2531, 6733, 48, 63, 568, 63, 3657, 12, 378, 3581, 4717, 70, 24, 9, 267, 3850, 2531, 6733, 48, 63, 8723, 12, 378, 3581, 4717, 70, 25, 9, 267, 3850, 2531, 6733, 48, 63, 10765, 12, 378, 3581, 4717, 667, 9, 267, 3850, 2531, 6733, 48, 63, 38, 1484, 22041, 12, 378, 3581, 4717, 4675, 9, 267, 3850, 2531, 6733, 48, 63, 1761, 12, 378, 3581, 4717, 3003, 9, 267, 3850, 2531, 6733, 48, 63, 5801, 14881, 540, 12, 378, 3581, 4717, 2592, 9, 267, 3850, 2531, 6733, 48, 63, 7486, 12, 378, 3581, 4717, 771, 9, 267, 3850, 2531, 6733, 48, 63, 8974, 12, 378, 21870, 9, 267, 3850, 2531, 6733, 49, 63, 1761, 12, 378, 21870, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 3179, 8, 277, 304, 267, 3850, 2531, 6733, 10966, 63, 709, 4567, 63, 14903, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 10966, 63, 709, 4567, 63, 7902, 12, 413, 5213, 413, 9, 267, 3850, 2531, 6733, 10966, 63, 1960, 4567, 63, 14903, 12, 413, 5213, 499, 9, 267, 3850, 2531, 6733, 10966, 63, 1960, 4567, 63, 7902, 12, 413, 5213, 650, 9, 267, 3850, 2531, 6733, 10966, 63, 17, 6487, 63, 14903, 12, 413, 5213, 841, 9, 267, 3850, 2531, 6733, 10966, 63, 17, 6487, 63, 7902, 12, 413, 5213, 959, 9, 267, 3850, 2531, 6733, 10966, 63, 709, 6487, 63, 7902, 12, 413 ]
[ 1898, 334, 35, 9, 6029, 653, 711, 678, 23884, 2180, 436, 23884, 9339, 11098, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 646, 2882, 199, 646, 2050, 199, 504, 11354, 14, 2537, 492, 3850, 63, 199, 504, 25494, 14, 15129, 14, 15129, 63, 86, 17, 63, 18, 492, 627, 421, 199, 4947, 275, 2050, 14, 5572, 360, 396, 63, 15129, 63, 86, 713, 358, 421, 199, 533, 1379, 3466, 2745, 713, 8, 2796, 14, 1746, 304, 272, 408, 1379, 1930, 367, 14122, 63, 86, 17, 63, 18, 272, 408, 339, 347, 511, 63, 1820, 63, 20943, 63, 1291, 8, 277, 304, 267, 3850, 2531, 6733, 63, 7311, 63, 6961, 63, 3027, 12, 14597, 5342, 11183, 358, 267, 3850, 2531, 6733, 63, 7311, 63, 4305, 12, 1695, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 466, 8, 277, 304, 267, 3850, 2531, 27812, 63, 24771, 1484, 12, 378, 9, 267, 3850, 2531, 27812, 63, 3170, 12, 413, 9, 267, 3850, 2531, 27812, 63, 37, 10465, 63, 6780, 12, 499, 9, 267, 3850, 2531, 27812, 63, 37, 10465, 63, 21130, 12, 650, 9, 267, 3850, 2531, 27812, 63, 28722, 12533, 12, 841, 9, 267, 3850, 2531, 27812, 63, 13313, 63, 6780, 12, 959, 9, 267, 3850, 2531, 27812, 63, 13313, 63, 21130, 12, 1227, 9, 267, 3850, 2531, 27812, 63, 2970, 63, 5569, 63, 6780, 12, 1520, 9, 267, 3850, 2531, 27812, 63, 2970, 63, 5569, 63, 21130, 12, 1695, 9, 267, 3850, 2531, 27812, 63, 3597, 63, 5569, 12, 1749, 9, 267, 3850, 2531, 27812, 63, 18058, 63, 568, 12, 1616, 9, 267, 3850, 2531, 27812, 63, 17114, 63, 907, 2679, 14112, 12, 4119, 9, 267, 3850, 2531, 27812, 63, 3657, 63, 6305, 12, 3144, 9, 267, 3850, 2531, 27812, 63, 18058, 63, 1877, 12, 4944, 9, 267, 3850, 2531, 27812, 63, 17114, 63, 8816, 12, 4329, 9, 267, 3850, 2531, 27812, 63, 7823, 63, 8816, 12, 4114, 9, 267, 3850, 2531, 27812, 63, 3657, 63, 8816, 12, 3193, 9, 267, 3850, 2531, 27812, 63, 8723, 63, 8816, 12, 5557, 9, 267, 3850, 2531, 27812, 63, 19202, 63, 6780, 12, 6155, 9, 267, 3850, 2531, 27812, 63, 19202, 63, 21130, 12, 5851, 9, 267, 3850, 2531, 27812, 63, 34, 27052, 540, 63, 6780, 12, 3388, 9, 267, 3850, 2531, 27812, 63, 34, 27052, 540, 63, 21130, 12, 7829, 9, 267, 3850, 2531, 27812, 63, 15125, 63, 2970, 63, 5569, 63, 6780, 12, 6928, 9, 267, 3850, 2531, 27812, 63, 15125, 63, 2970, 63, 5569, 63, 21130, 12, 6546, 9, 267, 3850, 2531, 27812, 63, 15468, 63, 6780, 12, 5504, 9, 267, 3850, 2531, 27812, 63, 15468, 63, 21130, 12, 5661, 9, 339, 347, 511, 63, 1820, 63, 20943, 63, 719, 8, 277, 304, 267, 3850, 2531, 6733, 63, 3657, 63, 6961, 63, 3027, 12, 14597, 41, 20, 88, 22, 83, 18, 88, 975, 83, 8921, 8921, 8921, 8921, 358, 267, 3850, 2531, 6733, 63, 3657, 63, 4305, 12, 5049, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 888, 8, 277, 304, 267, 3850, 2531, 6733, 4222, 63, 3657, 63, 8819, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 9481, 54, 12, 413, 5213, 499, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 38, 16698, 12, 413, 5213, 959, 9, 267, 3850, 2531, 6733, 4222, 63, 2826, 63, 18058, 63, 568, 12, 413, 5213, 1227, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 929, 8, 277, 304, 267, 3850, 2531, 6733, 5067, 63, 7916, 63, 8819, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 5067, 63, 8475, 1149, 12, 413, 5213, 413, 9, 267, 3850, 2531, 6733, 5067, 63, 31541, 12, 413, 5213, 499, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 889, 8, 277, 304, 267, 3850, 2531, 6733, 48, 63, 4283, 12, 378, 3581, 4717, 383, 9, 267, 3850, 2531, 6733, 48, 63, 568, 63, 3657, 12, 378, 3581, 4717, 70, 24, 9, 267, 3850, 2531, 6733, 48, 63, 8723, 12, 378, 3581, 4717, 70, 25, 9, 267, 3850, 2531, 6733, 48, 63, 10765, 12, 378, 3581, 4717, 667, 9, 267, 3850, 2531, 6733, 48, 63, 38, 1484, 22041, 12, 378, 3581, 4717, 4675, 9, 267, 3850, 2531, 6733, 48, 63, 1761, 12, 378, 3581, 4717, 3003, 9, 267, 3850, 2531, 6733, 48, 63, 5801, 14881, 540, 12, 378, 3581, 4717, 2592, 9, 267, 3850, 2531, 6733, 48, 63, 7486, 12, 378, 3581, 4717, 771, 9, 267, 3850, 2531, 6733, 48, 63, 8974, 12, 378, 21870, 9, 267, 3850, 2531, 6733, 49, 63, 1761, 12, 378, 21870, 9, 339, 347, 511, 63, 4869, 63, 20943, 63, 719, 63, 3179, 8, 277, 304, 267, 3850, 2531, 6733, 10966, 63, 709, 4567, 63, 14903, 12, 413, 5213, 378, 9, 267, 3850, 2531, 6733, 10966, 63, 709, 4567, 63, 7902, 12, 413, 5213, 413, 9, 267, 3850, 2531, 6733, 10966, 63, 1960, 4567, 63, 14903, 12, 413, 5213, 499, 9, 267, 3850, 2531, 6733, 10966, 63, 1960, 4567, 63, 7902, 12, 413, 5213, 650, 9, 267, 3850, 2531, 6733, 10966, 63, 17,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
yograterol/django
django/conf/locale/ru/formats.py
1059
1267
# -*- encoding: utf-8 -*- # This file is distributed under the same license as the Django package. # from __future__ import unicode_literals # The *_FORMAT strings use the Django date format syntax, # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'j E Y г.' TIME_FORMAT = 'G:i' DATETIME_FORMAT = 'j E Y г. G:i' YEAR_MONTH_FORMAT = 'F Y г.' MONTH_DAY_FORMAT = 'j F' SHORT_DATE_FORMAT = 'd.m.Y' SHORT_DATETIME_FORMAT = 'd.m.Y H:i' FIRST_DAY_OF_WEEK = 1 # Monday # The *_INPUT_FORMATS strings use the Python strftime format syntax, # see http://docs.python.org/library/datetime.html#strftime-strptime-behavior DATE_INPUT_FORMATS = [ '%d.%m.%Y', # '25.10.2006' '%d.%m.%y', # '25.10.06' ] DATETIME_INPUT_FORMATS = [ '%d.%m.%Y %H:%M:%S', # '25.10.2006 14:30:59' '%d.%m.%Y %H:%M:%S.%f', # '25.10.2006 14:30:59.000200' '%d.%m.%Y %H:%M', # '25.10.2006 14:30' '%d.%m.%Y', # '25.10.2006' '%d.%m.%y %H:%M:%S', # '25.10.06 14:30:59' '%d.%m.%y %H:%M:%S.%f', # '25.10.06 14:30:59.000200' '%d.%m.%y %H:%M', # '25.10.06 14:30' '%d.%m.%y', # '25.10.06' ] DECIMAL_SEPARATOR = ',' THOUSAND_SEPARATOR = '\xa0' # non-breaking space NUMBER_GROUPING = 3
bsd-3-clause
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 3530, 199, 4961, 63, 4807, 275, 283, 39, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 14, 598, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7038, 112, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1854, 1334, 314, 2011, 4190, 465, 314, 5634, 2559, 14, 199, 3, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 3, 710, 20841, 4807, 3326, 675, 314, 5634, 1434, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 5876, 15, 10372, 12645, 602, 199, 5390, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 3530, 199, 4961, 63, 4807, 275, 283, 39, 26, 73, 7, 199, 12488, 63, 4807, 275, 283, 74, 662, 1488, 7038, 112, 14, 598, 26, 73, 7, 199, 19216, 63, 16413, 63, 4807, 275, 283, 38, 1488, 7038, 112, 3530, 199, 16413, 63, 11655, 63, 4807, 275, 283, 74, 481, 7, 199, 13003, 63, 5390, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 7, 199, 13003, 63, 12488, 63, 4807, 275, 283, 68, 14, 77, 14, 57, 869, 26, 73, 7, 199, 12903, 63, 11655, 63, 3359, 63, 24929, 275, 413, 221, 327, 32740, 199, 199, 3, 710, 20841, 7321, 63, 14019, 3326, 675, 314, 2018, 14053, 1475, 6302, 12, 199, 3, 1937, 1455, 921, 4757, 14, 1548, 14, 1308, 15, 4342, 15, 2083, 14, 1360, 3, 6205, 13, 9866, 13, 17537, 199, 5390, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 12488, 63, 7321, 63, 14019, 275, 359, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 57, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 7968, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 57, 297, 4519, 327, 283, 821, 14, 709, 14, 7968, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 297, 258, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 2689, 51, 4111, 70, 297, 221, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 26, 1427, 14, 25080, 7, 272, 1543, 68, 4111, 77, 4111, 89, 450, 40, 2689, 45, 297, 263, 327, 283, 821, 14, 709, 14, 1690, 4329, 26, 1216, 7, 272, 1543, 68, 4111, 77, 4111, 89, 297, 4519, 327, 283, 821, 14, 709, 14, 1690, 7, 199, 61, 199, 23925, 63, 15828, 275, 13647, 199, 28714, 63, 15828, 275, 1557, 1800, 16, 7, 221, 327, 2222, 13, 4785, 316, 4601, 199, 9190, 63, 7823, 1206, 275, 650, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
robertmattmueller/sdac-compiler
sympy/physics/quantum/tests/test_spin.py
33
320428
from __future__ import division from sympy import cos, exp, expand, I, Matrix, pi, S, sin, sqrt, Sum, symbols from sympy.abc import alpha, beta, gamma, j, m from sympy.physics.quantum import hbar, represent, Commutator, InnerProduct from sympy.physics.quantum.qapply import qapply from sympy.physics.quantum.tensorproduct import TensorProduct from sympy.physics.quantum.cg import CG from sympy.physics.quantum.spin import ( Jx, Jy, Jz, Jplus, Jminus, J2, JxBra, JyBra, JzBra, JxKet, JyKet, JzKet, JxKetCoupled, JyKetCoupled, JzKetCoupled, couple, uncouple, Rotation, WignerD ) from sympy.utilities.pytest import raises j1, j2, j3, j4, m1, m2, m3, m4 = symbols('j1:5 m1:5') j12, j13, j24, j34, j123, j134, mi, mi1, mp = symbols( 'j12 j13 j24 j34 j123 j134 mi mi1 mp') def test_represent_spin_operators(): assert represent(Jx) == hbar*Matrix([[0, 1], [1, 0]])/2 assert represent( Jx, j=1) == hbar*sqrt(2)*Matrix([[0, 1, 0], [1, 0, 1], [0, 1, 0]])/2 assert represent(Jy) == hbar*I*Matrix([[0, -1], [1, 0]])/2 assert represent(Jy, j=1) == hbar*I*sqrt(2)*Matrix([[0, -1, 0], [1, 0, -1], [0, 1, 0]])/2 assert represent(Jz) == hbar*Matrix([[1, 0], [0, -1]])/2 assert represent( Jz, j=1) == hbar*Matrix([[1, 0, 0], [0, 0, 0], [0, 0, -1]]) def test_represent_spin_states(): # Jx basis assert represent(JxKet(S(1)/2, S(1)/2), basis=Jx) == Matrix([1, 0]) assert represent(JxKet(S(1)/2, -S(1)/2), basis=Jx) == Matrix([0, 1]) assert represent(JxKet(1, 1), basis=Jx) == Matrix([1, 0, 0]) assert represent(JxKet(1, 0), basis=Jx) == Matrix([0, 1, 0]) assert represent(JxKet(1, -1), basis=Jx) == Matrix([0, 0, 1]) assert represent( JyKet(S(1)/2, S(1)/2), basis=Jx) == Matrix([exp(-I*pi/4), 0]) assert represent( JyKet(S(1)/2, -S(1)/2), basis=Jx) == Matrix([0, exp(I*pi/4)]) assert represent(JyKet(1, 1), basis=Jx) == Matrix([-I, 0, 0]) assert represent(JyKet(1, 0), basis=Jx) == Matrix([0, 1, 0]) assert represent(JyKet(1, -1), basis=Jx) == Matrix([0, 0, I]) assert represent( JzKet(S(1)/2, S(1)/2), basis=Jx) == sqrt(2)*Matrix([-1, 1])/2 assert represent( JzKet(S(1)/2, -S(1)/2), basis=Jx) == sqrt(2)*Matrix([-1, -1])/2 assert represent(JzKet(1, 1), basis=Jx) == Matrix([1, -sqrt(2), 1])/2 assert represent(JzKet(1, 0), basis=Jx) == sqrt(2)*Matrix([1, 0, -1])/2 assert represent(JzKet(1, -1), basis=Jx) == Matrix([1, sqrt(2), 1])/2 # Jy basis assert represent( JxKet(S(1)/2, S(1)/2), basis=Jy) == Matrix([exp(-3*I*pi/4), 0]) assert represent( JxKet(S(1)/2, -S(1)/2), basis=Jy) == Matrix([0, exp(3*I*pi/4)]) assert represent(JxKet(1, 1), basis=Jy) == Matrix([I, 0, 0]) assert represent(JxKet(1, 0), basis=Jy) == Matrix([0, 1, 0]) assert represent(JxKet(1, -1), basis=Jy) == Matrix([0, 0, -I]) assert represent(JyKet(S(1)/2, S(1)/2), basis=Jy) == Matrix([1, 0]) assert represent(JyKet(S(1)/2, -S(1)/2), basis=Jy) == Matrix([0, 1]) assert represent(JyKet(1, 1), basis=Jy) == Matrix([1, 0, 0]) assert represent(JyKet(1, 0), basis=Jy) == Matrix([0, 1, 0]) assert represent(JyKet(1, -1), basis=Jy) == Matrix([0, 0, 1]) assert represent( JzKet(S(1)/2, S(1)/2), basis=Jy) == sqrt(2)*Matrix([-1, I])/2 assert represent( JzKet(S(1)/2, -S(1)/2), basis=Jy) == sqrt(2)*Matrix([I, -1])/2 assert represent(JzKet(1, 1), basis=Jy) == Matrix([1, -I*sqrt(2), -1])/2 assert represent( JzKet(1, 0), basis=Jy) == Matrix([-sqrt(2)*I, 0, -sqrt(2)*I])/2 assert represent(JzKet(1, -1), basis=Jy) == Matrix([-1, -sqrt(2)*I, 1])/2 # Jz basis assert represent( JxKet(S(1)/2, S(1)/2), basis=Jz) == sqrt(2)*Matrix([1, 1])/2 assert represent( JxKet(S(1)/2, -S(1)/2), basis=Jz) == sqrt(2)*Matrix([-1, 1])/2 assert represent(JxKet(1, 1), basis=Jz) == Matrix([1, sqrt(2), 1])/2 assert represent(JxKet(1, 0), basis=Jz) == sqrt(2)*Matrix([-1, 0, 1])/2 assert represent(JxKet(1, -1), basis=Jz) == Matrix([1, -sqrt(2), 1])/2 assert represent( JyKet(S(1)/2, S(1)/2), basis=Jz) == sqrt(2)*Matrix([-1, -I])/2 assert represent( JyKet(S(1)/2, -S(1)/2), basis=Jz) == sqrt(2)*Matrix([-I, -1])/2 assert represent(JyKet(1, 1), basis=Jz) == Matrix([1, sqrt(2)*I, -1])/2 assert represent(JyKet(1, 0), basis=Jz) == sqrt(2)*Matrix([I, 0, I])/2 assert represent(JyKet(1, -1), basis=Jz) == Matrix([-1, sqrt(2)*I, 1])/2 assert represent(JzKet(S(1)/2, S(1)/2), basis=Jz) == Matrix([1, 0]) assert represent(JzKet(S(1)/2, -S(1)/2), basis=Jz) == Matrix([0, 1]) assert represent(JzKet(1, 1), basis=Jz) == Matrix([1, 0, 0]) assert represent(JzKet(1, 0), basis=Jz) == Matrix([0, 1, 0]) assert represent(JzKet(1, -1), basis=Jz) == Matrix([0, 0, 1]) def test_represent_uncoupled_states(): # Jx basis assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([1, 0, 0, 0]) assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([0, 1, 0, 0]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 1, 0]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([0, 0, 0, 1]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([-I, 0, 0, 0]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([0, 1, 0, 0]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 1, 0]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([0, 0, 0, I]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([S(1)/2, -S(1)/2, -S(1)/2, S(1)/2]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([S(1)/2, S(1)/2, -S(1)/2, -S(1)/2]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([S(1)/2, -S(1)/2, S(1)/2, -S(1)/2]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jx) == \ Matrix([S(1)/2, S(1)/2, S(1)/2, S(1)/2]) # Jy basis assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([I, 0, 0, 0]) assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([0, 1, 0, 0]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 1, 0]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([0, 0, 0, -I]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([1, 0, 0, 0]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([0, 1, 0, 0]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 1, 0]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([0, 0, 0, 1]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([S(1)/2, -I/2, -I/2, -S(1)/2]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([-I/2, S(1)/2, -S(1)/2, -I/2]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([-I/2, -S(1)/2, S(1)/2, -I/2]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jy) == \ Matrix([-S(1)/2, -I/2, -I/2, S(1)/2]) # Jz basis assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([S(1)/2, S(1)/2, S(1)/2, S(1)/2]) assert represent(TensorProduct(JxKet(S(1)/2, S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([-S(1)/2, S(1)/2, -S(1)/2, S(1)/2]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([-S(1)/2, -S(1)/2, S(1)/2, S(1)/2]) assert represent(TensorProduct(JxKet(S(1)/2, -S(1)/2), JxKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([S(1)/2, -S(1)/2, -S(1)/2, S(1)/2]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([S(1)/2, I/2, I/2, -S(1)/2]) assert represent(TensorProduct(JyKet(S(1)/2, S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([I/2, S(1)/2, -S(1)/2, I/2]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([I/2, -S(1)/2, S(1)/2, I/2]) assert represent(TensorProduct(JyKet(S(1)/2, -S(1)/2), JyKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([-S(1)/2, I/2, I/2, S(1)/2]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([1, 0, 0, 0]) assert represent(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([0, 1, 0, 0]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, 0, 1, 0]) assert represent(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)), basis=Jz) == \ Matrix([0, 0, 0, 1]) def test_represent_coupled_states(): # Jx basis assert represent(JxKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([1, 0, 0, 0]) assert represent(JxKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 1, 0, 0]) assert represent(JxKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 1, 0]) assert represent(JxKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 0, 1]) assert represent(JyKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([1, 0, 0, 0]) assert represent(JyKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, -I, 0, 0]) assert represent(JyKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 1, 0]) assert represent(JyKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, 0, 0, I]) assert represent(JzKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([1, 0, 0, 0]) assert represent(JzKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, S(1)/2, -sqrt(2)/2, S(1)/2]) assert represent(JzKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, sqrt(2)/2, 0, -sqrt(2)/2]) assert represent(JzKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jx) == \ Matrix([0, S(1)/2, sqrt(2)/2, S(1)/2]) # Jy basis assert represent(JxKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([1, 0, 0, 0]) assert represent(JxKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, I, 0, 0]) assert represent(JxKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 1, 0]) assert represent(JxKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 0, -I]) assert represent(JyKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([1, 0, 0, 0]) assert represent(JyKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 1, 0, 0]) assert represent(JyKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 1, 0]) assert represent(JyKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, 0, 0, 1]) assert represent(JzKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([1, 0, 0, 0]) assert represent(JzKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, S(1)/2, -I*sqrt(2)/2, -S(1)/2]) assert represent(JzKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, -I*sqrt(2)/2, 0, -I*sqrt(2)/2]) assert represent(JzKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jy) == \ Matrix([0, -S(1)/2, -I*sqrt(2)/2, S(1)/2]) # Jz basis assert represent(JxKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([1, 0, 0, 0]) assert represent(JxKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, S(1)/2, sqrt(2)/2, S(1)/2]) assert represent(JxKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, -sqrt(2)/2, 0, sqrt(2)/2]) assert represent(JxKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, S(1)/2, -sqrt(2)/2, S(1)/2]) assert represent(JyKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([1, 0, 0, 0]) assert represent(JyKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, S(1)/2, I*sqrt(2)/2, -S(1)/2]) assert represent(JyKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, I*sqrt(2)/2, 0, I*sqrt(2)/2]) assert represent(JyKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, -S(1)/2, I*sqrt(2)/2, S(1)/2]) assert represent(JzKetCoupled(0, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([1, 0, 0, 0]) assert represent(JzKetCoupled(1, 1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, 1, 0, 0]) assert represent(JzKetCoupled(1, 0, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, 0, 1, 0]) assert represent(JzKetCoupled(1, -1, (S(1)/2, S(1)/2)), basis=Jz) == \ Matrix([0, 0, 0, 1]) def test_represent_rotation(): assert represent(Rotation(0, pi/2, 0)) == \ Matrix( [[WignerD( S( 1)/2, S( 1)/2, S( 1)/2, 0, pi/2, 0), WignerD( S(1)/2, S(1)/2, -S(1)/2, 0, pi/2, 0)], [WignerD(S(1)/2, -S(1)/2, S(1)/2, 0, pi/2, 0), WignerD(S(1)/2, -S(1)/2, -S(1)/2, 0, pi/2, 0)]]) assert represent(Rotation(0, pi/2, 0), doit=True) == \ Matrix([[sqrt(2)/2, -sqrt(2)/2], [sqrt(2)/2, sqrt(2)/2]]) def test_rewrite_same(): # Rewrite to same basis assert JxBra(1, 1).rewrite('Jx') == JxBra(1, 1) assert JxBra(j, m).rewrite('Jx') == JxBra(j, m) assert JxKet(1, 1).rewrite('Jx') == JxKet(1, 1) assert JxKet(j, m).rewrite('Jx') == JxKet(j, m) def test_rewrite_Bra(): # Numerical assert JxBra(1, 1).rewrite('Jy') == -I*JyBra(1, 1) assert JxBra(1, 0).rewrite('Jy') == JyBra(1, 0) assert JxBra(1, -1).rewrite('Jy') == I*JyBra(1, -1) assert JxBra(1, 1).rewrite( 'Jz') == JzBra(1, 1)/2 + JzBra(1, 0)/sqrt(2) + JzBra(1, -1)/2 assert JxBra( 1, 0).rewrite('Jz') == -sqrt(2)*JzBra(1, 1)/2 + sqrt(2)*JzBra(1, -1)/2 assert JxBra(1, -1).rewrite( 'Jz') == JzBra(1, 1)/2 - JzBra(1, 0)/sqrt(2) + JzBra(1, -1)/2 assert JyBra(1, 1).rewrite('Jx') == I*JxBra(1, 1) assert JyBra(1, 0).rewrite('Jx') == JxBra(1, 0) assert JyBra(1, -1).rewrite('Jx') == -I*JxBra(1, -1) assert JyBra(1, 1).rewrite( 'Jz') == JzBra(1, 1)/2 - sqrt(2)*I*JzBra(1, 0)/2 - JzBra(1, -1)/2 assert JyBra(1, 0).rewrite( 'Jz') == -sqrt(2)*I*JzBra(1, 1)/2 - sqrt(2)*I*JzBra(1, -1)/2 assert JyBra(1, -1).rewrite( 'Jz') == -JzBra(1, 1)/2 - sqrt(2)*I*JzBra(1, 0)/2 + JzBra(1, -1)/2 assert JzBra(1, 1).rewrite( 'Jx') == JxBra(1, 1)/2 - sqrt(2)*JxBra(1, 0)/2 + JxBra(1, -1)/2 assert JzBra( 1, 0).rewrite('Jx') == sqrt(2)*JxBra(1, 1)/2 - sqrt(2)*JxBra(1, -1)/2 assert JzBra(1, -1).rewrite( 'Jx') == JxBra(1, 1)/2 + sqrt(2)*JxBra(1, 0)/2 + JxBra(1, -1)/2 assert JzBra(1, 1).rewrite( 'Jy') == JyBra(1, 1)/2 + sqrt(2)*I*JyBra(1, 0)/2 - JyBra(1, -1)/2 assert JzBra(1, 0).rewrite( 'Jy') == sqrt(2)*I*JyBra(1, 1)/2 + sqrt(2)*I*JyBra(1, -1)/2 assert JzBra(1, -1).rewrite( 'Jy') == -JyBra(1, 1)/2 + sqrt(2)*I*JyBra(1, 0)/2 + JyBra(1, -1)/2 # Symbolic assert JxBra(j, m).rewrite('Jy') == Sum( WignerD(j, mi, m, 3*pi/2, 0, 0) * JyBra(j, mi), (mi, -j, j)) assert JxBra(j, m).rewrite('Jz') == Sum( WignerD(j, mi, m, 0, pi/2, 0) * JzBra(j, mi), (mi, -j, j)) assert JyBra(j, m).rewrite('Jx') == Sum( WignerD(j, mi, m, 0, 0, pi/2) * JxBra(j, mi), (mi, -j, j)) assert JyBra(j, m).rewrite('Jz') == Sum( WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * JzBra(j, mi), (mi, -j, j)) assert JzBra(j, m).rewrite('Jx') == Sum( WignerD(j, mi, m, 0, 3*pi/2, 0) * JxBra(j, mi), (mi, -j, j)) assert JzBra(j, m).rewrite('Jy') == Sum( WignerD(j, mi, m, 3*pi/2, pi/2, pi/2) * JyBra(j, mi), (mi, -j, j)) def test_rewrite_Ket(): # Numerical assert JxKet(1, 1).rewrite('Jy') == I*JyKet(1, 1) assert JxKet(1, 0).rewrite('Jy') == JyKet(1, 0) assert JxKet(1, -1).rewrite('Jy') == -I*JyKet(1, -1) assert JxKet(1, 1).rewrite( 'Jz') == JzKet(1, 1)/2 + JzKet(1, 0)/sqrt(2) + JzKet(1, -1)/2 assert JxKet( 1, 0).rewrite('Jz') == -sqrt(2)*JzKet(1, 1)/2 + sqrt(2)*JzKet(1, -1)/2 assert JxKet(1, -1).rewrite( 'Jz') == JzKet(1, 1)/2 - JzKet(1, 0)/sqrt(2) + JzKet(1, -1)/2 assert JyKet(1, 1).rewrite('Jx') == -I*JxKet(1, 1) assert JyKet(1, 0).rewrite('Jx') == JxKet(1, 0) assert JyKet(1, -1).rewrite('Jx') == I*JxKet(1, -1) assert JyKet(1, 1).rewrite( 'Jz') == JzKet(1, 1)/2 + sqrt(2)*I*JzKet(1, 0)/2 - JzKet(1, -1)/2 assert JyKet(1, 0).rewrite( 'Jz') == sqrt(2)*I*JzKet(1, 1)/2 + sqrt(2)*I*JzKet(1, -1)/2 assert JyKet(1, -1).rewrite( 'Jz') == -JzKet(1, 1)/2 + sqrt(2)*I*JzKet(1, 0)/2 + JzKet(1, -1)/2 assert JzKet(1, 1).rewrite( 'Jx') == JxKet(1, 1)/2 - sqrt(2)*JxKet(1, 0)/2 + JxKet(1, -1)/2 assert JzKet( 1, 0).rewrite('Jx') == sqrt(2)*JxKet(1, 1)/2 - sqrt(2)*JxKet(1, -1)/2 assert JzKet(1, -1).rewrite( 'Jx') == JxKet(1, 1)/2 + sqrt(2)*JxKet(1, 0)/2 + JxKet(1, -1)/2 assert JzKet(1, 1).rewrite( 'Jy') == JyKet(1, 1)/2 - sqrt(2)*I*JyKet(1, 0)/2 - JyKet(1, -1)/2 assert JzKet(1, 0).rewrite( 'Jy') == -sqrt(2)*I*JyKet(1, 1)/2 - sqrt(2)*I*JyKet(1, -1)/2 assert JzKet(1, -1).rewrite( 'Jy') == -JyKet(1, 1)/2 - sqrt(2)*I*JyKet(1, 0)/2 + JyKet(1, -1)/2 # Symbolic assert JxKet(j, m).rewrite('Jy') == Sum( WignerD(j, mi, m, 3*pi/2, 0, 0) * JyKet(j, mi), (mi, -j, j)) assert JxKet(j, m).rewrite('Jz') == Sum( WignerD(j, mi, m, 0, pi/2, 0) * JzKet(j, mi), (mi, -j, j)) assert JyKet(j, m).rewrite('Jx') == Sum( WignerD(j, mi, m, 0, 0, pi/2) * JxKet(j, mi), (mi, -j, j)) assert JyKet(j, m).rewrite('Jz') == Sum( WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * JzKet(j, mi), (mi, -j, j)) assert JzKet(j, m).rewrite('Jx') == Sum( WignerD(j, mi, m, 0, 3*pi/2, 0) * JxKet(j, mi), (mi, -j, j)) assert JzKet(j, m).rewrite('Jy') == Sum( WignerD(j, mi, m, 3*pi/2, pi/2, pi/2) * JyKet(j, mi), (mi, -j, j)) def test_rewrite_uncoupled_state(): # Numerical assert TensorProduct(JyKet(1, 1), JxKet( 1, 1)).rewrite('Jx') == -I*TensorProduct(JxKet(1, 1), JxKet(1, 1)) assert TensorProduct(JyKet(1, 0), JxKet( 1, 1)).rewrite('Jx') == TensorProduct(JxKet(1, 0), JxKet(1, 1)) assert TensorProduct(JyKet(1, -1), JxKet( 1, 1)).rewrite('Jx') == I*TensorProduct(JxKet(1, -1), JxKet(1, 1)) assert TensorProduct(JzKet(1, 1), JxKet(1, 1)).rewrite('Jx') == \ TensorProduct(JxKet(1, -1), JxKet(1, 1))/2 - sqrt(2)*TensorProduct(JxKet( 1, 0), JxKet(1, 1))/2 + TensorProduct(JxKet(1, 1), JxKet(1, 1))/2 assert TensorProduct(JzKet(1, 0), JxKet(1, 1)).rewrite('Jx') == \ -sqrt(2)*TensorProduct(JxKet(1, -1), JxKet(1, 1))/2 + sqrt( 2)*TensorProduct(JxKet(1, 1), JxKet(1, 1))/2 assert TensorProduct(JzKet(1, -1), JxKet(1, 1)).rewrite('Jx') == \ TensorProduct(JxKet(1, -1), JxKet(1, 1))/2 + sqrt(2)*TensorProduct(JxKet(1, 0), JxKet(1, 1))/2 + TensorProduct(JxKet(1, 1), JxKet(1, 1))/2 assert TensorProduct(JxKet(1, 1), JyKet( 1, 1)).rewrite('Jy') == I*TensorProduct(JyKet(1, 1), JyKet(1, 1)) assert TensorProduct(JxKet(1, 0), JyKet( 1, 1)).rewrite('Jy') == TensorProduct(JyKet(1, 0), JyKet(1, 1)) assert TensorProduct(JxKet(1, -1), JyKet( 1, 1)).rewrite('Jy') == -I*TensorProduct(JyKet(1, -1), JyKet(1, 1)) assert TensorProduct(JzKet(1, 1), JyKet(1, 1)).rewrite('Jy') == \ -TensorProduct(JyKet(1, -1), JyKet(1, 1))/2 - sqrt(2)*I*TensorProduct(JyKet(1, 0), JyKet(1, 1))/2 + TensorProduct(JyKet(1, 1), JyKet(1, 1))/2 assert TensorProduct(JzKet(1, 0), JyKet(1, 1)).rewrite('Jy') == \ -sqrt(2)*I*TensorProduct(JyKet(1, -1), JyKet( 1, 1))/2 - sqrt(2)*I*TensorProduct(JyKet(1, 1), JyKet(1, 1))/2 assert TensorProduct(JzKet(1, -1), JyKet(1, 1)).rewrite('Jy') == \ TensorProduct(JyKet(1, -1), JyKet(1, 1))/2 - sqrt(2)*I*TensorProduct(JyKet(1, 0), JyKet(1, 1))/2 - TensorProduct(JyKet(1, 1), JyKet(1, 1))/2 assert TensorProduct(JxKet(1, 1), JzKet(1, 1)).rewrite('Jz') == \ TensorProduct(JzKet(1, -1), JzKet(1, 1))/2 + sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 + TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 assert TensorProduct(JxKet(1, 0), JzKet(1, 1)).rewrite('Jz') == \ sqrt(2)*TensorProduct(JzKet(1, -1), JzKet( 1, 1))/2 - sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 assert TensorProduct(JxKet(1, -1), JzKet(1, 1)).rewrite('Jz') == \ TensorProduct(JzKet(1, -1), JzKet(1, 1))/2 - sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 + TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 assert TensorProduct(JyKet(1, 1), JzKet(1, 1)).rewrite('Jz') == \ -TensorProduct(JzKet(1, -1), JzKet(1, 1))/2 + sqrt(2)*I*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 + TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 assert TensorProduct(JyKet(1, 0), JzKet(1, 1)).rewrite('Jz') == \ sqrt(2)*I*TensorProduct(JzKet(1, -1), JzKet( 1, 1))/2 + sqrt(2)*I*TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 assert TensorProduct(JyKet(1, -1), JzKet(1, 1)).rewrite('Jz') == \ TensorProduct(JzKet(1, -1), JzKet(1, 1))/2 + sqrt(2)*I*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 - TensorProduct(JzKet(1, 1), JzKet(1, 1))/2 # Symbolic assert TensorProduct(JyKet(j1, m1), JxKet(j2, m2)).rewrite('Jy') == \ TensorProduct(JyKet(j1, m1), Sum( WignerD(j2, mi, m2, 3*pi/2, 0, 0) * JyKet(j2, mi), (mi, -j2, j2))) assert TensorProduct(JzKet(j1, m1), JxKet(j2, m2)).rewrite('Jz') == \ TensorProduct(JzKet(j1, m1), Sum( WignerD(j2, mi, m2, 0, pi/2, 0) * JzKet(j2, mi), (mi, -j2, j2))) assert TensorProduct(JxKet(j1, m1), JyKet(j2, m2)).rewrite('Jx') == \ TensorProduct(JxKet(j1, m1), Sum( WignerD(j2, mi, m2, 0, 0, pi/2) * JxKet(j2, mi), (mi, -j2, j2))) assert TensorProduct(JzKet(j1, m1), JyKet(j2, m2)).rewrite('Jz') == \ TensorProduct(JzKet(j1, m1), Sum(WignerD( j2, mi, m2, 3*pi/2, -pi/2, pi/2) * JzKet(j2, mi), (mi, -j2, j2))) assert TensorProduct(JxKet(j1, m1), JzKet(j2, m2)).rewrite('Jx') == \ TensorProduct(JxKet(j1, m1), Sum( WignerD(j2, mi, m2, 0, 3*pi/2, 0) * JxKet(j2, mi), (mi, -j2, j2))) assert TensorProduct(JyKet(j1, m1), JzKet(j2, m2)).rewrite('Jy') == \ TensorProduct(JyKet(j1, m1), Sum(WignerD( j2, mi, m2, 3*pi/2, pi/2, pi/2) * JyKet(j2, mi), (mi, -j2, j2))) def test_rewrite_coupled_state(): # Numerical assert JyKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jx') == \ JxKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JyKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jx') == \ -I*JxKetCoupled(1, 1, (S(1)/2, S(1)/2)) assert JyKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jx') == \ JxKetCoupled(1, 0, (S(1)/2, S(1)/2)) assert JyKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jx') == \ I*JxKetCoupled(1, -1, (S(1)/2, S(1)/2)) assert JzKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jx') == \ JxKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jx') == \ JxKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 - sqrt(2)*JxKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 + JxKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jx') == \ sqrt(2)*JxKetCoupled(1, 1, (S( 1)/2, S(1)/2))/2 - sqrt(2)*JxKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jx') == \ JxKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 + sqrt(2)*JxKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 + JxKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JxKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jy') == \ JyKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JxKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jy') == \ I*JyKetCoupled(1, 1, (S(1)/2, S(1)/2)) assert JxKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jy') == \ JyKetCoupled(1, 0, (S(1)/2, S(1)/2)) assert JxKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jy') == \ -I*JyKetCoupled(1, -1, (S(1)/2, S(1)/2)) assert JzKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jy') == \ JyKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jy') == \ JyKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 - I*sqrt(2)*JyKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 - JyKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jy') == \ -I*sqrt(2)*JyKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 - I*sqrt( 2)*JyKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jy') == \ -JyKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 - I*sqrt(2)*JyKetCoupled(1, 0, (S(1)/2, S(1)/2))/2 + JyKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JxKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jz') == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JxKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jz') == \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 + JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JxKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jz') == \ -sqrt(2)*JzKetCoupled(1, 1, (S( 1)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JxKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jz') == \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 - sqrt(2)*JzKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 + JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JyKetCoupled(0, 0, (S(1)/2, S(1)/2)).rewrite('Jz') == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2)) assert JyKetCoupled(1, 1, (S(1)/2, S(1)/2)).rewrite('Jz') == \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 + I*sqrt(2)*JzKetCoupled(1, 0, ( S(1)/2, S(1)/2))/2 - JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JyKetCoupled(1, 0, (S(1)/2, S(1)/2)).rewrite('Jz') == \ I*sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 + I*sqrt( 2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 assert JyKetCoupled(1, -1, (S(1)/2, S(1)/2)).rewrite('Jz') == \ -JzKetCoupled(1, 1, (S(1)/2, S(1)/2))/2 + I*sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2))/2 + JzKetCoupled(1, -1, (S(1)/2, S(1)/2))/2 # Symbolic assert JyKetCoupled(j, m, (j1, j2)).rewrite('Jx') == \ Sum(WignerD(j, mi, m, 0, 0, pi/2) * JxKetCoupled(j, mi, ( j1, j2)), (mi, -j, j)) assert JzKetCoupled(j, m, (j1, j2)).rewrite('Jx') == \ Sum(WignerD(j, mi, m, 0, 3*pi/2, 0) * JxKetCoupled(j, mi, ( j1, j2)), (mi, -j, j)) assert JxKetCoupled(j, m, (j1, j2)).rewrite('Jy') == \ Sum(WignerD(j, mi, m, 3*pi/2, 0, 0) * JyKetCoupled(j, mi, ( j1, j2)), (mi, -j, j)) assert JzKetCoupled(j, m, (j1, j2)).rewrite('Jy') == \ Sum(WignerD(j, mi, m, 3*pi/2, pi/2, pi/2) * JyKetCoupled(j, mi, (j1, j2)), (mi, -j, j)) assert JxKetCoupled(j, m, (j1, j2)).rewrite('Jz') == \ Sum(WignerD(j, mi, m, 0, pi/2, 0) * JzKetCoupled(j, mi, ( j1, j2)), (mi, -j, j)) assert JyKetCoupled(j, m, (j1, j2)).rewrite('Jz') == \ Sum(WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * JzKetCoupled( j, mi, (j1, j2)), (mi, -j, j)) def test_innerproducts_of_rewritten_states(): # Numerical assert qapply(JxBra(1, 1)*JxKet(1, 1).rewrite('Jy')).doit() == 1 assert qapply(JxBra(1, 0)*JxKet(1, 0).rewrite('Jy')).doit() == 1 assert qapply(JxBra(1, -1)*JxKet(1, -1).rewrite('Jy')).doit() == 1 assert qapply(JxBra(1, 1)*JxKet(1, 1).rewrite('Jz')).doit() == 1 assert qapply(JxBra(1, 0)*JxKet(1, 0).rewrite('Jz')).doit() == 1 assert qapply(JxBra(1, -1)*JxKet(1, -1).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, 1)*JyKet(1, 1).rewrite('Jx')).doit() == 1 assert qapply(JyBra(1, 0)*JyKet(1, 0).rewrite('Jx')).doit() == 1 assert qapply(JyBra(1, -1)*JyKet(1, -1).rewrite('Jx')).doit() == 1 assert qapply(JyBra(1, 1)*JyKet(1, 1).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, 0)*JyKet(1, 0).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, -1)*JyKet(1, -1).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, 1)*JyKet(1, 1).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, 0)*JyKet(1, 0).rewrite('Jz')).doit() == 1 assert qapply(JyBra(1, -1)*JyKet(1, -1).rewrite('Jz')).doit() == 1 assert qapply(JzBra(1, 1)*JzKet(1, 1).rewrite('Jy')).doit() == 1 assert qapply(JzBra(1, 0)*JzKet(1, 0).rewrite('Jy')).doit() == 1 assert qapply(JzBra(1, -1)*JzKet(1, -1).rewrite('Jy')).doit() == 1 assert qapply(JxBra(1, 1)*JxKet(1, 0).rewrite('Jy')).doit() == 0 assert qapply(JxBra(1, 1)*JxKet(1, -1).rewrite('Jy')) == 0 assert qapply(JxBra(1, 1)*JxKet(1, 0).rewrite('Jz')).doit() == 0 assert qapply(JxBra(1, 1)*JxKet(1, -1).rewrite('Jz')) == 0 assert qapply(JyBra(1, 1)*JyKet(1, 0).rewrite('Jx')).doit() == 0 assert qapply(JyBra(1, 1)*JyKet(1, -1).rewrite('Jx')) == 0 assert qapply(JyBra(1, 1)*JyKet(1, 0).rewrite('Jz')).doit() == 0 assert qapply(JyBra(1, 1)*JyKet(1, -1).rewrite('Jz')) == 0 assert qapply(JzBra(1, 1)*JzKet(1, 0).rewrite('Jx')).doit() == 0 assert qapply(JzBra(1, 1)*JzKet(1, -1).rewrite('Jx')) == 0 assert qapply(JzBra(1, 1)*JzKet(1, 0).rewrite('Jy')).doit() == 0 assert qapply(JzBra(1, 1)*JzKet(1, -1).rewrite('Jy')) == 0 assert qapply(JxBra(1, 0)*JxKet(1, 1).rewrite('Jy')) == 0 assert qapply(JxBra(1, 0)*JxKet(1, -1).rewrite('Jy')) == 0 assert qapply(JxBra(1, 0)*JxKet(1, 1).rewrite('Jz')) == 0 assert qapply(JxBra(1, 0)*JxKet(1, -1).rewrite('Jz')) == 0 assert qapply(JyBra(1, 0)*JyKet(1, 1).rewrite('Jx')) == 0 assert qapply(JyBra(1, 0)*JyKet(1, -1).rewrite('Jx')) == 0 assert qapply(JyBra(1, 0)*JyKet(1, 1).rewrite('Jz')) == 0 assert qapply(JyBra(1, 0)*JyKet(1, -1).rewrite('Jz')) == 0 assert qapply(JzBra(1, 0)*JzKet(1, 1).rewrite('Jx')) == 0 assert qapply(JzBra(1, 0)*JzKet(1, -1).rewrite('Jx')) == 0 assert qapply(JzBra(1, 0)*JzKet(1, 1).rewrite('Jy')) == 0 assert qapply(JzBra(1, 0)*JzKet(1, -1).rewrite('Jy')) == 0 assert qapply(JxBra(1, -1)*JxKet(1, 1).rewrite('Jy')) == 0 assert qapply(JxBra(1, -1)*JxKet(1, 0).rewrite('Jy')).doit() == 0 assert qapply(JxBra(1, -1)*JxKet(1, 1).rewrite('Jz')) == 0 assert qapply(JxBra(1, -1)*JxKet(1, 0).rewrite('Jz')).doit() == 0 assert qapply(JyBra(1, -1)*JyKet(1, 1).rewrite('Jx')) == 0 assert qapply(JyBra(1, -1)*JyKet(1, 0).rewrite('Jx')).doit() == 0 assert qapply(JyBra(1, -1)*JyKet(1, 1).rewrite('Jz')) == 0 assert qapply(JyBra(1, -1)*JyKet(1, 0).rewrite('Jz')).doit() == 0 assert qapply(JzBra(1, -1)*JzKet(1, 1).rewrite('Jx')) == 0 assert qapply(JzBra(1, -1)*JzKet(1, 0).rewrite('Jx')).doit() == 0 assert qapply(JzBra(1, -1)*JzKet(1, 1).rewrite('Jy')) == 0 assert qapply(JzBra(1, -1)*JzKet(1, 0).rewrite('Jy')).doit() == 0 def test_uncouple_2_coupled_states(): # j1=1/2, j2=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)) ))) # j1=1/2, j2=1 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)) == \ expand(uncouple( couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)) ))) # j1=1, j2=1 assert TensorProduct(JzKet(1, 1), JzKet(1, 1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 1), JzKet(1, 1)) ))) assert TensorProduct(JzKet(1, 1), JzKet(1, 0)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 1), JzKet(1, 0)) ))) assert TensorProduct(JzKet(1, 1), JzKet(1, -1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 1), JzKet(1, -1)) ))) assert TensorProduct(JzKet(1, 0), JzKet(1, 1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 0), JzKet(1, 1)) ))) assert TensorProduct(JzKet(1, 0), JzKet(1, 0)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 0), JzKet(1, 0)) ))) assert TensorProduct(JzKet(1, 0), JzKet(1, -1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, 0), JzKet(1, -1)) ))) assert TensorProduct(JzKet(1, -1), JzKet(1, 1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, -1), JzKet(1, 1)) ))) assert TensorProduct(JzKet(1, -1), JzKet(1, 0)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, -1), JzKet(1, 0)) ))) assert TensorProduct(JzKet(1, -1), JzKet(1, -1)) == \ expand(uncouple(couple( TensorProduct(JzKet(1, -1), JzKet(1, -1)) ))) def test_uncouple_3_coupled_states(): # Default coupling # j1=1/2, j2=1/2, j3=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/ 2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) # j1=1/2, j2=1, j3=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct( JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) # Coupling j1+j3=j13, j13+j2=j # j1=1/2, j2=1/2, j3=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) # j1=1/2, j2=1, j3=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( 1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( -1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( -1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( -1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( -1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S( -1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/ 2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ))) def test_uncouple_4_coupled_states(): # j1=1/2, j2=1/2, j3=1/2, j4=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S( 1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) ))) # j1=1/2, j2=1/2, j3=1, j4=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet( S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) ))) # Couple j1+j3=j13, j2+j4=j24, j13+j24=j # j1=1/2, j2=1/2, j3=1/2, j4=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) # j1=1/2, j2=1/2, j3=1, j4=1/2 assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(1)/2)), ((1, 3), (2, 4), (1, 2)) ))) assert TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)) == \ expand(uncouple(couple( TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (2, 4), (1, 2)) ))) def test_uncouple_2_coupled_states_numerical(): # j1=1/2, j2=1/2 assert uncouple(JzKetCoupled(0, 0, (S(1)/2, S(1)/2))) == \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))/2 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))/2 assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2))) == \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2))) == \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))/2 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))/2 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)) # j1=1, j2=1/2 assert uncouple(JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2))) == \ -sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(S(1)/2, S(1)/2))/3 + \ sqrt(6)*TensorProduct(JzKet(1, 1), JzKet(S(1)/2, -S(1)/2))/3 assert uncouple(JzKetCoupled(S(1)/2, -S(1)/2, (1, S(1)/2))) == \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(S(1)/2, -S(1)/2))/3 - \ sqrt(6)*TensorProduct(JzKet(1, -1), JzKet(S(1)/2, S(1)/2))/3 assert uncouple(JzKetCoupled(S(3)/2, S(3)/2, (1, S(1)/2))) == \ TensorProduct(JzKet(1, 1), JzKet(S(1)/2, S(1)/2)) assert uncouple(JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2))) == \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(S(1)/2, -S(1)/2))/3 + \ sqrt(6)*TensorProduct(JzKet(1, 0), JzKet(S(1)/2, S(1)/2))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(1)/2, (1, S(1)/2))) == \ sqrt(6)*TensorProduct(JzKet(1, 0), JzKet(S(1)/2, -S(1)/2))/3 + \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(S(1)/2, S(1)/2))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(3)/2, (1, S(1)/2))) == \ TensorProduct(JzKet(1, -1), JzKet(S(1)/2, -S(1)/2)) # j1=1, j2=1 assert uncouple(JzKetCoupled(0, 0, (1, 1))) == \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, -1))/3 - \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 1))/3 assert uncouple(JzKetCoupled(1, 1, (1, 1))) == \ sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 - \ sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 assert uncouple(JzKetCoupled(1, 0, (1, 1))) == \ sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, -1))/2 - \ sqrt(2)*TensorProduct(JzKet(1, -1), JzKet(1, 1))/2 assert uncouple(JzKetCoupled(1, -1, (1, 1))) == \ sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, -1))/2 - \ sqrt(2)*TensorProduct(JzKet(1, -1), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(2, 2, (1, 1))) == \ TensorProduct(JzKet(1, 1), JzKet(1, 1)) assert uncouple(JzKetCoupled(2, 1, (1, 1))) == \ sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 + \ sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 assert uncouple(JzKetCoupled(2, 0, (1, 1))) == \ sqrt(6)*TensorProduct(JzKet(1, 1), JzKet(1, -1))/6 + \ sqrt(6)*TensorProduct(JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct(JzKet(1, -1), JzKet(1, 1))/6 assert uncouple(JzKetCoupled(2, -1, (1, 1))) == \ sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, -1))/2 + \ sqrt(2)*TensorProduct(JzKet(1, -1), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(2, -2, (1, 1))) == \ TensorProduct(JzKet(1, -1), JzKet(1, -1)) def test_uncouple_3_coupled_states_numerical(): # Default coupling # j1=1/2, j2=1/2, j3=1/2 assert uncouple(JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2))) == \ TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)) assert uncouple(JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2))) == \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))/3 + \ sqrt(3)*TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2))) == \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))/3 + \ sqrt(3)*TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2))) == \ TensorProduct(JzKet( S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2)) # j1=1/2, j2=1/2, j3=1 assert uncouple(JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1))) == \ TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)) assert uncouple(JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))/2 + \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))/2 + \ sqrt(2)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1))) == \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1))) == \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))/2 + \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1))/2 + \ TensorProduct( JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1))) == \ TensorProduct( JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1)) assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1))) == \ -TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))/2 - \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))/2 + \ sqrt(2)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))/2 + \ sqrt(2)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))/2 + \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))/2 + \ TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1))/2 # j1=1/2, j2=1, j3=1 assert uncouple(JzKetCoupled(S(5)/2, S(5)/2, (S(1)/2, 1, 1))) == \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1)) assert uncouple(JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, 1, 1))) == \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/5 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/5 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/5 assert uncouple(JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, 1, 1))) == \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/5 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(10)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1))) == \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/5 assert uncouple(JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1))) == \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/5 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/5 + \ sqrt(5)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/5 assert uncouple(JzKetCoupled(S(5)/2, -S(5)/2, (S(1)/2, 1, 1))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1)) assert uncouple(JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1))) == \ -sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/15 - \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/5 assert uncouple(JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1))) == \ -4*sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 - \ 2*sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/15 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/5 assert uncouple(JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1))) == \ -sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/5 - \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ 2*sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/15 - \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ 4*sqrt(5)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1))) == \ -sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/5 + \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(30)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/3 - \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1))) == \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/2 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 - \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/3 # j1=1, j2=1, j3=1 assert uncouple(JzKetCoupled(3, 3, (1, 1, 1))) == \ TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 1)) assert uncouple(JzKetCoupled(3, 2, (1, 1, 1))) == \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(3, 1, (1, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, 0, (1, 1, 1))) == \ sqrt(10)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0))/10 + \ sqrt(10)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(10)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(10)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0))/10 + \ sqrt(10)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(3, -1, (1, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, -1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 0))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, -2, (1, 1, 1))) == \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, -1))/3 + \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(3, -3, (1, 1, 1))) == \ TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, -1)) assert uncouple(JzKetCoupled(2, 2, (1, 1, 1))) == \ -sqrt(6)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 1))/6 - \ sqrt(6)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(2, 1, (1, 1, 1))) == \ -sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))/6 - \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 0))/6 - \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(2, 0, (1, 1, 1))) == \ -TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))/2 + \ TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, -1, (1, 1, 1))) == \ -sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))/3 - \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, -1))/6 - \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))/3 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(2, -2, (1, 1, 1))) == \ -sqrt(6)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, -1))/6 + \ sqrt(6)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(1, 1, (1, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))/30 + \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))/15 - \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 1))/30 - \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))/5 assert uncouple(JzKetCoupled(1, 0, (1, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1))/10 - \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))/10 - \ 2*sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))/10 - \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(1, -1, (1, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))/5 - \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, -1))/30 - \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(15)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))/30 # Defined j13 # j1=1/2, j2=1/2, j3=1, j13=1/2 assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )) == \ -sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))/3 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1))/3 # j1=1/2, j2=1, j3=1, j13=1/2 assert uncouple(JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)))) == \ -sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)))) == \ -2*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/3 - \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/3 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 + \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ 2*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct( JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/3 # j1=1, j2=1, j3=1, j13=1 assert uncouple(JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)))) == \ -sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 1))/2 + \ sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)))) == \ -TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)))) == \ -sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1))/3 - \ sqrt(3)*TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0))/6 - \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)))) == \ -TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))/2 - \ TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))/2 + \ TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)))) == \ -sqrt(2)*TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 0))/2 + \ sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)))) == \ TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))/2 - \ TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 1)))) == \ TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)))) == \ -TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))/2 + \ TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))/2 - \ TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))/2 + \ TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))/2 def test_uncouple_4_coupled_states_numerical(): # j1=1/2, j2=1/2, j3=1, j4=1, default coupling assert uncouple(JzKetCoupled(3, 3, (S(1)/2, S(1)/2, 1, 1))) == \ TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1)) assert uncouple(JzKetCoupled(3, 2, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(3, 1, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, 0, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(3, -1, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, -2, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/3 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(3, -3, (S(1)/2, S(1)/2, 1, 1))) == \ TensorProduct(JzKet(S(1)/2, -S( 1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1)) assert uncouple(JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1, 1))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1, 1))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/12 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/12 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1, 1))) == \ -TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/2 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/4 + \ TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1, 1))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/3 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/12 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/12 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1, 1))) == \ -sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/30 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/20 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/20 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/30 - \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/5 assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/10 - \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/20 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/20 - \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1, 1))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/5 - \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/20 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/20 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/30 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/30 # j1=1/2, j2=1/2, j3=1, j4=1, j12=1, j34=1 assert uncouple(JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 2)))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/2 + \ sqrt(2)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/2 assert uncouple(JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 2)))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/4 - \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/2 + \ TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 2)))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/6 + \ sqrt(3)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 2)))) == \ -TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/2 + \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/2 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/4 assert uncouple(JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 2)))) == \ -sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/2 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 1)))) == \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/4 - \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/2 + \ TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 1)))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/2 - \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/2 - \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/2 + \ TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 1), (1, 3, 1)))) == \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/2 - \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/2 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/4 - \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/4 + \ sqrt(2)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/4 # j1=1/2, j2=1/2, j3=1, j4=1, j12=1, j34=2 assert uncouple(JzKetCoupled(3, 3, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ TensorProduct(JzKet( S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1)) assert uncouple(JzKetCoupled(3, 2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/3 + \ sqrt(3)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/3 assert uncouple(JzKetCoupled(3, 1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, 0, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/10 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/5 + \ sqrt(5)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/10 + \ sqrt(10)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(3, -1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/15 + \ 2*sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/15 + \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/15 assert uncouple(JzKetCoupled(3, -2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/3 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(3, -3, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 3)))) == \ TensorProduct(JzKet(S(1)/2, -S( 1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1)) assert uncouple(JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 2)))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1))/3 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/3 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/6 + \ sqrt(6)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/6 assert uncouple(JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 2)))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/3 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/12 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/12 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/12 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/12 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 + \ sqrt(3)*TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 assert uncouple(JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 2)))) == \ -TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/2 - \ TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/2 + \ TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/2 + \ TensorProduct(JzKet(S( 1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/2 assert uncouple(JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 2)))) == \ -sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/6 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/3 - \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/6 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/12 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/12 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/12 + \ sqrt(6)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/12 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 2)))) == \ -sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/6 - \ sqrt(6)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/6 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/3 + \ sqrt(3)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, -1))/3 assert uncouple(JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 1)))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 1))/5 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/20 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/30 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/30 assert uncouple(JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 1)))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 1))/10 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, 0))/10 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/30 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/10 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/10 assert uncouple(JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1, 1), ((1, 2, 1), (3, 4, 2), (1, 3, 1)))) == \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 1))/30 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, 0))/15 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1), JzKet(1, -1))/30 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1), JzKet(1, 0))/20 - \ sqrt(30)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0), JzKet(1, -1))/20 + \ sqrt(15)*TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))/5 def test_uncouple_symbolic(): assert uncouple(JzKetCoupled(j, m, (j1, j2) )) == \ Sum(CG(j1, m1, j2, m2, j, m) * TensorProduct(JzKet(j1, m1), JzKet(j2, m2)), (m1, -j1, j1), (m2, -j2, j2)) assert uncouple(JzKetCoupled(j, m, (j1, j2, j3) )) == \ Sum(CG(j1, m1, j2, m2, j1 + j2, m1 + m2) * CG(j1 + j2, m1 + m2, j3, m3, j, m) * TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3)), (m1, -j1, j1), (m2, -j2, j2), (m3, -j3, j3)) assert uncouple(JzKetCoupled(j, m, (j1, j2, j3), ((1, 3, j13), (1, 2, j)) )) == \ Sum(CG(j1, m1, j3, m3, j13, m1 + m3) * CG(j13, m1 + m3, j2, m2, j, m) * TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3)), (m1, -j1, j1), (m2, -j2, j2), (m3, -j3, j3)) assert uncouple(JzKetCoupled(j, m, (j1, j2, j3, j4) )) == \ Sum(CG(j1, m1, j2, m2, j1 + j2, m1 + m2) * CG(j1 + j2, m1 + m2, j3, m3, j1 + j2 + j3, m1 + m2 + m3) * CG(j1 + j2 + j3, m1 + m2 + m3, j4, m4, j, m) * TensorProduct( JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3), JzKet(j4, m4)), (m1, -j1, j1), (m2, -j2, j2), (m3, -j3, j3), (m4, -j4, j4)) assert uncouple(JzKetCoupled(j, m, (j1, j2, j3, j4), ((1, 3, j13), (2, 4, j24), (1, 2, j)) )) == \ Sum(CG(j1, m1, j3, m3, j13, m1 + m3) * CG(j2, m2, j4, m4, j24, m2 + m4) * CG(j13, m1 + m3, j24, m2 + m4, j, m) * TensorProduct( JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3), JzKet(j4, m4)), (m1, -j1, j1), (m2, -j2, j2), (m3, -j3, j3), (m4, -j4, j4)) def test_couple_2_states(): # j1=1/2, j2=1/2 assert JzKetCoupled(0, 0, (S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(0, 0, (S(1)/2, S(1)/2)) ))) assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, S(1)/2)) ))) assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, S(1)/2)) ))) assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, S(1)/2)) ))) # j1=1, j2=1/2 assert JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2)) ))) assert JzKetCoupled(S(1)/2, -S(1)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, -S(1)/2, (1, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(3)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(3)/2, (1, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, -S(1)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, -S(1)/2, (1, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, -S(3)/2, (1, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, -S(3)/2, (1, S(1)/2)) ))) # j1=1, j2=1 assert JzKetCoupled(0, 0, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(0, 0, (1, 1)) ))) assert JzKetCoupled(1, 1, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (1, 1)) ))) assert JzKetCoupled(1, 0, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (1, 1)) ))) assert JzKetCoupled(1, -1, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (1, 1)) ))) assert JzKetCoupled(2, 2, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 2, (1, 1)) ))) assert JzKetCoupled(2, 1, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 1, (1, 1)) ))) assert JzKetCoupled(2, 0, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 0, (1, 1)) ))) assert JzKetCoupled(2, -1, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, -1, (1, 1)) ))) assert JzKetCoupled(2, -2, (1, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, -2, (1, 1)) ))) # j1=1/2, j2=3/2 assert JzKetCoupled(1, 1, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(1, 0, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(1, -1, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(2, 2, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, 2, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(2, 1, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, 1, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(2, 0, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, 0, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(2, -1, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, -1, (S(1)/2, S(3)/2)) ))) assert JzKetCoupled(2, -2, (S(1)/2, S(3)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, -2, (S(1)/2, S(3)/2)) ))) def test_couple_3_states(): # Default coupling # j1=1/2, j2=1/2, j3=1/2 assert JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2)) ))) # j1=1/2, j2=1/2, j3=1 assert JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, 0, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1)) ))) # Couple j1+j3=j13, j13+j2=j # j1=1/2, j2=1/2, j3=1/2, j13=0 assert JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S( 1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2))) ), ((1, 3), (1, 2)) )) # j1=1, j2=1/2, j3=1, j13=1 assert JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(1)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(1)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(1)/2, S(-1)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(1)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(-1)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(1)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(3)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(3)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(1)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(-1)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-1)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) ), ((1, 3), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(-3)/2, (1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-3)/2, ( 1, S(1)/2, 1), ((1, 3, 1), (1, 2, S(3)/2))) ), ((1, 3), (1, 2)) )) def test_couple_4_states(): # Default coupling # j1=1/2, j2=1/2, j3=1/2, j4=1/2 assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple( uncouple( JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple( uncouple( JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(2, 2, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple( uncouple( JzKetCoupled(2, 2, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(2, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple( uncouple( JzKetCoupled(2, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple( uncouple( JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(2, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) assert JzKetCoupled(2, -2, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) == \ expand(couple(uncouple( JzKetCoupled(2, -2, (S(1)/2, S(1)/2, S(1)/2, S(1)/2)) ))) # j1=1/2, j2=1/2, j3=1/2, j4=1 assert JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(5)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(5)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) assert JzKetCoupled(S(5)/2, S(-5)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) == \ expand(couple(uncouple( JzKetCoupled(S(5)/2, S(-5)/2, (S(1)/2, S(1)/2, S(1)/2, 1)) ))) # Coupling j1+j3=j13, j2+j4=j24, j13+j24=j # j1=1/2, j2=1/2, j3=1/2, j4=1/2, j13=1, j24=0 assert JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (2, 4, 0), (1, 2, 1)) ) ), ((1, 3), (2, 4), (1, 2)) )) # j1=1/2, j2=1/2, j3=1/2, j4=1, j13=1, j24=1/2 assert JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(1)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(1)/2)) )), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(1)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(1)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(1)/2)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) == \ expand(couple(uncouple( JzKetCoupled(S(3)/2, S(-3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 3, 1), (2, 4, S(1)/2), (1, 2, S(3)/2)) ) ), ((1, 3), (2, 4), (1, 2)) )) # j1=1/2, j2=1, j3=1/2, j4=1, j13=0, j24=1 assert JzKetCoupled(1, 1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 0), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 0), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, 0, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 0), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 0), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, -1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 0), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 0), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) # j1=1/2, j2=1, j3=1/2, j4=1, j13=1, j24=1 assert JzKetCoupled(0, 0, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 0)) ) == \ expand(couple(uncouple( JzKetCoupled(0, 0, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 0))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, 1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, 0, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, 0, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(1, -1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 1)) ) == \ expand(couple(uncouple( JzKetCoupled(1, -1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 1))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(2, 2, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 2)) ) == \ expand(couple(uncouple( JzKetCoupled(2, 2, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 2))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(2, 1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 2)) ) == \ expand(couple(uncouple( JzKetCoupled(2, 1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 2))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(2, 0, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 2)) ) == \ expand(couple(uncouple( JzKetCoupled(2, 0, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 2))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(2, -1, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 2)) ) == \ expand(couple(uncouple( JzKetCoupled(2, -1, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 2))) ), ((1, 3), (2, 4), (1, 2)) )) assert JzKetCoupled(2, -2, (S(1)/2, 1, S(1)/2, 1), ((1, 3, 1), (2, 4, 1), (1, 2, 2)) ) == \ expand(couple(uncouple( JzKetCoupled(2, -2, (S(1)/2, 1, S(1)/2, 1), ( (1, 3, 1), (2, 4, 1), (1, 2, 2))) ), ((1, 3), (2, 4), (1, 2)) )) def test_couple_2_states_numerical(): # j1=1/2, j2=1/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2)) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))) == \ sqrt(2)*JzKetCoupled(0, 0, (S( 1)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(2)*JzKetCoupled(0, 0, (S( 1)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2))) == \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2)) # j1=1, j2=1/2 assert couple(TensorProduct(JzKet(1, 1), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(S(3)/2, S(3)/2, (1, S(1)/2)) assert couple(TensorProduct(JzKet(1, 1), JzKet(S(1)/2, -S(1)/2))) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2))/3 + sqrt( 3)*JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2))/3 assert couple(TensorProduct(JzKet(1, 0), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(3)*JzKetCoupled(S(1)/2, S(1)/2, (1, S(1)/2))/3 + \ sqrt(6)*JzKetCoupled(S(3)/2, S(1)/2, (1, S(1)/2))/3 assert couple(TensorProduct(JzKet(1, 0), JzKet(S(1)/2, -S(1)/2))) == \ sqrt(3)*JzKetCoupled(S(1)/2, -S(1)/2, (1, S(1)/2))/3 + \ sqrt(6)*JzKetCoupled(S(3)/2, -S(1)/2, (1, S(1)/2))/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (1, S( 1)/2))/3 + sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (1, S(1)/2))/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(S(1)/2, -S(1)/2))) == \ JzKetCoupled(S(3)/2, -S(3)/2, (1, S(1)/2)) # j1=1, j2=1 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1))) == \ JzKetCoupled(2, 2, (1, 1)) assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0))) == \ sqrt(2)*JzKetCoupled( 1, 1, (1, 1))/2 + sqrt(2)*JzKetCoupled(2, 1, (1, 1))/2 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ sqrt(3)*JzKetCoupled(0, 0, (1, 1))/3 + sqrt(2)*JzKetCoupled( 1, 0, (1, 1))/2 + sqrt(6)*JzKetCoupled(2, 0, (1, 1))/6 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1))) == \ -sqrt(2)*JzKetCoupled( 1, 1, (1, 1))/2 + sqrt(2)*JzKetCoupled(2, 1, (1, 1))/2 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0))) == \ -sqrt(3)*JzKetCoupled( 0, 0, (1, 1))/3 + sqrt(6)*JzKetCoupled(2, 0, (1, 1))/3 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled( 1, -1, (1, 1))/2 + sqrt(2)*JzKetCoupled(2, -1, (1, 1))/2 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(0, 0, (1, 1))/3 - sqrt(2)*JzKetCoupled( 1, 0, (1, 1))/2 + sqrt(6)*JzKetCoupled(2, 0, (1, 1))/6 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0))) == \ -sqrt(2)*JzKetCoupled( 1, -1, (1, 1))/2 + sqrt(2)*JzKetCoupled(2, -1, (1, 1))/2 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1))) == \ JzKetCoupled(2, -2, (1, 1)) # j1=3/2, j2=1/2 assert couple(TensorProduct(JzKet(S(3)/2, S(3)/2), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(2, 2, (S(3)/2, S(1)/2)) assert couple(TensorProduct(JzKet(S(3)/2, S(3)/2), JzKet(S(1)/2, -S(1)/2))) == \ sqrt(3)*JzKetCoupled( 1, 1, (S(3)/2, S(1)/2))/2 + JzKetCoupled(2, 1, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ -JzKetCoupled(1, 1, (S( 3)/2, S(1)/2))/2 + sqrt(3)*JzKetCoupled(2, 1, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2))) == \ sqrt(2)*JzKetCoupled(1, 0, (S( 3)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(2, 0, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(2)*JzKetCoupled(1, 0, (S( 3)/2, S(1)/2))/2 + sqrt(2)*JzKetCoupled(2, 0, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2))) == \ JzKetCoupled(1, -1, (S( 3)/2, S(1)/2))/2 + sqrt(3)*JzKetCoupled(2, -1, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, -S(3)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(3)*JzKetCoupled(1, -1, (S(3)/2, S(1)/2))/2 + \ JzKetCoupled(2, -1, (S(3)/2, S(1)/2))/2 assert couple(TensorProduct(JzKet(S(3)/2, -S(3)/2), JzKet(S(1)/2, -S(1)/2))) == \ JzKetCoupled(2, -2, (S(3)/2, S(1)/2)) def test_couple_3_states_numerical(): # Default coupling # j1=1/2,j2=1/2,j3=1/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(S(3)/2, S( 3)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 2, 1), (1, 3, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ JzKetCoupled(S(3)/2, -S( 3)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2)) ) # j1=S(1)/2, j2=S(1)/2, j3=1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(2)*JzKetCoupled( 2, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 0)) )/3 + \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 0)) )/6 + \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 + \ sqrt(3)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 + \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ -sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 0)) )/6 - \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 + \ sqrt(3)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ -sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, 1)) )/2 + \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 0)) )/3 - \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, 0))) == \ -sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(2)*JzKetCoupled( 2, -1, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, -S(1)/2), JzKet(S(1)/2, -S(1)/2), JzKet(1, -1))) == \ JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, 2)) ) # j1=S(1)/2, j2=1, j3=1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1))) == \ JzKetCoupled( S(5)/2, S(5)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0))) == \ sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/2 + \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 2*sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0))) == \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 4*sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1))) == \ -2*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0))) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 + \ 2*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1))) == \ sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, 1))) == \ -sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, 0))) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 - \ 2*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, -1))) == \ -2*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 4*sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, 0))) == \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, -1))) == \ -sqrt(3)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(1)/2)) )/2 - \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, 0))) == \ -sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, -1))) == \ JzKetCoupled(S( 5)/2, -S(5)/2, (S(1)/2, 1, 1), ((1, 2, S(3)/2), (1, 3, S(5)/2)) ) # j1=1, j2=1, j3=1 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 1))) == \ JzKetCoupled(3, 3, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) ) assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 0))) == \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1))) == \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/5 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0))) == \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 + \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1))) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 + \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/6 + \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 - \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/30 + \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 + \ sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 - \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/15 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/3 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1))) == \ sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 + \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/30 + \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 1))) == \ -sqrt(2)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 0))) == \ -JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 - \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1))) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 - \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/6 + \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1))) == \ -sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/15 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 0))) == \ -sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 - \ 2*sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/15 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/5 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1))) == \ -sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/15 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1))) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 - \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/6 - \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 0))) == \ -JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 + \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 + \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/30 - \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0))) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 + \ sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 - \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/15 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/3 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, -1))) == \ sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 0), (1, 3, 1)) )/3 - \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/30 - \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1))) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 0)) )/6 + \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/6 - \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/10 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0))) == \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/10 - \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, -1))) == \ -sqrt(2)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 2, 1), (1, 3, 2)) )/2 + \ sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1))) == \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 1)) )/5 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 2)) )/3 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, -1))) == \ JzKetCoupled(3, -3, (1, 1, 1), ((1, 2, 2), (1, 3, 3)) ) # j1=S(1)/2, j2=S(1)/2, j3=S(3)/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(3)/2))) == \ JzKetCoupled(S(5)/2, S( 5)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(1)/2))) == \ sqrt(10)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/5 + \ sqrt(15)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-1)/2))) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ 2*sqrt(30)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/15 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-3)/2))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/2 + \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(3)/2))) == \ sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/ 2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/30 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/30 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-3)/2))) == \ sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(3)/2))) == \ -sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/ 2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/30 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-1)/2))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/30 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-3)/2))) == \ -sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 0), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(3)/2))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/2 - \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(1)/2))) == \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(1)/2)) )/6 - \ 2*sqrt(30)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/15 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-1)/2))) == \ -sqrt(10)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(3)/2)) )/5 + \ sqrt(15)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S( 3)/2), ((1, 2, 1), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-3)/2))) == \ JzKetCoupled(S(5)/2, -S( 5)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 2, 1), (1, 3, S(5)/2)) ) # Couple j1 to j3 # j1=1/2, j2=1/2, j3=1/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(3)/2, S( 3)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(3)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/ 2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 0), (1, 2, S(1)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1) /2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(3)/2, -S( 3)/2, (S(1)/2, S(1)/2, S(1)/2), ((1, 3, 1), (1, 2, S(3)/2)) ) # j1=1/2, j2=1/2, j3=1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(2, 2, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 - \ sqrt(6)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ sqrt(2)*JzKetCoupled( 2, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 0)) )/3 + \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 - \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ sqrt(6)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 0)) )/6 + \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/6 + \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/3 + \ sqrt(3)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 + \ sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ JzKetCoupled( 2, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 - \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ JzKetCoupled(2, 1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 0)) )/6 - \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/6 - \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/3 + \ sqrt(3)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/3 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/2 + \ JzKetCoupled( 2, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 0)) )/3 - \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 + \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ sqrt(6)*JzKetCoupled( 2, 0, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(1)/2), (1, 2, 1)) )/3 + \ sqrt(6)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 1)) )/6 + \ sqrt(2)*JzKetCoupled( 2, -1, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(2, -2, (S(1)/2, S(1)/2, 1), ((1, 3, S(3)/2), (1, 2, 2)) ) # j 1=1/2, j 2=1, j 3=1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled( S(5)/2, S(5)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ 2*sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -2*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, 0), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 + \ 2*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/2 + \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ 4*sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(1, -1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ 4*sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/2 - \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 - \ 2*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S( 5)/2, S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 - \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, 0), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -2*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(1)/2), (1, 2, S(3)/2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(1, -1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S( 5)/2, -S(5)/2, (S(1)/2, 1, 1), ((1, 3, S(3)/2), (1, 2, S(5)/2)) ) # j1=1, 1, 1 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(3, 3, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) ) assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 - \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/30 + \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 + \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, 0), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 + \ sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 - \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/15 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/3 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/5 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 + \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/6 + \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, 1), JzKet(1, -1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 + \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/30 + \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(6)*JzKetCoupled(2, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, 2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/15 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 - \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 + \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/6 - \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 - \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 - \ 2*sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/15 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/5 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, 0), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 + \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 - \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/6 + \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/15 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, 0), JzKet(1, -1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(2)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 + \ JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/30 - \ JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, 1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 + \ JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/6 - \ JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/2 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/5 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(0, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 0)) )/6 + \ sqrt(3)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 - \ sqrt(15)*JzKetCoupled(1, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/15 - \ sqrt(3)*JzKetCoupled(2, 0, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/3 + \ sqrt(10)*JzKetCoupled(3, 0, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/10 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 - \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/10 - \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 - \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ 2*sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, 0), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/3 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 1)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 0), (1, 2, 1)) )/3 - \ JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 1)) )/2 + \ sqrt(15)*JzKetCoupled(1, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 1)) )/30 - \ JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(3)*JzKetCoupled(2, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(15)*JzKetCoupled(3, -1, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/15 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, 0)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 1), (1, 2, 2)) )/2 + \ sqrt(6)*JzKetCoupled(2, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 2)) )/6 + \ sqrt(3)*JzKetCoupled(3, -2, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) )/3 assert couple(TensorProduct(JzKet(1, -1), JzKet(1, -1), JzKet(1, -1)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(3, -3, (1, 1, 1), ((1, 3, 2), (1, 2, 3)) ) # j1=1/2, j2=1/2, j3=3/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(3)/2)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(5)/2, S( 5)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 - \ sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(15)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-3)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/2 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 - \ sqrt(15)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(3)/2)), ((1, 3), (1, 2)) ) == \ 2*sqrt(5)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/ 2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/6 + \ 3*sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-3)/2)), ((1, 3), (1, 2)) ) == \ sqrt(3)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 + \ sqrt(5)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(3)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(3)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 - \ sqrt(5)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S(1)/2, S(3)/ 2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 - \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(30)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 - \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/6 - \ 3*sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(3)/2, S(-3)/2)), ((1, 3), (1, 2)) ) == \ -2*sqrt(5)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3) /2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(3)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/2 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 + \ sqrt(15)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(10)*JzKetCoupled(S(5)/2, S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(1)/2)), ((1, 3), (1, 2)) ) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(1)/2)) )/6 - \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/5 + \ sqrt(30)*JzKetCoupled(S(5)/2, -S( 1)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-1)/2)), ((1, 3), (1, 2)) ) == \ -JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 1), (1, 2, S(3)/2)) )/2 + \ sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(3)/2)) )/10 + \ sqrt(15)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S(1)/2, S( 3)/2), ((1, 3, 2), (1, 2, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(3)/2, S(-3)/2)), ((1, 3), (1, 2)) ) == \ JzKetCoupled(S(5)/2, -S( 5)/2, (S(1)/2, S(1)/2, S(3)/2), ((1, 3, 2), (1, 2, S(5)/2)) ) def test_couple_4_states_numerical(): # Default coupling # j1=1/2, j2=1/2, j3=1/2, j4=1/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(2, 2, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ sqrt(6)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/3 - \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)) )/3 + \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/3 + \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 - \ sqrt(6)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 - \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 0)))/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)))/6 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)))/2 - \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)))/6 + \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)))/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)))/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ -JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)) )/6 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 + \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 - \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 + \ sqrt(6)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 + \ sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 - \ sqrt(6)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 - \ sqrt(3)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ -JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)) )/6 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 - \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)) )/6 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 + \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 - \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ -sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, 1)) )/2 + \ sqrt(6)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/6 + \ sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2))) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 0)) )/3 - \ sqrt(3)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/3 - \ sqrt(6)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2))) == \ -sqrt(6)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, 1)) )/3 + \ sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/6 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2))) == \ -sqrt(3)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2))) == \ JzKetCoupled(2, -2, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, 2)) ) # j1=S(1)/2, S(1)/2, S(1)/2, 1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ JzKetCoupled(S(5)/2, S(5)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/2 + \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1))) == \ sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0))) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 + \ 2*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1))) == \ 2*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ sqrt(3)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 + \ sqrt(6)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1))) == \ -sqrt(3)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 + \ sqrt(6)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1))) == \ sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ -sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/2 - \ sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ -sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 - \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ -sqrt(3)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(6)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1))) == \ sqrt(3)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(6)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0))) == \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 - \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1))) == \ -sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/2 + \ sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/6 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1))) == \ 2*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(1)/2)) )/3 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/3 - \ 2*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1))) == \ -sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(1)/2), (1, 4, S(3)/2)) )/3 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1))) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(1)/2)) )/2 - \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0))) == \ -sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1))) == \ JzKetCoupled(S(5)/2, -S(5)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (1, 3, S(3)/2), (1, 4, S(5)/2)) ) # Couple j1 to j2, j3 to j4 # j1=1/2, j2=1/2, j3=1/2, j4=1/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(2, 2, (S( 1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/3 + \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 0), (1, 3, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/6 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 0), (1, 3, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/6 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, 1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 0), (1, 3, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/6 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 0), (1, 3, 0)) )/2 - \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/6 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 - \ JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 0), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(3)*JzKetCoupled(0, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 0)) )/3 - \ sqrt(2)*JzKetCoupled(1, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ sqrt(6)*JzKetCoupled(2, 0, (S(1)/2, S(1)/2, S(1)/2, S(1)/ 2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/6 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 - \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 0), (1, 3, 1)) )/2 - \ JzKetCoupled(1, -1, (S(1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 1)) )/2 + \ JzKetCoupled(2, -1, (S(1)/2, S( 1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) )/2 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(2, -2, (S( 1)/2, S(1)/2, S(1)/2, S(1)/2), ((1, 2, 1), (3, 4, 1), (1, 3, 2)) ) # j1=S(1)/2, S(1)/2, S(1)/2, 1 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(S(5)/2, S(5)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) ) assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(3)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 2*sqrt(15)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ 2*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 2*sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(6)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 - \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ 4*sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/2 + \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/3 + \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(3)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 + \ sqrt(6)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/30 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(3)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 + \ sqrt(6)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/30 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/3 - \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/2 - \ sqrt(30)*JzKetCoupled(S(3)/2, S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(6)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(3)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/3 + \ JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(5)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(3)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(6)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/6 + \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/30 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(3)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(6)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/30 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(6)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/6 - \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 - \ sqrt(3)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/3 - \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 + \ sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 0), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/2 + \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/10 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(2)*JzKetCoupled(S(1)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/2 - \ sqrt(10)*JzKetCoupled(S(3)/2, S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/5 + \ sqrt(10)*JzKetCoupled(S(5)/2, S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/3 + \ JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 4*sqrt(5)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ sqrt(6)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ sqrt(30)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(5)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 1)), ((1, 2), (3, 4), (1, 3)) ) == \ 2*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(1)/2)) )/3 + \ sqrt(2)*JzKetCoupled(S(1)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(1)/2)) )/6 - \ sqrt(2)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 2*sqrt(10)*JzKetCoupled(S(3)/2, -S(1)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(1)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/10 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, 0)), ((1, 2), (3, 4), (1, 3)) ) == \ -sqrt(3)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(1)/2), (1, 3, S(3)/2)) )/3 - \ 2*sqrt(15)*JzKetCoupled(S(3)/2, -S(3)/2, (S(1)/2, S(1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(3)/2)) )/15 + \ sqrt(10)*JzKetCoupled(S(5)/2, -S(3)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) )/5 assert couple(TensorProduct(JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(S(1)/2, S(-1)/2), JzKet(1, -1)), ((1, 2), (3, 4), (1, 3)) ) == \ JzKetCoupled(S(5)/2, -S(5)/2, (S(1)/2, S( 1)/2, S(1)/2, 1), ((1, 2, 1), (3, 4, S(3)/2), (1, 3, S(5)/2)) ) def test_couple_symbolic(): assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ Sum(CG(j1, m1, j2, m2, j, m1 + m2) * JzKetCoupled(j, m1 + m2, ( j1, j2)), (j, m1 + m2, j1 + j2)) assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3))) == \ Sum(CG(j1, m1, j2, m2, j12, m1 + m2) * CG(j12, m1 + m2, j3, m3, j, m1 + m2 + m3) * JzKetCoupled(j, m1 + m2 + m3, (j1, j2, j3), ((1, 2, j12), (1, 3, j)) ), (j12, m1 + m2, j1 + j2), (j, m1 + m2 + m3, j12 + j3)) assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3)), ((1, 3), (1, 2)) ) == \ Sum(CG(j1, m1, j3, m3, j13, m1 + m3) * CG(j13, m1 + m3, j2, m2, j, m1 + m2 + m3) * JzKetCoupled(j, m1 + m2 + m3, (j1, j2, j3), ((1, 3, j13), (1, 2, j)) ), (j13, m1 + m3, j1 + j3), (j, m1 + m2 + m3, j13 + j2)) assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3), JzKet(j4, m4))) == \ Sum(CG(j1, m1, j2, m2, j12, m1 + m2) * CG(j12, m1 + m2, j3, m3, j123, m1 + m2 + m3) * CG(j123, m1 + m2 + m3, j4, m4, j, m1 + m2 + m3 + m4) * JzKetCoupled(j, m1 + m2 + m3 + m4, ( j1, j2, j3, j4), ((1, 2, j12), (1, 3, j123), (1, 4, j)) ), (j12, m1 + m2, j1 + j2), (j123, m1 + m2 + m3, j12 + j3), (j, m1 + m2 + m3 + m4, j123 + j4)) assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3), JzKet(j4, m4)), ((1, 2), (3, 4), (1, 3)) ) == \ Sum(CG(j1, m1, j2, m2, j12, m1 + m2) * CG(j3, m3, j4, m4, j34, m3 + m4) * CG(j12, m1 + m2, j34, m3 + m4, j, m1 + m2 + m3 + m4) * JzKetCoupled(j, m1 + m2 + m3 + m4, ( j1, j2, j3, j4), ((1, 2, j12), (3, 4, j34), (1, 3, j)) ), (j12, m1 + m2, j1 + j2), (j34, m3 + m4, j3 + j4), (j, m1 + m2 + m3 + m4, j12 + j34)) assert couple(TensorProduct(JzKet(j1, m1), JzKet(j2, m2), JzKet(j3, m3), JzKet(j4, m4)), ((1, 3), (1, 4), (1, 2)) ) == \ Sum(CG(j1, m1, j3, m3, j13, m1 + m3) * CG(j13, m1 + m3, j4, m4, j134, m1 + m3 + m4) * CG(j134, m1 + m3 + m4, j2, m2, j, m1 + m2 + m3 + m4) * JzKetCoupled(j, m1 + m2 + m3 + m4, ( j1, j2, j3, j4), ((1, 3, j13), (1, 4, j134), (1, 2, j)) ), (j13, m1 + m3, j1 + j3), (j134, m1 + m3 + m4, j13 + j4), (j, m1 + m2 + m3 + m4, j134 + j2)) def test_innerproduct(): assert InnerProduct(JzBra(1, 1), JzKet(1, 1)).doit() == 1 assert InnerProduct( JzBra(S(1)/2, S(1)/2), JzKet(S(1)/2, -S(1)/2)).doit() == 0 assert InnerProduct(JzBra(j, m), JzKet(j, m)).doit() == 1 assert InnerProduct(JzBra(1, 0), JyKet(1, 1)).doit() == I/sqrt(2) assert InnerProduct( JxBra(S(1)/2, S(1)/2), JzKet(S(1)/2, S(1)/2)).doit() == -sqrt(2)/2 assert InnerProduct(JyBra(1, 1), JzKet(1, 1)).doit() == S(1)/2 assert InnerProduct(JxBra(1, -1), JyKet(1, 1)).doit() == 0 def test_rotation_small_d(): # Symbolic tests # j = 1/2 assert Rotation.d(S(1)/2, S(1)/2, S(1)/2, beta).doit() == cos(beta/2) assert Rotation.d(S(1)/2, S(1)/2, -S(1)/2, beta).doit() == -sin(beta/2) assert Rotation.d(S(1)/2, -S(1)/2, S(1)/2, beta).doit() == sin(beta/2) assert Rotation.d(S(1)/2, -S(1)/2, -S(1)/2, beta).doit() == cos(beta/2) # j = 1 assert Rotation.d(1, 1, 1, beta).doit() == (1 + cos(beta))/2 assert Rotation.d(1, 1, 0, beta).doit() == -sin(beta)/sqrt(2) assert Rotation.d(1, 1, -1, beta).doit() == (1 - cos(beta))/2 assert Rotation.d(1, 0, 1, beta).doit() == sin(beta)/sqrt(2) assert Rotation.d(1, 0, 0, beta).doit() == cos(beta) assert Rotation.d(1, 0, -1, beta).doit() == -sin(beta)/sqrt(2) assert Rotation.d(1, -1, 1, beta).doit() == (1 - cos(beta))/2 assert Rotation.d(1, -1, 0, beta).doit() == sin(beta)/sqrt(2) assert Rotation.d(1, -1, -1, beta).doit() == (1 + cos(beta))/2 # j = 3/2 assert Rotation.d(S( 3)/2, S(3)/2, S(3)/2, beta).doit() == (3*cos(beta/2) + cos(3*beta/2))/4 assert Rotation.d(S(3)/2, S( 3)/2, S(1)/2, beta).doit() == -sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4 assert Rotation.d(S(3)/2, S( 3)/2, -S(1)/2, beta).doit() == sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4 assert Rotation.d(S(3)/2, S( 3)/2, -S(3)/2, beta).doit() == (-3*sin(beta/2) + sin(3*beta/2))/4 assert Rotation.d(S(3)/2, S( 1)/2, S(3)/2, beta).doit() == sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4 assert Rotation.d(S( 3)/2, S(1)/2, S(1)/2, beta).doit() == (cos(beta/2) + 3*cos(3*beta/2))/4 assert Rotation.d(S( 3)/2, S(1)/2, -S(1)/2, beta).doit() == (sin(beta/2) - 3*sin(3*beta/2))/4 assert Rotation.d(S(3)/2, S( 1)/2, -S(3)/2, beta).doit() == sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 1)/2, S(3)/2, beta).doit() == sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 1)/2, S(1)/2, beta).doit() == (-sin(beta/2) + 3*sin(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 1)/2, -S(1)/2, beta).doit() == (cos(beta/2) + 3*cos(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 1)/2, -S(3)/2, beta).doit() == -sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4 assert Rotation.d(S( 3)/2, -S(3)/2, S(3)/2, beta).doit() == (3*sin(beta/2) - sin(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 3)/2, S(1)/2, beta).doit() == sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 3)/2, -S(1)/2, beta).doit() == sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4 assert Rotation.d(S(3)/2, -S( 3)/2, -S(3)/2, beta).doit() == (3*cos(beta/2) + cos(3*beta/2))/4 # j = 2 assert Rotation.d(2, 2, 2, beta).doit() == (3 + 4*cos(beta) + cos(2*beta))/8 assert Rotation.d(2, 2, 1, beta).doit() == -((cos(beta) + 1)*sin(beta))/2 assert Rotation.d(2, 2, 0, beta).doit() == sqrt(6)*sin(beta)**2/4 assert Rotation.d(2, 2, -1, beta).doit() == (cos(beta) - 1)*sin(beta)/2 assert Rotation.d(2, 2, -2, beta).doit() == (3 - 4*cos(beta) + cos(2*beta))/8 assert Rotation.d(2, 1, 2, beta).doit() == (cos(beta) + 1)*sin(beta)/2 assert Rotation.d(2, 1, 1, beta).doit() == (cos(beta) + cos(2*beta))/2 assert Rotation.d(2, 1, 0, beta).doit() == -sqrt(6)*sin(2*beta)/4 assert Rotation.d(2, 1, -1, beta).doit() == (cos(beta) - cos(2*beta))/2 assert Rotation.d(2, 1, -2, beta).doit() == (cos(beta) - 1)*sin(beta)/2 assert Rotation.d(2, 0, 2, beta).doit() == sqrt(6)*sin(beta)**2/4 assert Rotation.d(2, 0, 1, beta).doit() == sqrt(6)*sin(2*beta)/4 assert Rotation.d(2, 0, 0, beta).doit() == (1 + 3*cos(2*beta))/4 assert Rotation.d(2, 0, -1, beta).doit() == -sqrt(6)*sin(2*beta)/4 assert Rotation.d(2, 0, -2, beta).doit() == sqrt(6)*sin(beta)**2/4 assert Rotation.d(2, -1, 2, beta).doit() == (2*sin(beta) - sin(2*beta))/4 assert Rotation.d(2, -1, 1, beta).doit() == (cos(beta) - cos(2*beta))/2 assert Rotation.d(2, -1, 0, beta).doit() == sqrt(6)*sin(2*beta)/4 assert Rotation.d(2, -1, -1, beta).doit() == (cos(beta) + cos(2*beta))/2 assert Rotation.d(2, -1, -2, beta).doit() == -((cos(beta) + 1)*sin(beta))/2 assert Rotation.d(2, -2, 2, beta).doit() == (3 - 4*cos(beta) + cos(2*beta))/8 assert Rotation.d(2, -2, 1, beta).doit() == (2*sin(beta) - sin(2*beta))/4 assert Rotation.d(2, -2, 0, beta).doit() == sqrt(6)*sin(beta)**2/4 assert Rotation.d(2, -2, -1, beta).doit() == (cos(beta) + 1)*sin(beta)/2 assert Rotation.d(2, -2, -2, beta).doit() == (3 + 4*cos(beta) + cos(2*beta))/8 # Numerical tests # j = 1/2 assert Rotation.d(S(1)/2, S(1)/2, S(1)/2, pi/2).doit() == sqrt(2)/2 assert Rotation.d(S(1)/2, S(1)/2, -S(1)/2, pi/2).doit() == -sqrt(2)/2 assert Rotation.d(S(1)/2, -S(1)/2, S(1)/2, pi/2).doit() == sqrt(2)/2 assert Rotation.d(S(1)/2, -S(1)/2, -S(1)/2, pi/2).doit() == sqrt(2)/2 # j = 1 assert Rotation.d(1, 1, 1, pi/2).doit() == 1/2 assert Rotation.d(1, 1, 0, pi/2).doit() == -sqrt(2)/2 assert Rotation.d(1, 1, -1, pi/2).doit() == 1/2 assert Rotation.d(1, 0, 1, pi/2).doit() == sqrt(2)/2 assert Rotation.d(1, 0, 0, pi/2).doit() == 0 assert Rotation.d(1, 0, -1, pi/2).doit() == -sqrt(2)/2 assert Rotation.d(1, -1, 1, pi/2).doit() == 1/2 assert Rotation.d(1, -1, 0, pi/2).doit() == sqrt(2)/2 assert Rotation.d(1, -1, -1, pi/2).doit() == 1/2 # j = 3/2 assert Rotation.d(S(3)/2, S(3)/2, S(3)/2, pi/2).doit() == sqrt(2)/4 assert Rotation.d(S(3)/2, S(3)/2, S(1)/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.d(S(3)/2, S(3)/2, -S(1)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, S(3)/2, -S(3)/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.d(S(3)/2, S(1)/2, S(3)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, S(1)/2, S(1)/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.d(S(3)/2, S(1)/2, -S(1)/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.d(S(3)/2, S(1)/2, -S(3)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, -S(1)/2, S(3)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, -S(1)/2, S(1)/2, pi/2).doit() == sqrt(2)/4 assert Rotation.d(S(3)/2, -S(1)/2, -S(1)/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.d(S(3)/2, -S(1)/2, -S(3)/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.d(S(3)/2, -S(3)/2, S(3)/2, pi/2).doit() == sqrt(2)/4 assert Rotation.d(S(3)/2, -S(3)/2, S(1)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, -S(3)/2, -S(1)/2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(S(3)/2, -S(3)/2, -S(3)/2, pi/2).doit() == sqrt(2)/4 # j = 2 assert Rotation.d(2, 2, 2, pi/2).doit() == 1/4 assert Rotation.d(2, 2, 1, pi/2).doit() == -1/2 assert Rotation.d(2, 2, 0, pi/2).doit() == sqrt(6)/4 assert Rotation.d(2, 2, -1, pi/2).doit() == -1/2 assert Rotation.d(2, 2, -2, pi/2).doit() == 1/4 assert Rotation.d(2, 1, 2, pi/2).doit() == 1/2 assert Rotation.d(2, 1, 1, pi/2).doit() == -1/2 assert Rotation.d(2, 1, 0, pi/2).doit() == 0 assert Rotation.d(2, 1, -1, pi/2).doit() == 1/2 assert Rotation.d(2, 1, -2, pi/2).doit() == -1/2 assert Rotation.d(2, 0, 2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(2, 0, 1, pi/2).doit() == 0 assert Rotation.d(2, 0, 0, pi/2).doit() == -1/2 assert Rotation.d(2, 0, -1, pi/2).doit() == 0 assert Rotation.d(2, 0, -2, pi/2).doit() == sqrt(6)/4 assert Rotation.d(2, -1, 2, pi/2).doit() == 1/2 assert Rotation.d(2, -1, 1, pi/2).doit() == 1/2 assert Rotation.d(2, -1, 0, pi/2).doit() == 0 assert Rotation.d(2, -1, -1, pi/2).doit() == -1/2 assert Rotation.d(2, -1, -2, pi/2).doit() == -1/2 assert Rotation.d(2, -2, 2, pi/2).doit() == 1/4 assert Rotation.d(2, -2, 1, pi/2).doit() == 1/2 assert Rotation.d(2, -2, 0, pi/2).doit() == sqrt(6)/4 assert Rotation.d(2, -2, -1, pi/2).doit() == 1/2 assert Rotation.d(2, -2, -2, pi/2).doit() == 1/4 def test_rotation_d(): # Symbolic tests # j = 1/2 assert Rotation.D(S(1)/2, S(1)/2, S(1)/2, alpha, beta, gamma).doit() == \ cos(beta/2)*exp(-I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(1)/2, S(1)/2, -S(1)/2, alpha, beta, gamma).doit() == \ -sin(beta/2)*exp(-I*alpha/2)*exp(I*gamma/2) assert Rotation.D(S(1)/2, -S(1)/2, S(1)/2, alpha, beta, gamma).doit() == \ sin(beta/2)*exp(I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(1)/2, -S(1)/2, -S(1)/2, alpha, beta, gamma).doit() == \ cos(beta/2)*exp(I*alpha/2)*exp(I*gamma/2) # j = 1 assert Rotation.D(1, 1, 1, alpha, beta, gamma).doit() == \ (1 + cos(beta))/2*exp(-I*alpha)*exp(-I*gamma) assert Rotation.D(1, 1, 0, alpha, beta, gamma).doit() == -sin( beta)/sqrt(2)*exp(-I*alpha) assert Rotation.D(1, 1, -1, alpha, beta, gamma).doit() == \ (1 - cos(beta))/2*exp(-I*alpha)*exp(I*gamma) assert Rotation.D(1, 0, 1, alpha, beta, gamma).doit() == \ sin(beta)/sqrt(2)*exp(-I*gamma) assert Rotation.D(1, 0, 0, alpha, beta, gamma).doit() == cos(beta) assert Rotation.D(1, 0, -1, alpha, beta, gamma).doit() == \ -sin(beta)/sqrt(2)*exp(I*gamma) assert Rotation.D(1, -1, 1, alpha, beta, gamma).doit() == \ (1 - cos(beta))/2*exp(I*alpha)*exp(-I*gamma) assert Rotation.D(1, -1, 0, alpha, beta, gamma).doit() == \ sin(beta)/sqrt(2)*exp(I*alpha) assert Rotation.D(1, -1, -1, alpha, beta, gamma).doit() == \ (1 + cos(beta))/2*exp(I*alpha)*exp(I*gamma) # j = 3/2 assert Rotation.D(S(3)/2, S(3)/2, S(3)/2, alpha, beta, gamma).doit() == \ (3*cos(beta/2) + cos(3*beta/2))/4*exp(-3*I*alpha/2)*exp(-3*I*gamma/2) assert Rotation.D(S(3)/2, S(3)/2, S(1)/2, alpha, beta, gamma).doit() == \ -sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4*exp(-3*I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(3)/2, S(3)/2, -S(1)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4*exp(-3*I*alpha/2)*exp(I*gamma/2) assert Rotation.D(S(3)/2, S(3)/2, -S(3)/2, alpha, beta, gamma).doit() == \ (-3*sin(beta/2) + sin(3*beta/2))/4*exp(-3*I*alpha/2)*exp(3*I*gamma/2) assert Rotation.D(S(3)/2, S(1)/2, S(3)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4*exp(-I*alpha/2)*exp(-3*I*gamma/2) assert Rotation.D(S(3)/2, S(1)/2, S(1)/2, alpha, beta, gamma).doit() == \ (cos(beta/2) + 3*cos(3*beta/2))/4*exp(-I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(3)/2, S(1)/2, -S(1)/2, alpha, beta, gamma).doit() == \ (sin(beta/2) - 3*sin(3*beta/2))/4*exp(-I*alpha/2)*exp(I*gamma/2) assert Rotation.D(S(3)/2, S(1)/2, -S(3)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4*exp(-I*alpha/2)*exp(3*I*gamma/2) assert Rotation.D(S(3)/2, -S(1)/2, S(3)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4*exp(I*alpha/2)*exp(-3*I*gamma/2) assert Rotation.D(S(3)/2, -S(1)/2, S(1)/2, alpha, beta, gamma).doit() == \ (-sin(beta/2) + 3*sin(3*beta/2))/4*exp(I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(3)/2, -S(1)/2, -S(1)/2, alpha, beta, gamma).doit() == \ (cos(beta/2) + 3*cos(3*beta/2))/4*exp(I*alpha/2)*exp(I*gamma/2) assert Rotation.D(S(3)/2, -S(1)/2, -S(3)/2, alpha, beta, gamma).doit() == \ -sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4*exp(I*alpha/2)*exp(3*I*gamma/2) assert Rotation.D(S(3)/2, -S(3)/2, S(3)/2, alpha, beta, gamma).doit() == \ (3*sin(beta/2) - sin(3*beta/2))/4*exp(3*I*alpha/2)*exp(-3*I*gamma/2) assert Rotation.D(S(3)/2, -S(3)/2, S(1)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(cos(beta/2) - cos(3*beta/2))/4*exp(3*I*alpha/2)*exp(-I*gamma/2) assert Rotation.D(S(3)/2, -S(3)/2, -S(1)/2, alpha, beta, gamma).doit() == \ sqrt(3)*(sin(beta/2) + sin(3*beta/2))/4*exp(3*I*alpha/2)*exp(I*gamma/2) assert Rotation.D(S(3)/2, -S(3)/2, -S(3)/2, alpha, beta, gamma).doit() == \ (3*cos(beta/2) + cos(3*beta/2))/4*exp(3*I*alpha/2)*exp(3*I*gamma/2) # j = 2 assert Rotation.D(2, 2, 2, alpha, beta, gamma).doit() == \ (3 + 4*cos(beta) + cos(2*beta))/8*exp(-2*I*alpha)*exp(-2*I*gamma) assert Rotation.D(2, 2, 1, alpha, beta, gamma).doit() == \ -((cos(beta) + 1)*exp(-2*I*alpha)*exp(-I*gamma)*sin(beta))/2 assert Rotation.D(2, 2, 0, alpha, beta, gamma).doit() == \ sqrt(6)*sin(beta)**2/4*exp(-2*I*alpha) assert Rotation.D(2, 2, -1, alpha, beta, gamma).doit() == \ (cos(beta) - 1)*sin(beta)/2*exp(-2*I*alpha)*exp(I*gamma) assert Rotation.D(2, 2, -2, alpha, beta, gamma).doit() == \ (3 - 4*cos(beta) + cos(2*beta))/8*exp(-2*I*alpha)*exp(2*I*gamma) assert Rotation.D(2, 1, 2, alpha, beta, gamma).doit() == \ (cos(beta) + 1)*sin(beta)/2*exp(-I*alpha)*exp(-2*I*gamma) assert Rotation.D(2, 1, 1, alpha, beta, gamma).doit() == \ (cos(beta) + cos(2*beta))/2*exp(-I*alpha)*exp(-I*gamma) assert Rotation.D(2, 1, 0, alpha, beta, gamma).doit() == -sqrt(6)* \ sin(2*beta)/4*exp(-I*alpha) assert Rotation.D(2, 1, -1, alpha, beta, gamma).doit() == \ (cos(beta) - cos(2*beta))/2*exp(-I*alpha)*exp(I*gamma) assert Rotation.D(2, 1, -2, alpha, beta, gamma).doit() == \ (cos(beta) - 1)*sin(beta)/2*exp(-I*alpha)*exp(2*I*gamma) assert Rotation.D(2, 0, 2, alpha, beta, gamma).doit() == \ sqrt(6)*sin(beta)**2/4*exp(-2*I*gamma) assert Rotation.D(2, 0, 1, alpha, beta, gamma).doit() == sqrt(6)* \ sin(2*beta)/4*exp(-I*gamma) assert Rotation.D( 2, 0, 0, alpha, beta, gamma).doit() == (1 + 3*cos(2*beta))/4 assert Rotation.D(2, 0, -1, alpha, beta, gamma).doit() == -sqrt(6)* \ sin(2*beta)/4*exp(I*gamma) assert Rotation.D(2, 0, -2, alpha, beta, gamma).doit() == \ sqrt(6)*sin(beta)**2/4*exp(2*I*gamma) assert Rotation.D(2, -1, 2, alpha, beta, gamma).doit() == \ (2*sin(beta) - sin(2*beta))/4*exp(I*alpha)*exp(-2*I*gamma) assert Rotation.D(2, -1, 1, alpha, beta, gamma).doit() == \ (cos(beta) - cos(2*beta))/2*exp(I*alpha)*exp(-I*gamma) assert Rotation.D(2, -1, 0, alpha, beta, gamma).doit() == sqrt(6)* \ sin(2*beta)/4*exp(I*alpha) assert Rotation.D(2, -1, -1, alpha, beta, gamma).doit() == \ (cos(beta) + cos(2*beta))/2*exp(I*alpha)*exp(I*gamma) assert Rotation.D(2, -1, -2, alpha, beta, gamma).doit() == \ -((cos(beta) + 1)*sin(beta))/2*exp(I*alpha)*exp(2*I*gamma) assert Rotation.D(2, -2, 2, alpha, beta, gamma).doit() == \ (3 - 4*cos(beta) + cos(2*beta))/8*exp(2*I*alpha)*exp(-2*I*gamma) assert Rotation.D(2, -2, 1, alpha, beta, gamma).doit() == \ (2*sin(beta) - sin(2*beta))/4*exp(2*I*alpha)*exp(-I*gamma) assert Rotation.D(2, -2, 0, alpha, beta, gamma).doit() == \ sqrt(6)*sin(beta)**2/4*exp(2*I*alpha) assert Rotation.D(2, -2, -1, alpha, beta, gamma).doit() == \ (cos(beta) + 1)*sin(beta)/2*exp(2*I*alpha)*exp(I*gamma) assert Rotation.D(2, -2, -2, alpha, beta, gamma).doit() == \ (3 + 4*cos(beta) + cos(2*beta))/8*exp(2*I*alpha)*exp(2*I*gamma) # Numerical tests # j = 1/2 assert Rotation.D( S(1)/2, S(1)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == -I*sqrt(2)/2 assert Rotation.D( S(1)/2, S(1)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == -sqrt(2)/2 assert Rotation.D( S(1)/2, -S(1)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == sqrt(2)/2 assert Rotation.D( S(1)/2, -S(1)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == I*sqrt(2)/2 # j = 1 assert Rotation.D(1, 1, 1, pi/2, pi/2, pi/2).doit() == -1/2 assert Rotation.D(1, 1, 0, pi/2, pi/2, pi/2).doit() == I*sqrt(2)/2 assert Rotation.D(1, 1, -1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(1, 0, 1, pi/2, pi/2, pi/2).doit() == -I*sqrt(2)/2 assert Rotation.D(1, 0, 0, pi/2, pi/2, pi/2).doit() == 0 assert Rotation.D(1, 0, -1, pi/2, pi/2, pi/2).doit() == -I*sqrt(2)/2 assert Rotation.D(1, -1, 1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(1, -1, 0, pi/2, pi/2, pi/2).doit() == I*sqrt(2)/2 assert Rotation.D(1, -1, -1, pi/2, pi/2, pi/2).doit() == -1/2 # j = 3/2 assert Rotation.D( S(3)/2, S(3)/2, S(3)/2, pi/2, pi/2, pi/2).doit() == I*sqrt(2)/4 assert Rotation.D( S(3)/2, S(3)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == sqrt(6)/4 assert Rotation.D( S(3)/2, S(3)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == -I*sqrt(6)/4 assert Rotation.D( S(3)/2, S(3)/2, -S(3)/2, pi/2, pi/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.D( S(3)/2, S(1)/2, S(3)/2, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D( S(3)/2, S(1)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == I*sqrt(2)/4 assert Rotation.D( S(3)/2, S(1)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == -sqrt(2)/4 assert Rotation.D( S(3)/2, S(1)/2, -S(3)/2, pi/2, pi/2, pi/2).doit() == I*sqrt(6)/4 assert Rotation.D( S(3)/2, -S(1)/2, S(3)/2, pi/2, pi/2, pi/2).doit() == -I*sqrt(6)/4 assert Rotation.D( S(3)/2, -S(1)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == sqrt(2)/4 assert Rotation.D( S(3)/2, -S(1)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == -I*sqrt(2)/4 assert Rotation.D( S(3)/2, -S(1)/2, -S(3)/2, pi/2, pi/2, pi/2).doit() == sqrt(6)/4 assert Rotation.D( S(3)/2, -S(3)/2, S(3)/2, pi/2, pi/2, pi/2).doit() == sqrt(2)/4 assert Rotation.D( S(3)/2, -S(3)/2, S(1)/2, pi/2, pi/2, pi/2).doit() == I*sqrt(6)/4 assert Rotation.D( S(3)/2, -S(3)/2, -S(1)/2, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D( S(3)/2, -S(3)/2, -S(3)/2, pi/2, pi/2, pi/2).doit() == -I*sqrt(2)/4 # j = 2 assert Rotation.D(2, 2, 2, pi/2, pi/2, pi/2).doit() == 1/4 assert Rotation.D(2, 2, 1, pi/2, pi/2, pi/2).doit() == -I/2 assert Rotation.D(2, 2, 0, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D(2, 2, -1, pi/2, pi/2, pi/2).doit() == I/2 assert Rotation.D(2, 2, -2, pi/2, pi/2, pi/2).doit() == 1/4 assert Rotation.D(2, 1, 2, pi/2, pi/2, pi/2).doit() == I/2 assert Rotation.D(2, 1, 1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(2, 1, 0, pi/2, pi/2, pi/2).doit() == 0 assert Rotation.D(2, 1, -1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(2, 1, -2, pi/2, pi/2, pi/2).doit() == -I/2 assert Rotation.D(2, 0, 2, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D(2, 0, 1, pi/2, pi/2, pi/2).doit() == 0 assert Rotation.D(2, 0, 0, pi/2, pi/2, pi/2).doit() == -1/2 assert Rotation.D(2, 0, -1, pi/2, pi/2, pi/2).doit() == 0 assert Rotation.D(2, 0, -2, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D(2, -1, 2, pi/2, pi/2, pi/2).doit() == -I/2 assert Rotation.D(2, -1, 1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(2, -1, 0, pi/2, pi/2, pi/2).doit() == 0 assert Rotation.D(2, -1, -1, pi/2, pi/2, pi/2).doit() == 1/2 assert Rotation.D(2, -1, -2, pi/2, pi/2, pi/2).doit() == I/2 assert Rotation.D(2, -2, 2, pi/2, pi/2, pi/2).doit() == 1/4 assert Rotation.D(2, -2, 1, pi/2, pi/2, pi/2).doit() == I/2 assert Rotation.D(2, -2, 0, pi/2, pi/2, pi/2).doit() == -sqrt(6)/4 assert Rotation.D(2, -2, -1, pi/2, pi/2, pi/2).doit() == -I/2 assert Rotation.D(2, -2, -2, pi/2, pi/2, pi/2).doit() == 1/4 def test_wignerd(): assert Rotation.D( j, m, mp, alpha, beta, gamma) == WignerD(j, m, mp, alpha, beta, gamma) assert Rotation.d(j, m, mp, beta) == WignerD(j, m, mp, 0, beta, 0) def test_jplus(): assert Commutator(Jplus, Jminus).doit() == 2*hbar*Jz assert Jplus.matrix_element(1, 1, 1, 1) == 0 assert Jplus.rewrite('xyz') == Jx + I*Jy # Normal operators, normal states # Numerical assert qapply(Jplus*JxKet(1, 1)) == \ -hbar*sqrt(2)*JxKet(1, 0)/2 + hbar*JxKet(1, 1) assert qapply(Jplus*JyKet(1, 1)) == \ hbar*sqrt(2)*JyKet(1, 0)/2 + I*hbar*JyKet(1, 1) assert qapply(Jplus*JzKet(1, 1)) == 0 # Symbolic assert qapply(Jplus*JxKet(j, m)) == \ Sum(hbar * sqrt(-mi**2 - mi + j**2 + j) * WignerD(j, mi, m, 0, pi/2, 0) * Sum(WignerD(j, mi1, mi + 1, 0, 3*pi/2, 0) * JxKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jplus*JyKet(j, m)) == \ Sum(hbar * sqrt(j**2 + j - mi**2 - mi) * WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j, mi1, mi + 1, 3*pi/2, pi/2, pi/2) * JyKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jplus*JzKet(j, m)) == \ hbar*sqrt(j**2 + j - m**2 - m)*JzKet(j, m + 1) # Normal operators, coupled states # Numerical assert qapply(Jplus*JxKetCoupled(1, 1, (1, 1))) == -hbar*sqrt(2) * \ JxKetCoupled(1, 0, (1, 1))/2 + hbar*JxKetCoupled(1, 1, (1, 1)) assert qapply(Jplus*JyKetCoupled(1, 1, (1, 1))) == hbar*sqrt(2) * \ JyKetCoupled(1, 0, (1, 1))/2 + I*hbar*JyKetCoupled(1, 1, (1, 1)) assert qapply(Jplus*JzKet(1, 1)) == 0 # Symbolic assert qapply(Jplus*JxKetCoupled(j, m, (j1, j2))) == \ Sum(hbar * sqrt(-mi**2 - mi + j**2 + j) * WignerD(j, mi, m, 0, pi/2, 0) * Sum( WignerD( j, mi1, mi + 1, 0, 3*pi/2, 0) * JxKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jplus*JyKetCoupled(j, m, (j1, j2))) == \ Sum(hbar * sqrt(j**2 + j - mi**2 - mi) * WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * Sum( WignerD(j, mi1, mi + 1, 3*pi/2, pi/2, pi/2) * JyKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jplus*JzKetCoupled(j, m, (j1, j2))) == \ hbar*sqrt(j**2 + j - m**2 - m)*JzKetCoupled(j, m + 1, (j1, j2)) # Uncoupled operators, uncoupled states # Numerical assert qapply(TensorProduct(Jplus, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -hbar*sqrt(2)*TensorProduct(JxKet(1, 0), JxKet(1, -1))/2 + \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(1, Jplus)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) + \ hbar*sqrt(2)*TensorProduct(JxKet(1, 1), JxKet(1, 0))/2 assert qapply(TensorProduct(Jplus, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JyKet(1, 0), JyKet(1, -1))/2 + \ hbar*I*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(1, Jplus)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ -hbar*I*TensorProduct(JyKet(1, 1), JyKet(1, -1)) + \ hbar*sqrt(2)*TensorProduct(JyKet(1, 1), JyKet(1, 0))/2 assert qapply( TensorProduct(Jplus, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == 0 assert qapply(TensorProduct(1, Jplus)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 0)) # Symbolic assert qapply(TensorProduct(Jplus, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(Sum(hbar * sqrt(-mi**2 - mi + j1**2 + j1) * WignerD(j1, mi, m1, 0, pi/2, 0) * Sum(WignerD(j1, mi1, mi + 1, 0, 3*pi/2, 0) * JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(TensorProduct(1, Jplus)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar * sqrt(-mi**2 - mi + j2**2 + j2) * WignerD(j2, mi, m2, 0, pi/2, 0) * Sum(WignerD(j2, mi1, mi + 1, 0, 3*pi/2, 0) * JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jplus, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(Sum(hbar * sqrt(j1**2 + j1 - mi**2 - mi) * WignerD(j1, mi, m1, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j1, mi1, mi + 1, 3*pi/2, pi/2, pi/2) * JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) assert qapply(TensorProduct(1, Jplus)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(JyKet(j1, m1), Sum(hbar * sqrt(j2**2 + j2 - mi**2 - mi) * WignerD(j2, mi, m2, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j2, mi1, mi + 1, 3*pi/2, pi/2, pi/2) * JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jplus, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt( j1**2 + j1 - m1**2 - m1)*TensorProduct(JzKet(j1, m1 + 1), JzKet(j2, m2)) assert qapply(TensorProduct(1, Jplus)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt( j2**2 + j2 - m2**2 - m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 + 1)) def test_jminus(): assert qapply(Jminus*JzKet(1, -1)) == 0 assert Jminus.matrix_element(1, 0, 1, 1) == sqrt(2)*hbar assert Jminus.rewrite('xyz') == Jx - I*Jy # Normal operators, normal states # Numerical assert qapply(Jminus*JxKet(1, 1)) == \ hbar*sqrt(2)*JxKet(1, 0)/2 + hbar*JxKet(1, 1) assert qapply(Jminus*JyKet(1, 1)) == \ hbar*sqrt(2)*JyKet(1, 0)/2 - hbar*I*JyKet(1, 1) assert qapply(Jminus*JzKet(1, 1)) == sqrt(2)*hbar*JzKet(1, 0) # Symbolic assert qapply(Jminus*JxKet(j, m)) == \ Sum(hbar*sqrt(j**2 + j - mi**2 + mi)*WignerD(j, mi, m, 0, pi/2, 0) * Sum(WignerD(j, mi1, mi - 1, 0, 3*pi/2, 0)*JxKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jminus*JyKet(j, m)) == \ Sum(hbar*sqrt(j**2 + j - mi**2 + mi)*WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j, mi1, mi - 1, 3*pi/2, pi/2, pi/2)*JyKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jminus*JzKet(j, m)) == \ hbar*sqrt(j**2 + j - m**2 + m)*JzKet(j, m - 1) # Normal operators, coupled states # Numerical assert qapply(Jminus*JxKetCoupled(1, 1, (1, 1))) == \ hbar*sqrt(2)*JxKetCoupled(1, 0, (1, 1))/2 + \ hbar*JxKetCoupled(1, 1, (1, 1)) assert qapply(Jminus*JyKetCoupled(1, 1, (1, 1))) == \ hbar*sqrt(2)*JyKetCoupled(1, 0, (1, 1))/2 - \ hbar*I*JyKetCoupled(1, 1, (1, 1)) assert qapply(Jminus*JzKetCoupled(1, 1, (1, 1))) == \ sqrt(2)*hbar*JzKetCoupled(1, 0, (1, 1)) # Symbolic assert qapply(Jminus*JxKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*sqrt(j**2 + j - mi**2 + mi)*WignerD(j, mi, m, 0, pi/2, 0) * Sum(WignerD(j, mi1, mi - 1, 0, 3*pi/2, 0)*JxKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jminus*JyKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*sqrt(j**2 + j - mi**2 + mi)*WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2) * Sum( WignerD(j, mi1, mi - 1, 3*pi/2, pi/2, pi/2)* JyKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jminus*JzKetCoupled(j, m, (j1, j2))) == \ hbar*sqrt(j**2 + j - m**2 + m)*JzKetCoupled(j, m - 1, (j1, j2)) # Uncoupled operators, uncoupled states # Numerical assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JxKet(1, 0), JxKet(1, -1))/2 + \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(1, Jminus)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) - \ hbar*sqrt(2)*TensorProduct(JxKet(1, 1), JxKet(1, 0))/2 assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JyKet(1, 0), JyKet(1, -1))/2 - \ hbar*I*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(1, Jminus)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ hbar*I*TensorProduct(JyKet(1, 1), JyKet(1, -1)) + \ hbar*sqrt(2)*TensorProduct(JyKet(1, 1), JyKet(1, 0))/2 assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ sqrt(2)*hbar*TensorProduct(JzKet(1, 0), JzKet(1, -1)) assert qapply(TensorProduct( 1, Jminus)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == 0 # Symbolic assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(Sum(hbar*sqrt(j1**2 + j1 - mi**2 + mi)*WignerD(j1, mi, m1, 0, pi/2, 0) * Sum(WignerD(j1, mi1, mi - 1, 0, 3*pi/2, 0)*JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(TensorProduct(1, Jminus)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar*sqrt(j2**2 + j2 - mi**2 + mi)*WignerD(j2, mi, m2, 0, pi/2, 0) * Sum(WignerD(j2, mi1, mi - 1, 0, 3*pi/2, 0)*JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(Sum(hbar*sqrt(j1**2 + j1 - mi**2 + mi)*WignerD(j1, mi, m1, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j1, mi1, mi - 1, 3*pi/2, pi/2, pi/2)*JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) assert qapply(TensorProduct(1, Jminus)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(JyKet(j1, m1), Sum(hbar*sqrt(j2**2 + j2 - mi**2 + mi)*WignerD(j2, mi, m2, 3*pi/2, -pi/2, pi/2) * Sum(WignerD(j2, mi1, mi - 1, 3*pi/2, pi/2, pi/2)*JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jminus, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt( j1**2 + j1 - m1**2 + m1)*TensorProduct(JzKet(j1, m1 - 1), JzKet(j2, m2)) assert qapply(TensorProduct(1, Jminus)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt( j2**2 + j2 - m2**2 + m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 - 1)) def test_j2(): assert Commutator(J2, Jz).doit() == 0 assert J2.matrix_element(1, 1, 1, 1) == 2*hbar**2 # Normal operators, normal states # Numerical assert qapply(J2*JxKet(1, 1)) == 2*hbar**2*JxKet(1, 1) assert qapply(J2*JyKet(1, 1)) == 2*hbar**2*JyKet(1, 1) assert qapply(J2*JzKet(1, 1)) == 2*hbar**2*JzKet(1, 1) # Symbolic assert qapply(J2*JxKet(j, m)) == \ hbar**2*j**2*JxKet(j, m) + hbar**2*j*JxKet(j, m) assert qapply(J2*JyKet(j, m)) == \ hbar**2*j**2*JyKet(j, m) + hbar**2*j*JyKet(j, m) assert qapply(J2*JzKet(j, m)) == \ hbar**2*j**2*JzKet(j, m) + hbar**2*j*JzKet(j, m) # Normal operators, coupled states # Numerical assert qapply(J2*JxKetCoupled(1, 1, (1, 1))) == \ 2*hbar**2*JxKetCoupled(1, 1, (1, 1)) assert qapply(J2*JyKetCoupled(1, 1, (1, 1))) == \ 2*hbar**2*JyKetCoupled(1, 1, (1, 1)) assert qapply(J2*JzKetCoupled(1, 1, (1, 1))) == \ 2*hbar**2*JzKetCoupled(1, 1, (1, 1)) # Symbolic assert qapply(J2*JxKetCoupled(j, m, (j1, j2))) == \ hbar**2*j**2*JxKetCoupled(j, m, (j1, j2)) + \ hbar**2*j*JxKetCoupled(j, m, (j1, j2)) assert qapply(J2*JyKetCoupled(j, m, (j1, j2))) == \ hbar**2*j**2*JyKetCoupled(j, m, (j1, j2)) + \ hbar**2*j*JyKetCoupled(j, m, (j1, j2)) assert qapply(J2*JzKetCoupled(j, m, (j1, j2))) == \ hbar**2*j**2*JzKetCoupled(j, m, (j1, j2)) + \ hbar**2*j*JzKetCoupled(j, m, (j1, j2)) # Uncoupled operators, uncoupled states # Numerical assert qapply(TensorProduct(J2, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ 2*hbar**2*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(1, J2)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ 2*hbar**2*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(J2, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ 2*hbar**2*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(1, J2)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ 2*hbar**2*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(J2, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ 2*hbar**2*TensorProduct(JzKet(1, 1), JzKet(1, -1)) assert qapply(TensorProduct(1, J2)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ 2*hbar**2*TensorProduct(JzKet(1, 1), JzKet(1, -1)) # Symbolic assert qapply(TensorProduct(J2, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ hbar**2*j1**2*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) + \ hbar**2*j1*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) assert qapply(TensorProduct(1, J2)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ hbar**2*j2**2*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) + \ hbar**2*j2*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) assert qapply(TensorProduct(J2, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ hbar**2*j1**2*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) + \ hbar**2*j1*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) assert qapply(TensorProduct(1, J2)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ hbar**2*j2**2*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) + \ hbar**2*j2*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) assert qapply(TensorProduct(J2, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar**2*j1**2*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) + \ hbar**2*j1*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) assert qapply(TensorProduct(1, J2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar**2*j2**2*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) + \ hbar**2*j2*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) def test_jx(): assert Commutator(Jx, Jz).doit() == -I*hbar*Jy assert Jx.rewrite('plusminus') == (Jminus + Jplus)/2 assert represent(Jx, basis=Jz, j=1) == ( represent(Jplus, basis=Jz, j=1) + represent(Jminus, basis=Jz, j=1))/2 # Normal operators, normal states # Numerical assert qapply(Jx*JxKet(1, 1)) == hbar*JxKet(1, 1) assert qapply(Jx*JyKet(1, 1)) == hbar*JyKet(1, 1) assert qapply(Jx*JzKet(1, 1)) == sqrt(2)*hbar*JzKet(1, 0)/2 # Symbolic assert qapply(Jx*JxKet(j, m)) == hbar*m*JxKet(j, m) assert qapply(Jx*JyKet(j, m)) == \ Sum(hbar*mi*WignerD(j, mi, m, 0, 0, pi/2)*Sum(WignerD(j, mi1, mi, 3*pi/2, 0, 0)*JyKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jx*JzKet(j, m)) == \ hbar*sqrt(j**2 + j - m**2 - m)*JzKet(j, m + 1)/2 + hbar*sqrt(j**2 + j - m**2 + m)*JzKet(j, m - 1)/2 # Normal operators, coupled states # Numerical assert qapply(Jx*JxKetCoupled(1, 1, (1, 1))) == \ hbar*JxKetCoupled(1, 1, (1, 1)) assert qapply(Jx*JyKetCoupled(1, 1, (1, 1))) == \ hbar*JyKetCoupled(1, 1, (1, 1)) assert qapply(Jx*JzKetCoupled(1, 1, (1, 1))) == \ sqrt(2)*hbar*JzKetCoupled(1, 0, (1, 1))/2 # Symbolic assert qapply(Jx*JxKetCoupled(j, m, (j1, j2))) == \ hbar*m*JxKetCoupled(j, m, (j1, j2)) assert qapply(Jx*JyKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*mi*WignerD(j, mi, m, 0, 0, pi/2)*Sum(WignerD(j, mi1, mi, 3*pi/2, 0, 0)*JyKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jx*JzKetCoupled(j, m, (j1, j2))) == \ hbar*sqrt(j**2 + j - m**2 - m)*JzKetCoupled(j, m + 1, (j1, j2))/2 + \ hbar*sqrt(j**2 + j - m**2 + m)*JzKetCoupled(j, m - 1, (j1, j2))/2 # Normal operators, uncoupled states # Numerical assert qapply(Jx*TensorProduct(JxKet(1, 1), JxKet(1, 1))) == \ 2*hbar*TensorProduct(JxKet(1, 1), JxKet(1, 1)) assert qapply(Jx*TensorProduct(JyKet(1, 1), JyKet(1, 1))) == \ hbar*TensorProduct(JyKet(1, 1), JyKet(1, 1)) + \ hbar*TensorProduct(JyKet(1, 1), JyKet(1, 1)) assert qapply(Jx*TensorProduct(JzKet(1, 1), JzKet(1, 1))) == \ sqrt(2)*hbar*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 + \ sqrt(2)*hbar*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 assert qapply(Jx*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == 0 # Symbolic assert qapply(Jx*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ hbar*m1*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) + \ hbar*m2*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) assert qapply(Jx*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 0, 0, pi/2)*Sum(WignerD(j1, mi1, mi, 3*pi/2, 0, 0)*JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) + \ TensorProduct(JyKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 0, 0, pi/2)*Sum(WignerD(j2, mi1, mi, 3*pi/2, 0, 0)*JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(Jx*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt(j1**2 + j1 - m1**2 - m1)*TensorProduct(JzKet(j1, m1 + 1), JzKet(j2, m2))/2 + \ hbar*sqrt(j1**2 + j1 - m1**2 + m1)*TensorProduct(JzKet(j1, m1 - 1), JzKet(j2, m2))/2 + \ hbar*sqrt(j2**2 + j2 - m2**2 - m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 + 1))/2 + \ hbar*sqrt( j2**2 + j2 - m2**2 + m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 - 1))/2 # Uncoupled operators, uncoupled states # Numerical assert qapply(TensorProduct(Jx, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(1, Jx)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(Jx, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ hbar*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(1, Jx)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ -hbar*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(Jx, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JzKet(1, 0), JzKet(1, -1))/2 assert qapply(TensorProduct(1, Jx)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ hbar*sqrt(2)*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 # Symbolic assert qapply(TensorProduct(Jx, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ hbar*m1*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) assert qapply(TensorProduct(1, Jx)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ hbar*m2*TensorProduct(JxKet(j1, m1), JxKet(j2, m2)) assert qapply(TensorProduct(Jx, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 0, 0, pi/2) * Sum(WignerD(j1, mi1, mi, 3*pi/2, 0, 0)*JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) assert qapply(TensorProduct(1, Jx)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(JyKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 0, 0, pi/2) * Sum(WignerD(j2, mi1, mi, 3*pi/2, 0, 0)*JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jx, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt(j1**2 + j1 - m1**2 - m1)*TensorProduct(JzKet(j1, m1 + 1), JzKet(j2, m2))/2 + \ hbar*sqrt( j1**2 + j1 - m1**2 + m1)*TensorProduct(JzKet(j1, m1 - 1), JzKet(j2, m2))/2 assert qapply(TensorProduct(1, Jx)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*sqrt(j2**2 + j2 - m2**2 - m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 + 1))/2 + \ hbar*sqrt( j2**2 + j2 - m2**2 + m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 - 1))/2 def test_jy(): assert Commutator(Jy, Jz).doit() == I*hbar*Jx assert Jy.rewrite('plusminus') == (Jplus - Jminus)/(2*I) assert represent(Jy, basis=Jz) == ( represent(Jplus, basis=Jz) - represent(Jminus, basis=Jz))/(2*I) # Normal operators, normal states # Numerical assert qapply(Jy*JxKet(1, 1)) == hbar*JxKet(1, 1) assert qapply(Jy*JyKet(1, 1)) == hbar*JyKet(1, 1) assert qapply(Jy*JzKet(1, 1)) == sqrt(2)*hbar*I*JzKet(1, 0)/2 # Symbolic assert qapply(Jy*JxKet(j, m)) == \ Sum(hbar*mi*WignerD(j, mi, m, 3*pi/2, 0, 0)*Sum(WignerD( j, mi1, mi, 0, 0, pi/2)*JxKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jy*JyKet(j, m)) == hbar*m*JyKet(j, m) assert qapply(Jy*JzKet(j, m)) == \ -hbar*I*sqrt(j**2 + j - m**2 - m)*JzKet( j, m + 1)/2 + hbar*I*sqrt(j**2 + j - m**2 + m)*JzKet(j, m - 1)/2 # Normal operators, coupled states # Numerical assert qapply(Jy*JxKetCoupled(1, 1, (1, 1))) == \ hbar*JxKetCoupled(1, 1, (1, 1)) assert qapply(Jy*JyKetCoupled(1, 1, (1, 1))) == \ hbar*JyKetCoupled(1, 1, (1, 1)) assert qapply(Jy*JzKetCoupled(1, 1, (1, 1))) == \ sqrt(2)*hbar*I*JzKetCoupled(1, 0, (1, 1))/2 # Symbolic assert qapply(Jy*JxKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*mi*WignerD(j, mi, m, 3*pi/2, 0, 0)*Sum(WignerD(j, mi1, mi, 0, 0, pi/2)*JxKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jy*JyKetCoupled(j, m, (j1, j2))) == \ hbar*m*JyKetCoupled(j, m, (j1, j2)) assert qapply(Jy*JzKetCoupled(j, m, (j1, j2))) == \ -hbar*I*sqrt(j**2 + j - m**2 - m)*JzKetCoupled(j, m + 1, (j1, j2))/2 + \ hbar*I*sqrt(j**2 + j - m**2 + m)*JzKetCoupled(j, m - 1, (j1, j2))/2 # Normal operators, uncoupled states # Numerical assert qapply(Jy*TensorProduct(JxKet(1, 1), JxKet(1, 1))) == \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, 1)) + \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, 1)) assert qapply(Jy*TensorProduct(JyKet(1, 1), JyKet(1, 1))) == \ 2*hbar*TensorProduct(JyKet(1, 1), JyKet(1, 1)) assert qapply(Jy*TensorProduct(JzKet(1, 1), JzKet(1, 1))) == \ sqrt(2)*hbar*I*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 + \ sqrt(2)*hbar*I*TensorProduct(JzKet(1, 0), JzKet(1, 1))/2 assert qapply(Jy*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == 0 # Symbolic assert qapply(Jy*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 3*pi/2, 0, 0)*Sum(WignerD(j2, mi1, mi, 0, 0, pi/2)*JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) + \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 3*pi/2, 0, 0)*Sum(WignerD(j1, mi1, mi, 0, 0, pi/2)*JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(Jy*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ hbar*m1*TensorProduct(JyKet(j1, m1), JyKet( j2, m2)) + hbar*m2*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) assert qapply(Jy*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ -hbar*I*sqrt(j1**2 + j1 - m1**2 - m1)*TensorProduct(JzKet(j1, m1 + 1), JzKet(j2, m2))/2 + \ hbar*I*sqrt(j1**2 + j1 - m1**2 + m1)*TensorProduct(JzKet(j1, m1 - 1), JzKet(j2, m2))/2 + \ -hbar*I*sqrt(j2**2 + j2 - m2**2 - m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 + 1))/2 + \ hbar*I*sqrt( j2**2 + j2 - m2**2 + m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 - 1))/2 # Uncoupled operators, uncoupled states # Numerical assert qapply(TensorProduct(Jy, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(1, Jy)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -hbar*TensorProduct(JxKet(1, 1), JxKet(1, -1)) assert qapply(TensorProduct(Jy, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ hbar*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(1, Jy)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ -hbar*TensorProduct(JyKet(1, 1), JyKet(1, -1)) assert qapply(TensorProduct(Jy, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ hbar*sqrt(2)*I*TensorProduct(JzKet(1, 0), JzKet(1, -1))/2 assert qapply(TensorProduct(1, Jy)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ -hbar*sqrt(2)*I*TensorProduct(JzKet(1, 1), JzKet(1, 0))/2 # Symbolic assert qapply(TensorProduct(Jy, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 3*pi/2, 0, 0) * Sum(WignerD(j1, mi1, mi, 0, 0, pi/2)*JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(TensorProduct(1, Jy)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 3*pi/2, 0, 0) * Sum(WignerD(j2, mi1, mi, 0, 0, pi/2)*JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jy, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ hbar*m1*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) assert qapply(TensorProduct(1, Jy)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ hbar*m2*TensorProduct(JyKet(j1, m1), JyKet(j2, m2)) assert qapply(TensorProduct(Jy, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ -hbar*I*sqrt(j1**2 + j1 - m1**2 - m1)*TensorProduct(JzKet(j1, m1 + 1), JzKet(j2, m2))/2 + \ hbar*I*sqrt( j1**2 + j1 - m1**2 + m1)*TensorProduct(JzKet(j1, m1 - 1), JzKet(j2, m2))/2 assert qapply(TensorProduct(1, Jy)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ -hbar*I*sqrt(j2**2 + j2 - m2**2 - m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 + 1))/2 + \ hbar*I*sqrt( j2**2 + j2 - m2**2 + m2)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2 - 1))/2 def test_jz(): assert Commutator(Jz, Jminus).doit() == -hbar*Jminus # Normal operators, normal states # Numerical assert qapply(Jz*JxKet(1, 1)) == -sqrt(2)*hbar*JxKet(1, 0)/2 assert qapply(Jz*JyKet(1, 1)) == -sqrt(2)*hbar*I*JyKet(1, 0)/2 assert qapply(Jz*JzKet(2, 1)) == hbar*JzKet(2, 1) # Symbolic assert qapply(Jz*JxKet(j, m)) == \ Sum(hbar*mi*WignerD(j, mi, m, 0, pi/2, 0)*Sum(WignerD(j, mi1, mi, 0, 3*pi/2, 0)*JxKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jz*JyKet(j, m)) == \ Sum(hbar*mi*WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKet(j, mi1), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jz*JzKet(j, m)) == hbar*m*JzKet(j, m) # Normal operators, coupled states # Numerical assert qapply(Jz*JxKetCoupled(1, 1, (1, 1))) == \ -sqrt(2)*hbar*JxKetCoupled(1, 0, (1, 1))/2 assert qapply(Jz*JyKetCoupled(1, 1, (1, 1))) == \ -sqrt(2)*hbar*I*JyKetCoupled(1, 0, (1, 1))/2 assert qapply(Jz*JzKetCoupled(1, 1, (1, 1))) == \ hbar*JzKetCoupled(1, 1, (1, 1)) # Symbolic assert qapply(Jz*JxKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*mi*WignerD(j, mi, m, 0, pi/2, 0)*Sum(WignerD(j, mi1, mi, 0, 3*pi/2, 0)*JxKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jz*JyKetCoupled(j, m, (j1, j2))) == \ Sum(hbar*mi*WignerD(j, mi, m, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKetCoupled(j, mi1, (j1, j2)), (mi1, -j, j)), (mi, -j, j)) assert qapply(Jz*JzKetCoupled(j, m, (j1, j2))) == \ hbar*m*JzKetCoupled(j, m, (j1, j2)) # Normal operators, uncoupled states # Numerical assert qapply(Jz*TensorProduct(JxKet(1, 1), JxKet(1, 1))) == \ -sqrt(2)*hbar*TensorProduct(JxKet(1, 1), JxKet(1, 0))/2 - \ sqrt(2)*hbar*TensorProduct(JxKet(1, 0), JxKet(1, 1))/2 assert qapply(Jz*TensorProduct(JyKet(1, 1), JyKet(1, 1))) == \ -sqrt(2)*hbar*I*TensorProduct(JyKet(1, 1), JyKet(1, 0))/2 - \ sqrt(2)*hbar*I*TensorProduct(JyKet(1, 0), JyKet(1, 1))/2 assert qapply(Jz*TensorProduct(JzKet(1, 1), JzKet(1, 1))) == \ 2*hbar*TensorProduct(JzKet(1, 1), JzKet(1, 1)) assert qapply(Jz*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == 0 # Symbolic assert qapply(Jz*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 0, pi/2, 0)*Sum(WignerD(j2, mi1, mi, 0, 3*pi/2, 0)*JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) + \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 0, pi/2, 0)*Sum(WignerD(j1, mi1, mi, 0, 3*pi/2, 0)*JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(Jz*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(JyKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j2, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) + \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j1, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) assert qapply(Jz*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*m1*TensorProduct(JzKet(j1, m1), JzKet( j2, m2)) + hbar*m2*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) # Uncoupled Operators # Numerical assert qapply(TensorProduct(Jz, 1)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -sqrt(2)*hbar*TensorProduct(JxKet(1, 0), JxKet(1, -1))/2 assert qapply(TensorProduct(1, Jz)*TensorProduct(JxKet(1, 1), JxKet(1, -1))) == \ -sqrt(2)*hbar*TensorProduct(JxKet(1, 1), JxKet(1, 0))/2 assert qapply(TensorProduct(Jz, 1)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ -sqrt(2)*I*hbar*TensorProduct(JyKet(1, 0), JyKet(1, -1))/2 assert qapply(TensorProduct(1, Jz)*TensorProduct(JyKet(1, 1), JyKet(1, -1))) == \ sqrt(2)*I*hbar*TensorProduct(JyKet(1, 1), JyKet(1, 0))/2 assert qapply(TensorProduct(Jz, 1)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ hbar*TensorProduct(JzKet(1, 1), JzKet(1, -1)) assert qapply(TensorProduct(1, Jz)*TensorProduct(JzKet(1, 1), JzKet(1, -1))) == \ -hbar*TensorProduct(JzKet(1, 1), JzKet(1, -1)) # Symbolic assert qapply(TensorProduct(Jz, 1)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 0, pi/2, 0)*Sum(WignerD(j1, mi1, mi, 0, 3*pi/2, 0)*JxKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JxKet(j2, m2)) assert qapply(TensorProduct(1, Jz)*TensorProduct(JxKet(j1, m1), JxKet(j2, m2))) == \ TensorProduct(JxKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 0, pi/2, 0)*Sum(WignerD(j2, mi1, mi, 0, 3*pi/2, 0)*JxKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jz, 1)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(Sum(hbar*mi*WignerD(j1, mi, m1, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j1, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKet(j1, mi1), (mi1, -j1, j1)), (mi, -j1, j1)), JyKet(j2, m2)) assert qapply(TensorProduct(1, Jz)*TensorProduct(JyKet(j1, m1), JyKet(j2, m2))) == \ TensorProduct(JyKet(j1, m1), Sum(hbar*mi*WignerD(j2, mi, m2, 3*pi/2, -pi/2, pi/2)*Sum(WignerD(j2, mi1, mi, 3*pi/2, pi/2, pi/2)*JyKet(j2, mi1), (mi1, -j2, j2)), (mi, -j2, j2))) assert qapply(TensorProduct(Jz, 1)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*m1*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) assert qapply(TensorProduct(1, Jz)*TensorProduct(JzKet(j1, m1), JzKet(j2, m2))) == \ hbar*m2*TensorProduct(JzKet(j1, m1), JzKet(j2, m2)) def test_rotation(): a, b, g = symbols('a b g') j, m = symbols('j m') #Uncoupled answ = [JxKet(1,-1)/2 - sqrt(2)*JxKet(1,0)/2 + JxKet(1,1)/2 , JyKet(1,-1)/2 - sqrt(2)*JyKet(1,0)/2 + JyKet(1,1)/2 , JzKet(1,-1)/2 - sqrt(2)*JzKet(1,0)/2 + JzKet(1,1)/2] fun = [state(1, 1) for state in (JxKet, JyKet, JzKet)] for state in fun: got = qapply(Rotation(0, pi/2, 0)*state) assert got in answ answ.remove(got) assert not answ arg = Rotation(a, b, g)*fun[0] assert qapply(arg) == (-exp(-I*a)*exp(I*g)*cos(b)*JxKet(1,-1)/2 + exp(-I*a)*exp(I*g)*JxKet(1,-1)/2 - sqrt(2)*exp(-I*a)*sin(b)*JxKet(1,0)/2 + exp(-I*a)*exp(-I*g)*cos(b)*JxKet(1,1)/2 + exp(-I*a)*exp(-I*g)*JxKet(1,1)/2) #dummy effective assert str(qapply(Rotation(a, b, g)*JzKet(j, m), dummy=False)) == str( qapply(Rotation(a, b, g)*JzKet(j, m), dummy=True)).replace('_','') #Coupled ans = [JxKetCoupled(1,-1,(1,1))/2 - sqrt(2)*JxKetCoupled(1,0,(1,1))/2 + JxKetCoupled(1,1,(1,1))/2 , JyKetCoupled(1,-1,(1,1))/2 - sqrt(2)*JyKetCoupled(1,0,(1,1))/2 + JyKetCoupled(1,1,(1,1))/2 , JzKetCoupled(1,-1,(1,1))/2 - sqrt(2)*JzKetCoupled(1,0,(1,1))/2 + JzKetCoupled(1,1,(1,1))/2] fun = [state(1, 1, (1,1)) for state in (JxKetCoupled, JyKetCoupled, JzKetCoupled)] for state in fun: got = qapply(Rotation(0, pi/2, 0)*state) assert got in ans ans.remove(got) assert not ans arg = Rotation(a, b, g)*fun[0] assert qapply(arg) == ( -exp(-I*a)*exp(I*g)*cos(b)*JxKetCoupled(1,-1,(1,1))/2 + exp(-I*a)*exp(I*g)*JxKetCoupled(1,-1,(1,1))/2 - sqrt(2)*exp(-I*a)*sin(b)*JxKetCoupled(1,0,(1,1))/2 + exp(-I*a)*exp(-I*g)*cos(b)*JxKetCoupled(1,1,(1,1))/2 + exp(-I*a)*exp(-I*g)*JxKetCoupled(1,1,(1,1))/2) #dummy effective assert str(qapply(Rotation(a,b,g)*JzKetCoupled(j,m,(j1,j2)), dummy=False)) == str( qapply(Rotation(a,b,g)*JzKetCoupled(j,m,(j1,j2)), dummy=True)).replace('_','') def test_jzket(): j, m = symbols('j m') # j not integer or half integer raises(ValueError, lambda: JzKet(S(2)/3, -S(1)/3)) raises(ValueError, lambda: JzKet(S(2)/3, m)) # j < 0 raises(ValueError, lambda: JzKet(-1, 1)) raises(ValueError, lambda: JzKet(-1, m)) # m not integer or half integer raises(ValueError, lambda: JzKet(j, -S(1)/3)) # abs(m) > j raises(ValueError, lambda: JzKet(1, 2)) raises(ValueError, lambda: JzKet(1, -2)) # j-m not integer raises(ValueError, lambda: JzKet(1, S(1)/2)) def test_jzketcoupled(): j, m = symbols('j m') # j not integer or half integer raises(ValueError, lambda: JzKetCoupled(S(2)/3, -S(1)/3, (1,))) raises(ValueError, lambda: JzKetCoupled(S(2)/3, m, (1,))) # j < 0 raises(ValueError, lambda: JzKetCoupled(-1, 1, (1,))) raises(ValueError, lambda: JzKetCoupled(-1, m, (1,))) # m not integer or half integer raises(ValueError, lambda: JzKetCoupled(j, -S(1)/3, (1,))) # abs(m) > j raises(ValueError, lambda: JzKetCoupled(1, 2, (1,))) raises(ValueError, lambda: JzKetCoupled(1, -2, (1,))) # j-m not integer raises(ValueError, lambda: JzKetCoupled(1, S(1)/2, (1,))) # checks types on coupling scheme raises(TypeError, lambda: JzKetCoupled(1, 1, 1)) raises(TypeError, lambda: JzKetCoupled(1, 1, (1,), 1)) raises(TypeError, lambda: JzKetCoupled(1, 1, (1, 1), (1,))) raises(TypeError, lambda: JzKetCoupled(1, 1, (1, 1, 1), (1, 2, 1), (1, 3, 1))) # checks length of coupling terms raises(ValueError, lambda: JzKetCoupled(1, 1, (1,), ((1, 2, 1),))) raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((1, 2),))) # all jn are integer or half-integer raises(ValueError, lambda: JzKetCoupled(1, 1, (S(1)/3, S(2)/3))) # indicies in coupling scheme must be integers raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((S(1)/2, 1, 2),) )) raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((1, S(1)/2, 2),) )) # indicies out of range raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((0, 2, 1),) )) raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((3, 2, 1),) )) raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((1, 0, 1),) )) raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((1, 3, 1),) )) # all j values in coupling scheme must by integer or half-integer raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1, 1), ((1, 2, S( 4)/3), (1, 3, 1)) )) # each coupling must satisfy |j1-j2| <= j3 <= j1+j2 raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 5))) raises(ValueError, lambda: JzKetCoupled(5, 1, (1, 1))) # final j of coupling must be j of the state raises(ValueError, lambda: JzKetCoupled(1, 1, (1, 1), ((1, 2, 2),) ))
gpl-3.0
[ 504, 636, 2443, 363, 492, 4629, 199, 504, 5840, 492, 9794, 12, 1437, 12, 6544, 12, 473, 12, 8449, 12, 6682, 12, 428, 12, 9829, 12, 7452, 12, 12094, 12, 6698, 199, 504, 5840, 14, 3175, 492, 5131, 12, 8201, 12, 10169, 12, 1335, 12, 333, 199, 504, 5840, 14, 24724, 14, 25999, 492, 394, 1700, 12, 2954, 12, 7046, 337, 707, 12, 19646, 5884, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 4998, 492, 30888, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3128, 2558, 492, 23482, 199, 504, 5840, 14, 24724, 14, 25999, 14, 12595, 492, 18657, 199, 504, 5840, 14, 24724, 14, 25999, 14, 14809, 492, 334, 272, 1603, 88, 12, 1603, 89, 12, 1603, 90, 12, 1603, 6666, 12, 1603, 13084, 12, 1603, 18, 12, 272, 1603, 8094, 345, 12, 1603, 89, 17171, 12, 1603, 90, 17171, 12, 272, 1603, 88, 5018, 12, 1603, 89, 5018, 12, 7623, 12, 272, 1603, 88, 5018, 11605, 12, 1603, 89, 5018, 11605, 12, 23783, 12, 272, 17535, 12, 625, 17600, 12, 272, 28642, 12, 644, 1030, 281, 36, 199, 9, 199, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 74, 17, 12, 1335, 18, 12, 1335, 19, 12, 1335, 20, 12, 333, 17, 12, 333, 18, 12, 333, 19, 12, 333, 20, 275, 6698, 360, 74, 17, 26, 21, 333, 17, 26, 21, 358, 199, 74, 713, 12, 1335, 969, 12, 1335, 1194, 12, 1335, 1082, 12, 1335, 4288, 12, 1335, 7582, 12, 10684, 12, 10684, 17, 12, 6118, 275, 6698, 8, 272, 283, 74, 713, 1335, 969, 1335, 1194, 1335, 1082, 1335, 4288, 1335, 7582, 10684, 10684, 17, 6118, 358, 421, 199, 318, 511, 63, 13063, 63, 14809, 63, 12688, 837, 272, 702, 2954, 8, 21968, 9, 508, 394, 1700, 10, 6443, 4038, 16, 12, 413, 467, 359, 17, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 267, 1603, 88, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 5079, 8, 18, 3342, 6443, 4038, 16, 12, 413, 12, 378, 467, 359, 17, 12, 378, 12, 413, 467, 359, 16, 12, 413, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 16608, 9, 508, 394, 1700, 10, 41, 10, 6443, 4038, 16, 12, 446, 17, 467, 359, 17, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 16608, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 41, 10, 5079, 8, 18, 3342, 6443, 4038, 16, 12, 446, 17, 12, 378, 467, 359, 17, 12, 2151, 378, 12, 446, 17, 467, 359, 16, 12, 413, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 25620, 9, 508, 394, 1700, 10, 6443, 4038, 17, 12, 378, 467, 359, 16, 12, 446, 17, 3934, 15, 18, 272, 702, 2954, 8, 267, 1603, 90, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 6443, 4038, 17, 12, 378, 12, 378, 467, 359, 16, 12, 378, 12, 378, 467, 359, 16, 12, 378, 12, 446, 17, 3934, 421, 199, 318, 511, 63, 13063, 63, 14809, 63, 4981, 837, 272, 327, 1603, 88, 5597, 272, 702, 2954, 8, 21968, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 378, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 378, 12, 413, 566, 272, 702, 2954, 8, 267, 1603, 89, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 1474, 2801, 41, 10, 1038, 15, 20, 395, 378, 566, 272, 702, 2954, 8, 267, 1603, 89, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 1437, 8, 41, 10, 1038, 15, 20, 3948, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 11468, 41, 12, 378, 12, 378, 566, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 12, 378, 566, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 378, 12, 473, 566, 272, 702, 2954, 8, 267, 7623, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 11468, 17, 12, 413, 23067, 18, 272, 702, 2954, 8, 267, 7623, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 11468, 17, 12, 446, 17, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 446, 5079, 8, 18, 395, 413, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 779, 17, 12, 378, 12, 446, 17, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 7452, 8, 18, 395, 413, 23067, 18, 272, 327, 1603, 89, 5597, 272, 702, 2954, 8, 267, 1603, 88, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 16608, 9, 508, 8449, 779, 1474, 2801, 19, 10, 41, 10, 1038, 15, 20, 395, 378, 566, 272, 702, 2954, 8, 267, 1603, 88, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 16608, 9, 508, 8449, 779, 16, 12, 1437, 8, 19 ]
[ 636, 2443, 363, 492, 4629, 199, 504, 5840, 492, 9794, 12, 1437, 12, 6544, 12, 473, 12, 8449, 12, 6682, 12, 428, 12, 9829, 12, 7452, 12, 12094, 12, 6698, 199, 504, 5840, 14, 3175, 492, 5131, 12, 8201, 12, 10169, 12, 1335, 12, 333, 199, 504, 5840, 14, 24724, 14, 25999, 492, 394, 1700, 12, 2954, 12, 7046, 337, 707, 12, 19646, 5884, 199, 504, 5840, 14, 24724, 14, 25999, 14, 81, 4998, 492, 30888, 199, 504, 5840, 14, 24724, 14, 25999, 14, 3128, 2558, 492, 23482, 199, 504, 5840, 14, 24724, 14, 25999, 14, 12595, 492, 18657, 199, 504, 5840, 14, 24724, 14, 25999, 14, 14809, 492, 334, 272, 1603, 88, 12, 1603, 89, 12, 1603, 90, 12, 1603, 6666, 12, 1603, 13084, 12, 1603, 18, 12, 272, 1603, 8094, 345, 12, 1603, 89, 17171, 12, 1603, 90, 17171, 12, 272, 1603, 88, 5018, 12, 1603, 89, 5018, 12, 7623, 12, 272, 1603, 88, 5018, 11605, 12, 1603, 89, 5018, 11605, 12, 23783, 12, 272, 17535, 12, 625, 17600, 12, 272, 28642, 12, 644, 1030, 281, 36, 199, 9, 199, 199, 504, 5840, 14, 16355, 14, 4462, 492, 6534, 199, 199, 74, 17, 12, 1335, 18, 12, 1335, 19, 12, 1335, 20, 12, 333, 17, 12, 333, 18, 12, 333, 19, 12, 333, 20, 275, 6698, 360, 74, 17, 26, 21, 333, 17, 26, 21, 358, 199, 74, 713, 12, 1335, 969, 12, 1335, 1194, 12, 1335, 1082, 12, 1335, 4288, 12, 1335, 7582, 12, 10684, 12, 10684, 17, 12, 6118, 275, 6698, 8, 272, 283, 74, 713, 1335, 969, 1335, 1194, 1335, 1082, 1335, 4288, 1335, 7582, 10684, 10684, 17, 6118, 358, 421, 199, 318, 511, 63, 13063, 63, 14809, 63, 12688, 837, 272, 702, 2954, 8, 21968, 9, 508, 394, 1700, 10, 6443, 4038, 16, 12, 413, 467, 359, 17, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 267, 1603, 88, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 5079, 8, 18, 3342, 6443, 4038, 16, 12, 413, 12, 378, 467, 359, 17, 12, 378, 12, 413, 467, 359, 16, 12, 413, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 16608, 9, 508, 394, 1700, 10, 41, 10, 6443, 4038, 16, 12, 446, 17, 467, 359, 17, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 16608, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 41, 10, 5079, 8, 18, 3342, 6443, 4038, 16, 12, 446, 17, 12, 378, 467, 359, 17, 12, 2151, 378, 12, 446, 17, 467, 359, 16, 12, 413, 12, 378, 3934, 15, 18, 272, 702, 2954, 8, 25620, 9, 508, 394, 1700, 10, 6443, 4038, 17, 12, 378, 467, 359, 16, 12, 446, 17, 3934, 15, 18, 272, 702, 2954, 8, 267, 1603, 90, 12, 1335, 29, 17, 9, 508, 394, 1700, 10, 6443, 4038, 17, 12, 378, 12, 378, 467, 359, 16, 12, 378, 12, 378, 467, 359, 16, 12, 378, 12, 446, 17, 3934, 421, 199, 318, 511, 63, 13063, 63, 14809, 63, 4981, 837, 272, 327, 1603, 88, 5597, 272, 702, 2954, 8, 21968, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 378, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 12, 378, 566, 272, 702, 2954, 8, 21968, 5018, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 378, 12, 413, 566, 272, 702, 2954, 8, 267, 1603, 89, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 1474, 2801, 41, 10, 1038, 15, 20, 395, 378, 566, 272, 702, 2954, 8, 267, 1603, 89, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 1437, 8, 41, 10, 1038, 15, 20, 3948, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 11468, 41, 12, 378, 12, 378, 566, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 413, 12, 378, 566, 272, 702, 2954, 8, 16608, 5018, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 16, 12, 378, 12, 473, 566, 272, 702, 2954, 8, 267, 7623, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 11468, 17, 12, 413, 23067, 18, 272, 702, 2954, 8, 267, 7623, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 11468, 17, 12, 446, 17, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 413, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 446, 5079, 8, 18, 395, 413, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 378, 395, 5597, 29, 21968, 9, 508, 7452, 8, 18, 3342, 6443, 779, 17, 12, 378, 12, 446, 17, 23067, 18, 272, 702, 2954, 8, 9450, 8, 17, 12, 446, 17, 395, 5597, 29, 21968, 9, 508, 8449, 779, 17, 12, 7452, 8, 18, 395, 413, 23067, 18, 272, 327, 1603, 89, 5597, 272, 702, 2954, 8, 267, 1603, 88, 5018, 8, 51, 8, 17, 2447, 18, 12, 428, 8, 17, 2447, 18, 395, 5597, 29, 16608, 9, 508, 8449, 779, 1474, 2801, 19, 10, 41, 10, 1038, 15, 20, 395, 378, 566, 272, 702, 2954, 8, 267, 1603, 88, 5018, 8, 51, 8, 17, 2447, 18, 12, 446, 51, 8, 17, 2447, 18, 395, 5597, 29, 16608, 9, 508, 8449, 779, 16, 12, 1437, 8, 19, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
maxamillion/openshift-ansible
roles/lib_openshift/src/lib/serviceaccount.py
84
4113
# pylint: skip-file # flake8: noqa class ServiceAccountConfig(object): '''Service account config class This class stores the options and returns a default service account ''' # pylint: disable=too-many-arguments def __init__(self, sname, namespace, kubeconfig, secrets=None, image_pull_secrets=None): self.name = sname self.kubeconfig = kubeconfig self.namespace = namespace self.secrets = secrets or [] self.image_pull_secrets = image_pull_secrets or [] self.data = {} self.create_dict() def create_dict(self): ''' instantiate a properly structured volume ''' self.data['apiVersion'] = 'v1' self.data['kind'] = 'ServiceAccount' self.data['metadata'] = {} self.data['metadata']['name'] = self.name self.data['metadata']['namespace'] = self.namespace self.data['secrets'] = [] if self.secrets: for sec in self.secrets: self.data['secrets'].append({"name": sec}) self.data['imagePullSecrets'] = [] if self.image_pull_secrets: for sec in self.image_pull_secrets: self.data['imagePullSecrets'].append({"name": sec}) class ServiceAccount(Yedit): ''' Class to wrap the oc command line tools ''' image_pull_secrets_path = "imagePullSecrets" secrets_path = "secrets" def __init__(self, content): '''ServiceAccount constructor''' super(ServiceAccount, self).__init__(content=content) self._secrets = None self._image_pull_secrets = None @property def image_pull_secrets(self): ''' property for image_pull_secrets ''' if self._image_pull_secrets is None: self._image_pull_secrets = self.get(ServiceAccount.image_pull_secrets_path) or [] return self._image_pull_secrets @image_pull_secrets.setter def image_pull_secrets(self, secrets): ''' property for secrets ''' self._image_pull_secrets = secrets @property def secrets(self): ''' property for secrets ''' if not self._secrets: self._secrets = self.get(ServiceAccount.secrets_path) or [] return self._secrets @secrets.setter def secrets(self, secrets): ''' property for secrets ''' self._secrets = secrets def delete_secret(self, inc_secret): ''' remove a secret ''' remove_idx = None for idx, sec in enumerate(self.secrets): if sec['name'] == inc_secret: remove_idx = idx break if remove_idx: del self.secrets[remove_idx] return True return False def delete_image_pull_secret(self, inc_secret): ''' remove a image_pull_secret ''' remove_idx = None for idx, sec in enumerate(self.image_pull_secrets): if sec['name'] == inc_secret: remove_idx = idx break if remove_idx: del self.image_pull_secrets[remove_idx] return True return False def find_secret(self, inc_secret): '''find secret''' for secret in self.secrets: if secret['name'] == inc_secret: return secret return None def find_image_pull_secret(self, inc_secret): '''find secret''' for secret in self.image_pull_secrets: if secret['name'] == inc_secret: return secret return None def add_secret(self, inc_secret): '''add secret''' if self.secrets: self.secrets.append({"name": inc_secret}) # pylint: disable=no-member else: self.put(ServiceAccount.secrets_path, [{"name": inc_secret}]) def add_image_pull_secret(self, inc_secret): '''add image_pull_secret''' if self.image_pull_secrets: self.image_pull_secrets.append({"name": inc_secret}) # pylint: disable=no-member else: self.put(ServiceAccount.image_pull_secrets_path, [{"name": inc_secret}])
apache-2.0
[ 3, 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 199, 199, 533, 7591, 6009, 2028, 8, 785, 304, 272, 1449, 3167, 2933, 1101, 1021, 10817, 961, 1021, 14086, 314, 1511, 436, 2529, 282, 849, 2435, 2933, 272, 1449, 339, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 636, 826, 721, 277, 12, 308, 354, 12, 3231, 12, 23091, 888, 12, 25563, 29, 403, 12, 1834, 63, 9302, 63, 16153, 29, 403, 304, 267, 291, 14, 354, 275, 308, 354, 267, 291, 14, 29192, 275, 23091, 888, 267, 291, 14, 3251, 275, 3231, 267, 291, 14, 16153, 275, 25563, 503, 942, 267, 291, 14, 1569, 63, 9302, 63, 16153, 275, 1834, 63, 9302, 63, 16153, 503, 942, 267, 291, 14, 576, 275, 1052, 267, 291, 14, 981, 63, 807, 342, 339, 347, 1218, 63, 807, 8, 277, 304, 267, 1449, 17321, 282, 7684, 21781, 3301, 1449, 267, 291, 14, 576, 459, 1246, 3353, 418, 275, 283, 86, 17, 7, 267, 291, 14, 576, 459, 5091, 418, 275, 283, 3167, 6009, 7, 267, 291, 14, 576, 459, 2343, 418, 275, 1052, 267, 291, 14, 576, 459, 2343, 2545, 354, 418, 275, 291, 14, 354, 267, 291, 14, 576, 459, 2343, 2545, 3251, 418, 275, 291, 14, 3251, 398, 291, 14, 576, 459, 16153, 418, 275, 942, 267, 340, 291, 14, 16153, 26, 288, 367, 6513, 315, 291, 14, 16153, 26, 355, 291, 14, 576, 459, 16153, 2278, 740, 6333, 354, 582, 6513, 1552, 398, 291, 14, 576, 459, 1569, 27318, 4933, 264, 1086, 418, 275, 942, 267, 340, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 367, 6513, 315, 291, 14, 1569, 63, 9302, 63, 16153, 26, 355, 291, 14, 576, 459, 1569, 27318, 4933, 264, 1086, 2278, 740, 6333, 354, 582, 6513, 1552, 199, 199, 533, 7591, 6009, 8, 57, 3773, 304, 272, 1449, 8089, 370, 4816, 314, 4244, 1414, 1004, 7249, 1449, 272, 1834, 63, 9302, 63, 16153, 63, 515, 275, 298, 1569, 27318, 4933, 264, 1086, 2, 272, 25563, 63, 515, 275, 298, 16153, 2, 339, 347, 636, 826, 721, 277, 12, 1564, 304, 267, 1449, 3167, 6009, 3787, 2344, 267, 1613, 8, 3167, 6009, 12, 291, 2843, 826, 721, 1317, 29, 1317, 9, 267, 291, 423, 16153, 275, 488, 267, 291, 423, 1569, 63, 9302, 63, 16153, 275, 488, 339, 768, 1829, 272, 347, 1834, 63, 9302, 63, 16153, 8, 277, 304, 267, 1449, 3324, 367, 1834, 63, 9302, 63, 16153, 1449, 267, 340, 291, 423, 1569, 63, 9302, 63, 16153, 365, 488, 26, 288, 291, 423, 1569, 63, 9302, 63, 16153, 275, 291, 14, 362, 8, 3167, 6009, 14, 1569, 63, 9302, 63, 16153, 63, 515, 9, 503, 942, 267, 372, 291, 423, 1569, 63, 9302, 63, 16153, 339, 768, 1569, 63, 9302, 63, 16153, 14, 8345, 272, 347, 1834, 63, 9302, 63, 16153, 8, 277, 12, 25563, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 291, 423, 1569, 63, 9302, 63, 16153, 275, 25563, 339, 768, 1829, 272, 347, 25563, 8, 277, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 340, 440, 291, 423, 16153, 26, 288, 291, 423, 16153, 275, 291, 14, 362, 8, 3167, 6009, 14, 16153, 63, 515, 9, 503, 942, 267, 372, 291, 423, 16153, 339, 768, 16153, 14, 8345, 272, 347, 25563, 8, 277, 12, 25563, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 291, 423, 16153, 275, 25563, 339, 347, 3145, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 2813, 282, 7565, 1449, 267, 2813, 63, 2996, 275, 488, 267, 367, 4280, 12, 6513, 315, 3874, 8, 277, 14, 16153, 304, 288, 340, 6513, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 2813, 63, 2996, 275, 4280, 355, 2059, 398, 340, 2813, 63, 2996, 26, 288, 2150, 291, 14, 16153, 59, 2168, 63, 2996, 61, 288, 372, 715, 398, 372, 756, 339, 347, 3145, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 2813, 282, 1834, 63, 9302, 63, 4731, 1449, 267, 2813, 63, 2996, 275, 488, 267, 367, 4280, 12, 6513, 315, 3874, 8, 277, 14, 1569, 63, 9302, 63, 16153, 304, 288, 340, 6513, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 2813, 63, 2996, 275, 4280, 355, 2059, 398, 340, 2813, 63, 2996, 26, 288, 2150, 291, 14, 1569, 63, 9302, 63, 16153, 59, 2168, 63, 2996, 61, 288, 372, 715, 398, 372, 756, 339, 347, 2342, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 1623, 7565, 2344, 267, 367, 7565, 315, 291, 14, 16153, 26, 288, 340, 7565, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 372, 7565, 398, 372, 488, 339, 347, 2342, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 1623, 7565, 2344, 267, 367, 7565, 315, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 340, 7565, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 372, 7565, 398, 372, 488, 339, 347, 1050, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 525, 7565, 2344, 267, 340, 291, 14, 16153, 26, 288, 291, 14, 16153, 14, 740, 6333, 354, 582, 12864, 63, 4731, 1552, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 587, 26, 288, 291, 14, 524, 8, 3167, 6009, 14, 16153, 63, 515, 12, 16870, 354, 582, 12864, 63, 4731, 29810, 339, 347, 1050, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 525, 1834, 63, 9302, 63, 4731, 2344, 267, 340, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 291, 14, 1569, 63, 9302, 63, 16153, 14, 740, 6333, 354, 582, 12864, 63, 4731, 1552, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 587, 26, 288, 291, 14, 524, 8, 3167, 6009, 14, 1569, 63, 9302, 63, 16153, 63, 515, 12, 16870, 354, 582, 12864, 63, 4731, 29810, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4287, 26, 3372, 13, 493, 199, 3, 27510, 24, 26, 8151, 199, 199, 533, 7591, 6009, 2028, 8, 785, 304, 272, 1449, 3167, 2933, 1101, 1021, 10817, 961, 1021, 14086, 314, 1511, 436, 2529, 282, 849, 2435, 2933, 272, 1449, 339, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 4958, 272, 347, 636, 826, 721, 277, 12, 308, 354, 12, 3231, 12, 23091, 888, 12, 25563, 29, 403, 12, 1834, 63, 9302, 63, 16153, 29, 403, 304, 267, 291, 14, 354, 275, 308, 354, 267, 291, 14, 29192, 275, 23091, 888, 267, 291, 14, 3251, 275, 3231, 267, 291, 14, 16153, 275, 25563, 503, 942, 267, 291, 14, 1569, 63, 9302, 63, 16153, 275, 1834, 63, 9302, 63, 16153, 503, 942, 267, 291, 14, 576, 275, 1052, 267, 291, 14, 981, 63, 807, 342, 339, 347, 1218, 63, 807, 8, 277, 304, 267, 1449, 17321, 282, 7684, 21781, 3301, 1449, 267, 291, 14, 576, 459, 1246, 3353, 418, 275, 283, 86, 17, 7, 267, 291, 14, 576, 459, 5091, 418, 275, 283, 3167, 6009, 7, 267, 291, 14, 576, 459, 2343, 418, 275, 1052, 267, 291, 14, 576, 459, 2343, 2545, 354, 418, 275, 291, 14, 354, 267, 291, 14, 576, 459, 2343, 2545, 3251, 418, 275, 291, 14, 3251, 398, 291, 14, 576, 459, 16153, 418, 275, 942, 267, 340, 291, 14, 16153, 26, 288, 367, 6513, 315, 291, 14, 16153, 26, 355, 291, 14, 576, 459, 16153, 2278, 740, 6333, 354, 582, 6513, 1552, 398, 291, 14, 576, 459, 1569, 27318, 4933, 264, 1086, 418, 275, 942, 267, 340, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 367, 6513, 315, 291, 14, 1569, 63, 9302, 63, 16153, 26, 355, 291, 14, 576, 459, 1569, 27318, 4933, 264, 1086, 2278, 740, 6333, 354, 582, 6513, 1552, 199, 199, 533, 7591, 6009, 8, 57, 3773, 304, 272, 1449, 8089, 370, 4816, 314, 4244, 1414, 1004, 7249, 1449, 272, 1834, 63, 9302, 63, 16153, 63, 515, 275, 298, 1569, 27318, 4933, 264, 1086, 2, 272, 25563, 63, 515, 275, 298, 16153, 2, 339, 347, 636, 826, 721, 277, 12, 1564, 304, 267, 1449, 3167, 6009, 3787, 2344, 267, 1613, 8, 3167, 6009, 12, 291, 2843, 826, 721, 1317, 29, 1317, 9, 267, 291, 423, 16153, 275, 488, 267, 291, 423, 1569, 63, 9302, 63, 16153, 275, 488, 339, 768, 1829, 272, 347, 1834, 63, 9302, 63, 16153, 8, 277, 304, 267, 1449, 3324, 367, 1834, 63, 9302, 63, 16153, 1449, 267, 340, 291, 423, 1569, 63, 9302, 63, 16153, 365, 488, 26, 288, 291, 423, 1569, 63, 9302, 63, 16153, 275, 291, 14, 362, 8, 3167, 6009, 14, 1569, 63, 9302, 63, 16153, 63, 515, 9, 503, 942, 267, 372, 291, 423, 1569, 63, 9302, 63, 16153, 339, 768, 1569, 63, 9302, 63, 16153, 14, 8345, 272, 347, 1834, 63, 9302, 63, 16153, 8, 277, 12, 25563, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 291, 423, 1569, 63, 9302, 63, 16153, 275, 25563, 339, 768, 1829, 272, 347, 25563, 8, 277, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 340, 440, 291, 423, 16153, 26, 288, 291, 423, 16153, 275, 291, 14, 362, 8, 3167, 6009, 14, 16153, 63, 515, 9, 503, 942, 267, 372, 291, 423, 16153, 339, 768, 16153, 14, 8345, 272, 347, 25563, 8, 277, 12, 25563, 304, 267, 1449, 3324, 367, 25563, 1449, 267, 291, 423, 16153, 275, 25563, 339, 347, 3145, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 2813, 282, 7565, 1449, 267, 2813, 63, 2996, 275, 488, 267, 367, 4280, 12, 6513, 315, 3874, 8, 277, 14, 16153, 304, 288, 340, 6513, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 2813, 63, 2996, 275, 4280, 355, 2059, 398, 340, 2813, 63, 2996, 26, 288, 2150, 291, 14, 16153, 59, 2168, 63, 2996, 61, 288, 372, 715, 398, 372, 756, 339, 347, 3145, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 2813, 282, 1834, 63, 9302, 63, 4731, 1449, 267, 2813, 63, 2996, 275, 488, 267, 367, 4280, 12, 6513, 315, 3874, 8, 277, 14, 1569, 63, 9302, 63, 16153, 304, 288, 340, 6513, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 2813, 63, 2996, 275, 4280, 355, 2059, 398, 340, 2813, 63, 2996, 26, 288, 2150, 291, 14, 1569, 63, 9302, 63, 16153, 59, 2168, 63, 2996, 61, 288, 372, 715, 398, 372, 756, 339, 347, 2342, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 1623, 7565, 2344, 267, 367, 7565, 315, 291, 14, 16153, 26, 288, 340, 7565, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 372, 7565, 398, 372, 488, 339, 347, 2342, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 1623, 7565, 2344, 267, 367, 7565, 315, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 340, 7565, 459, 354, 418, 508, 12864, 63, 4731, 26, 355, 372, 7565, 398, 372, 488, 339, 347, 1050, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 525, 7565, 2344, 267, 340, 291, 14, 16153, 26, 288, 291, 14, 16153, 14, 740, 6333, 354, 582, 12864, 63, 4731, 1552, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 587, 26, 288, 291, 14, 524, 8, 3167, 6009, 14, 16153, 63, 515, 12, 16870, 354, 582, 12864, 63, 4731, 29810, 339, 347, 1050, 63, 1569, 63, 9302, 63, 4731, 8, 277, 12, 12864, 63, 4731, 304, 267, 1449, 525, 1834, 63, 9302, 63, 4731, 2344, 267, 340, 291, 14, 1569, 63, 9302, 63, 16153, 26, 288, 291, 14, 1569, 63, 9302, 63, 16153, 14, 740, 6333, 354, 582, 12864, 63, 4731, 1552, 221, 327, 4287, 26, 3507, 29, 889, 13, 1114, 267, 587, 26, 288, 291, 14, 524, 8, 3167, 6009, 14, 1569, 63, 9302, 63, 16153, 63, 515, 12, 16870, 354, 582, 12864, 63, 4731, 29810, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
podemos-info/odoo
addons/l10n_ch/invoice.py
8
9305
# -*- encoding: utf-8 -*- ############################################################################## # # Author: Nicolas Bessi. Copyright Camptocamp SA # Donors: Hasa Sàrl, Open Net Sàrl and Prisme Solutions Informatique SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from datetime import datetime from osv import fields, osv from tools import mod10r class account_invoice(osv.osv): """Inherit account.invoice in order to add bvr printing functionnalites. BVR is a Swiss payment vector""" _inherit = "account.invoice" ## @param self The object pointer. ## @param cursor a psycopg cursor ## @param user res.user.id that is currently loged ## @parma context a standard dict ## @return a list of tuple (name,value) def _get_reference_type(self, cursor, user, context=None): """Function use by the function field reference_type in order to initalise available BVR Reference Types""" res = super(account_invoice, self)._get_reference_type(cursor, user, context=context) res.append(('bvr', 'BVR')) return res ## @param self The object pointer. ## @param cursor a psycopg cursor ## @param user res.user.id that is currently loged ## @parma context a standard dict ## @param name of the files ## @param args a list of diverse argument ## @parma context a standard dict ## @return a dict (invoice id,amount to pay) def _amount_to_pay(self, cursor, user, ids, name, args, context=None): '''Return the amount still to pay regarding all the payment orders''' if not ids: return {} res = {} for invoice in self.browse(cursor, user, ids, context=context): res[invoice.id] = 0.0 if invoice.move_id: for line in invoice.move_id.line_id: if not line.date_maturity or \ datetime.strptime(line.date_maturity, '%Y-%m-%d') \ < datetime.now(): res[invoice.id] += line.amount_to_pay return res _columns = { ### BVR reference type BVR or FREE 'reference_type': fields.selection(_get_reference_type, 'Reference Type', required=True), ### Partner bank link between bank and partner id 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account', help='The partner bank account to pay\nKeep empty to use the default' ), ### Amount to pay 'amount_to_pay': fields.function(_amount_to_pay, type='float', string='Amount to be paid', help='The amount which should be paid at the current date\n' \ 'minus the amount which is already in payment order'), } ## @param self The object pointer. ## @param cursor a psycopg cursor ## @param user res.user.id that is currently loged ## @parma ids invoices id ## @return a boolean True if valid False if invalid def _check_bvr(self, cr, uid, ids, context=None): """ Function to validate a bvr reference like : 0100054150009>132000000000000000000000014+ 1300132412> The validation is based on l10n_ch """ invoices = self.browse(cr,uid,ids) for invoice in invoices: if invoice.reference_type == 'bvr': if not invoice.reference: return False ## I need help for this bug because in this case # <010001000060190> 052550152684006+ 43435> # the reference 052550152684006 do not match modulo 10 # if mod10r(invoice.reference[:-1]) != invoice.reference and \ len(invoice.reference) == 15: return True # if mod10r(invoice.reference[:-1]) != invoice.reference: return False return True ## @param self The object pointer. ## @param cursor a psycopg cursor ## @param user res.user.id that is currently loged ## @parma ids invoices id ## @return a boolean True if valid False if invalid def _check_reference_type(self, cursor, user, ids, context=None): """Check the customer invoice reference type depending on the BVR reference type and the invoice partner bank type""" for invoice in self.browse(cursor, user, ids): if invoice.type in 'in_invoice': if invoice.partner_bank_id and \ invoice.partner_bank_id.state in \ ('bvrbank', 'bvrpost') and \ invoice.reference_type != 'bvr': return False return True _constraints = [ (_check_bvr, 'Error: Invalid Bvr Number (wrong checksum).', ['reference']), (_check_reference_type, 'Error: BVR reference is required.', ['reference_type']), ] ## @param self The object pointer. ## @param cr a psycopg cursor ## @param uid res.user.id that is currently loged ## @parma ids invoices id ## @parma type the invoice type ## @param partner_id the partner linked to the invoice ## @parma date_invoice date of the invoice ## @parma payment_term inoice payment term ## @param partner_bank_id the partner linked invoice bank ## @return the dict of values with the partner_bank value updated def onchange_partner_id(self, cr, uid, ids, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): """ Function that is call when the partner of the invoice is changed it will retrieve and set the good bank partner bank""" #context not define in signature of function in account module context = {} res = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice, payment_term, partner_bank_id, company_id) bank_id = False if partner_id: if type in ('in_invoice', 'in_refund'): p = self.pool.get('res.partner').browse(cr, uid, partner_id, context) if p.bank_ids: bank_id = p.bank_ids[0].id res['value']['partner_bank_id'] = bank_id else: user = self.pool.get('res.users').browse(cr, uid, uid, context) bank_ids = user.company_id.partner_id.bank_ids if bank_ids: #How to order bank ? for bank in bank_ids: if bank.my_bank: bank_id = bank.id res['value']['partner_bank_id'] = bank_id if partner_bank_id != bank_id: to_update = self.onchange_partner_bank(cr, uid, ids, bank_id) res['value'].update(to_update['value']) return res ## @param self The object pointer. ## @param cursor a psycopg cursor ## @param user res.user.id that is currently loged ## @parma ids invoices id ## @param partner_bank_id the partner linked invoice bank ## @return the dict of values with the reference type value updated def onchange_partner_bank(self, cursor, user, ids, partner_bank_id): """update the reference type depending of the partner bank""" res = {'value': {}} partner_bank_obj = self.pool.get('res.partner.bank') if partner_bank_id: partner_bank = partner_bank_obj.browse(cursor, user, partner_bank_id) if partner_bank.state in ('bvrbank', 'bvrpost'): res['value']['reference_type'] = 'bvr' return res account_invoice() class account_tax_code(osv.osv): """Inherit account tax code in order to add a Case code""" _name = 'account.tax.code' _inherit = "account.tax.code" _columns = { 'code': fields.char('Case Code', size=512), } account_tax_code() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 6529, 26, 30650, 761, 305, 699, 28601, 14, 1898, 24569, 475, 20290, 13950, 199, 3, 259, 7529, 1384, 26, 13481, 65, 428, 26482, 4308, 12, 3232, 5365, 428, 26482, 4308, 436, 510, 5719, 278, 17991, 8653, 1010, 10928, 280, 544, 13950, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2197, 492, 2197, 199, 504, 9506, 492, 1504, 12, 9506, 199, 504, 7249, 492, 3413, 709, 82, 199, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 272, 408, 23542, 2933, 14, 5404, 315, 1865, 370, 1050, 330, 10922, 272, 16116, 805, 78, 279, 4033, 14, 699, 20271, 365, 282, 16666, 19857, 11628, 5477, 624, 272, 485, 6486, 275, 298, 2048, 14, 5404, 2, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 1107, 282, 769, 402, 2008, 334, 354, 12, 585, 9, 272, 347, 485, 362, 63, 4443, 63, 466, 8, 277, 12, 3920, 12, 922, 12, 1067, 29, 403, 304, 267, 408, 3481, 675, 701, 314, 805, 901, 3659, 63, 466, 315, 1865, 370, 4205, 279, 572, 2808, 267, 699, 20271, 10944, 18851, 624, 267, 522, 275, 1613, 8, 2048, 63, 5404, 12, 291, 10445, 362, 63, 4443, 63, 466, 8, 3937, 12, 922, 12, 355, 1067, 29, 1100, 9, 267, 522, 14, 740, 4725, 66, 10922, 297, 283, 34, 20271, 1333, 267, 372, 522, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 635, 536, 402, 314, 1584, 272, 925, 768, 635, 1249, 282, 769, 402, 487, 2077, 1423, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 1107, 282, 221, 1211, 334, 5404, 1305, 12, 4606, 370, 8633, 9, 272, 347, 485, 4606, 63, 475, 63, 5989, 8, 277, 12, 3920, 12, 922, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 1449, 1767, 314, 5982, 5139, 370, 8633, 12602, 1006, 314, 11628, 15460, 2344, 267, 340, 440, 2762, 26, 288, 372, 1052, 267, 522, 275, 1052, 267, 367, 8485, 315, 291, 14, 4570, 8, 3937, 12, 922, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 5404, 14, 344, 61, 275, 378, 14, 16, 288, 340, 8485, 14, 1185, 63, 344, 26, 355, 367, 1004, 315, 8485, 14, 1185, 63, 344, 14, 604, 63, 344, 26, 490, 340, 440, 1004, 14, 602, 63, 569, 5581, 503, 971, 1169, 2197, 14, 9866, 8, 604, 14, 602, 63, 569, 5581, 12, 1543, 57, 3295, 77, 3295, 68, 358, 971, 1169, 665, 2197, 14, 2131, 837, 717, 522, 59, 5404, 14, 344, 61, 847, 1004, 14, 4606, 63, 475, 63, 5989, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 6754, 699, 20271, 3659, 730, 699, 20271, 503, 481, 5271, 267, 283, 4443, 63, 466, 356, 1504, 14, 5592, 1547, 362, 63, 4443, 63, 466, 12, 288, 283, 5083, 2434, 297, 1415, 29, 549, 395, 267, 6754, 31351, 16297, 2142, 3382, 16297, 436, 5854, 1305, 267, 283, 3899, 63, 9860, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 14, 9860, 297, 283, 14814, 9973, 297, 288, 1720, 534, 1918, 5854, 16297, 2933, 370, 8633, 60, 78, 18567, 2701, 370, 675, 314, 849, 7, 288, 2318, 267, 6754, 26701, 370, 8633, 267, 283, 4606, 63, 475, 63, 5989, 356, 1504, 14, 1593, 1547, 4606, 63, 475, 63, 5989, 12, 288, 730, 534, 1609, 297, 7205, 1059, 534, 18785, 370, 506, 30677, 297, 288, 1720, 534, 1918, 5982, 1314, 1077, 506, 30677, 737, 314, 1453, 1434, 60, 78, 7, 971, 490, 283, 13084, 314, 5982, 1314, 365, 2575, 315, 11628, 1865, 659, 272, 789, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 2762, 26175, 1305, 272, 925, 768, 1107, 282, 5046, 715, 340, 1686, 756, 340, 3866, 272, 347, 485, 1074, 63, 66, 10922, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 6801, 370, 4107, 282, 330, 10922, 3659, 2839, 520, 267, 378, 5279, 1477, 1046, 21144, 30, 6557, 9409, 3273, 1079, 11, 4944, 4587, 12744, 713, 30, 267, 710, 6411, 365, 4079, 641, 634, 709, 78, 63, 335, 267, 408, 267, 26175, 275, 291, 14, 4570, 8, 1556, 12, 1535, 12, 1580, 9, 267, 367, 8485, 315, 26175, 26, 288, 340, 8485, 14, 4443, 63, 466, 508, 283, 66, 10922, 356, 355, 340, 440, 8485, 14, 4443, 26, 490, 372, 756, 355, 925, 473, 1929, 1720, 367, 642, 6519, 2952, 315, 642, 1930, 355, 327, 665, 614, 4183, 993, 24539, 2710, 30, 22528, 2299, 11164, 1479, 1349, 8010, 11, 841, 1082, 1276, 30, 355, 327, 314, 3659 ]
[ 1882, 2644, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 6529, 26, 30650, 761, 305, 699, 28601, 14, 1898, 24569, 475, 20290, 13950, 199, 3, 259, 7529, 1384, 26, 13481, 65, 428, 26482, 4308, 12, 3232, 5365, 428, 26482, 4308, 436, 510, 5719, 278, 17991, 8653, 1010, 10928, 280, 544, 13950, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 2197, 492, 2197, 199, 504, 9506, 492, 1504, 12, 9506, 199, 504, 7249, 492, 3413, 709, 82, 199, 199, 533, 2933, 63, 5404, 8, 4795, 14, 4795, 304, 272, 408, 23542, 2933, 14, 5404, 315, 1865, 370, 1050, 330, 10922, 272, 16116, 805, 78, 279, 4033, 14, 699, 20271, 365, 282, 16666, 19857, 11628, 5477, 624, 272, 485, 6486, 275, 298, 2048, 14, 5404, 2, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 1107, 282, 769, 402, 2008, 334, 354, 12, 585, 9, 272, 347, 485, 362, 63, 4443, 63, 466, 8, 277, 12, 3920, 12, 922, 12, 1067, 29, 403, 304, 267, 408, 3481, 675, 701, 314, 805, 901, 3659, 63, 466, 315, 1865, 370, 4205, 279, 572, 2808, 267, 699, 20271, 10944, 18851, 624, 267, 522, 275, 1613, 8, 2048, 63, 5404, 12, 291, 10445, 362, 63, 4443, 63, 466, 8, 3937, 12, 922, 12, 355, 1067, 29, 1100, 9, 267, 522, 14, 740, 4725, 66, 10922, 297, 283, 34, 20271, 1333, 267, 372, 522, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 635, 536, 402, 314, 1584, 272, 925, 768, 635, 1249, 282, 769, 402, 487, 2077, 1423, 272, 925, 768, 462, 391, 1067, 282, 4465, 1211, 272, 925, 768, 1107, 282, 221, 1211, 334, 5404, 1305, 12, 4606, 370, 8633, 9, 272, 347, 485, 4606, 63, 475, 63, 5989, 8, 277, 12, 3920, 12, 922, 12, 2762, 12, 536, 12, 1249, 12, 1067, 29, 403, 304, 267, 1449, 1767, 314, 5982, 5139, 370, 8633, 12602, 1006, 314, 11628, 15460, 2344, 267, 340, 440, 2762, 26, 288, 372, 1052, 267, 522, 275, 1052, 267, 367, 8485, 315, 291, 14, 4570, 8, 3937, 12, 922, 12, 2762, 12, 1067, 29, 1100, 304, 288, 522, 59, 5404, 14, 344, 61, 275, 378, 14, 16, 288, 340, 8485, 14, 1185, 63, 344, 26, 355, 367, 1004, 315, 8485, 14, 1185, 63, 344, 14, 604, 63, 344, 26, 490, 340, 440, 1004, 14, 602, 63, 569, 5581, 503, 971, 1169, 2197, 14, 9866, 8, 604, 14, 602, 63, 569, 5581, 12, 1543, 57, 3295, 77, 3295, 68, 358, 971, 1169, 665, 2197, 14, 2131, 837, 717, 522, 59, 5404, 14, 344, 61, 847, 1004, 14, 4606, 63, 475, 63, 5989, 267, 372, 522, 339, 485, 3406, 275, 469, 267, 6754, 699, 20271, 3659, 730, 699, 20271, 503, 481, 5271, 267, 283, 4443, 63, 466, 356, 1504, 14, 5592, 1547, 362, 63, 4443, 63, 466, 12, 288, 283, 5083, 2434, 297, 1415, 29, 549, 395, 267, 6754, 31351, 16297, 2142, 3382, 16297, 436, 5854, 1305, 267, 283, 3899, 63, 9860, 63, 344, 356, 1504, 14, 3479, 18, 368, 360, 470, 14, 3899, 14, 9860, 297, 283, 14814, 9973, 297, 288, 1720, 534, 1918, 5854, 16297, 2933, 370, 8633, 60, 78, 18567, 2701, 370, 675, 314, 849, 7, 288, 2318, 267, 6754, 26701, 370, 8633, 267, 283, 4606, 63, 475, 63, 5989, 356, 1504, 14, 1593, 1547, 4606, 63, 475, 63, 5989, 12, 288, 730, 534, 1609, 297, 7205, 1059, 534, 18785, 370, 506, 30677, 297, 288, 1720, 534, 1918, 5982, 1314, 1077, 506, 30677, 737, 314, 1453, 1434, 60, 78, 7, 971, 490, 283, 13084, 314, 5982, 1314, 365, 2575, 315, 11628, 1865, 659, 272, 789, 339, 925, 768, 635, 291, 710, 909, 7849, 14, 272, 925, 768, 635, 3920, 282, 15492, 3920, 272, 925, 768, 635, 922, 522, 14, 751, 14, 344, 626, 365, 5544, 560, 3046, 272, 925, 768, 462, 391, 2762, 26175, 1305, 272, 925, 768, 1107, 282, 5046, 715, 340, 1686, 756, 340, 3866, 272, 347, 485, 1074, 63, 66, 10922, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 408, 267, 6801, 370, 4107, 282, 330, 10922, 3659, 2839, 520, 267, 378, 5279, 1477, 1046, 21144, 30, 6557, 9409, 3273, 1079, 11, 4944, 4587, 12744, 713, 30, 267, 710, 6411, 365, 4079, 641, 634, 709, 78, 63, 335, 267, 408, 267, 26175, 275, 291, 14, 4570, 8, 1556, 12, 1535, 12, 1580, 9, 267, 367, 8485, 315, 26175, 26, 288, 340, 8485, 14, 4443, 63, 466, 508, 283, 66, 10922, 356, 355, 340, 440, 8485, 14, 4443, 26, 490, 372, 756, 355, 925, 473, 1929, 1720, 367, 642, 6519, 2952, 315, 642, 1930, 355, 327, 665, 614, 4183, 993, 24539, 2710, 30, 22528, 2299, 11164, 1479, 1349, 8010, 11, 841, 1082, 1276, 30, 355, 327, 314, 3659, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
NeuroRoboticTech/Jetduino
Software/Python/grove_single_axis_analog_gyro.py
1
2819
#!/usr/bin/env python # # Jetduino Example for using the Grove Single Axis Analog Gyro (http://www.seeedstudio.com/wiki/Grove_-_Single_Axis_Analog_Gyro) # # The Jetduino connects the Jetson and Grove sensors. You can learn more about the Jetduino here: http://www.NeuroRoboticTech.com/Projects/Jetduino # # Have a question about this example? Ask on the forums here: http://www.NeuroRoboticTech.com/Forum # ''' ## License The MIT License (MIT) GrovePi for the Raspberry Pi: an open source platform for connecting Grove Sensors to the Raspberry Pi. Copyright (C) 2015 Dexter Industries Jetduino for the Jetson TK1/TX1: an open source platform for connecting Grove Sensors to the Jetson embedded supercomputers. Copyright (C) 2016 NeuroRobotic Technologies Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' import time import jetduino from jetduino_pins import * # Connect the Grove Single Axis Analog Gyro to analog port A0 # SIG,NC,VCC,GND sensor = ARD_A0 jetduino.pinMode(sensor, INPUT_PIN) # calibration print ("calibrating...") sum = 0 errors = 0 for x in range(0, 100): try: # Get sensor value v = jetduino.analogRead(sensor) sum += v #time.sleep(.05) except IOError: print ("Error") errors += 1 if errors == 100: print ("unable to calibrate") raise SystemExit reference_value = sum / (100 - errors) print ("finished calibrating") print ("reference_value =", reference_value) # ready while True: try: # Get sensor value sensor_value = jetduino.analogRead(sensor) # Calculate angular velocity (deg/s) velocity = ((float)(sensor_value - reference_value) * 4930.0) / 1023.0 / 0.67 print ("sensor_value =", sensor_value, " velocity =", velocity) time.sleep(.5) except IOError: print ("Error")
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1603, 386, 2033, 10175, 5679, 367, 1808, 314, 598, 11750, 13050, 23205, 1626, 2548, 598, 89, 293, 334, 1014, 921, 1544, 14, 3239, 379, 19806, 14, 957, 15, 6797, 15, 39, 11750, 32069, 63, 7200, 63, 11220, 63, 2493, 2548, 63, 39, 89, 293, 9, 199, 3, 199, 3, 710, 1603, 386, 2033, 10175, 4907, 83, 314, 1603, 386, 834, 436, 598, 11750, 19678, 14, 221, 2047, 883, 12537, 1655, 3595, 314, 1603, 386, 2033, 10175, 2348, 26, 221, 1455, 921, 1544, 14, 4698, 9129, 3863, 656, 764, 6301, 335, 14, 957, 15, 24286, 15, 42, 386, 2033, 10175, 199, 3, 199, 3, 26858, 282, 7894, 3595, 642, 2893, 31, 221, 30481, 641, 314, 21575, 83, 2348, 26, 221, 1455, 921, 1544, 14, 4698, 9129, 3863, 656, 764, 6301, 335, 14, 957, 15, 1858, 453, 199, 3, 199, 2344, 199, 309, 844, 199, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 39, 11750, 10542, 367, 314, 820, 20222, 605, 651, 19835, 26, 376, 1551, 1350, 4298, 367, 18170, 598, 11750, 428, 17564, 370, 314, 820, 20222, 605, 651, 19835, 14, 199, 7384, 334, 35, 9, 6900, 221, 577, 476, 351, 473, 977, 85, 816, 397, 199, 199, 42, 386, 2033, 10175, 367, 314, 1603, 386, 834, 377, 43, 17, 15, 10051, 17, 26, 376, 1551, 1350, 4298, 367, 18170, 221, 199, 39, 11750, 428, 17564, 370, 314, 1603, 386, 834, 12169, 1613, 863, 19717, 14, 199, 7384, 334, 35, 9, 7800, 221, 5612, 9129, 3863, 656, 764, 19215, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 452, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 18061, 4141, 14, 199, 2344, 199, 199, 646, 900, 199, 646, 1335, 386, 2033, 10175, 199, 504, 1335, 386, 2033, 10175, 63, 21746, 492, 627, 199, 199, 3, 15175, 314, 598, 11750, 13050, 23205, 1626, 2548, 598, 89, 293, 370, 20439, 1844, 437, 16, 199, 3, 15522, 12, 6389, 12, 54, 2571, 12, 39, 8711, 199, 8956, 275, 4160, 36, 63, 33, 16, 199, 199, 74, 386, 2033, 10175, 14, 7751, 1385, 8, 8956, 12, 21955, 63, 30929, 9, 199, 199, 3, 25365, 199, 1361, 1689, 15737, 10417, 12594, 199, 1838, 275, 378, 199, 2550, 275, 378, 199, 509, 671, 315, 1425, 8, 16, 12, 2948, 304, 272, 862, 26, 267, 327, 2372, 8778, 574, 267, 373, 275, 1335, 386, 2033, 10175, 14, 290, 2548, 3284, 8, 8956, 9, 267, 3089, 847, 373, 267, 327, 521, 14, 4532, 13417, 1717, 9, 272, 871, 5925, 26, 267, 870, 1689, 547, 531, 267, 2552, 847, 413, 199, 199, 692, 2552, 508, 2948, 26, 272, 870, 1689, 17200, 370, 12855, 1866, 531, 272, 746, 14838, 199, 199, 4443, 63, 585, 275, 3089, 1182, 334, 1960, 446, 2552, 9, 199, 199, 1361, 1689, 8669, 12855, 10417, 531, 199, 1361, 1689, 4443, 63, 585, 20815, 3659, 63, 585, 9, 199, 199, 3, 10144, 199, 6710, 715, 26, 272, 862, 26, 267, 327, 2372, 8778, 574, 267, 8778, 63, 585, 275, 1335, 386, 2033, 10175, 14, 290, 2548, 3284, 8, 8956, 9, 398, 327, 12707, 30921, 20508, 334, 6458, 15, 83, 9, 267, 20508, 275, 3666, 1609, 5130, 8956, 63, 585, 446, 3659, 63, 585, 9, 627, 12260, 1216, 14, 16, 9, 1182, 12996, 19, 14, 16, 1182, 378, 14, 1822, 398, 870, 1689, 8956, 63, 585, 20815, 8778, 63, 585, 12, 298, 20508, 20815, 20508, 9, 267, 900, 14, 4532, 13417, 21, 9, 339, 871, 5925, 26, 2126, 870, 1689, 547, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1603, 386, 2033, 10175, 5679, 367, 1808, 314, 598, 11750, 13050, 23205, 1626, 2548, 598, 89, 293, 334, 1014, 921, 1544, 14, 3239, 379, 19806, 14, 957, 15, 6797, 15, 39, 11750, 32069, 63, 7200, 63, 11220, 63, 2493, 2548, 63, 39, 89, 293, 9, 199, 3, 199, 3, 710, 1603, 386, 2033, 10175, 4907, 83, 314, 1603, 386, 834, 436, 598, 11750, 19678, 14, 221, 2047, 883, 12537, 1655, 3595, 314, 1603, 386, 2033, 10175, 2348, 26, 221, 1455, 921, 1544, 14, 4698, 9129, 3863, 656, 764, 6301, 335, 14, 957, 15, 24286, 15, 42, 386, 2033, 10175, 199, 3, 199, 3, 26858, 282, 7894, 3595, 642, 2893, 31, 221, 30481, 641, 314, 21575, 83, 2348, 26, 221, 1455, 921, 1544, 14, 4698, 9129, 3863, 656, 764, 6301, 335, 14, 957, 15, 1858, 453, 199, 3, 199, 2344, 199, 309, 844, 199, 199, 1918, 10697, 844, 334, 13965, 9, 199, 199, 39, 11750, 10542, 367, 314, 820, 20222, 605, 651, 19835, 26, 376, 1551, 1350, 4298, 367, 18170, 598, 11750, 428, 17564, 370, 314, 820, 20222, 605, 651, 19835, 14, 199, 7384, 334, 35, 9, 6900, 221, 577, 476, 351, 473, 977, 85, 816, 397, 199, 199, 42, 386, 2033, 10175, 367, 314, 1603, 386, 834, 377, 43, 17, 15, 10051, 17, 26, 376, 1551, 1350, 4298, 367, 18170, 221, 199, 39, 11750, 428, 17564, 370, 314, 1603, 386, 834, 12169, 1613, 863, 19717, 14, 199, 7384, 334, 35, 9, 7800, 221, 5612, 9129, 3863, 656, 764, 19215, 199, 199, 7980, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 1618, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 262, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 475, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 16847, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 70, 13399, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 199, 1918, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 199, 452, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 199, 18061, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 8947, 5177, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 38, 3061, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 5580, 4149, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 2673, 2477, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 1877, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 18061, 4141, 14, 199, 2344, 199, 199, 646, 900, 199, 646, 1335, 386, 2033, 10175, 199, 504, 1335, 386, 2033, 10175, 63, 21746, 492, 627, 199, 199, 3, 15175, 314, 598, 11750, 13050, 23205, 1626, 2548, 598, 89, 293, 370, 20439, 1844, 437, 16, 199, 3, 15522, 12, 6389, 12, 54, 2571, 12, 39, 8711, 199, 8956, 275, 4160, 36, 63, 33, 16, 199, 199, 74, 386, 2033, 10175, 14, 7751, 1385, 8, 8956, 12, 21955, 63, 30929, 9, 199, 199, 3, 25365, 199, 1361, 1689, 15737, 10417, 12594, 199, 1838, 275, 378, 199, 2550, 275, 378, 199, 509, 671, 315, 1425, 8, 16, 12, 2948, 304, 272, 862, 26, 267, 327, 2372, 8778, 574, 267, 373, 275, 1335, 386, 2033, 10175, 14, 290, 2548, 3284, 8, 8956, 9, 267, 3089, 847, 373, 267, 327, 521, 14, 4532, 13417, 1717, 9, 272, 871, 5925, 26, 267, 870, 1689, 547, 531, 267, 2552, 847, 413, 199, 199, 692, 2552, 508, 2948, 26, 272, 870, 1689, 17200, 370, 12855, 1866, 531, 272, 746, 14838, 199, 199, 4443, 63, 585, 275, 3089, 1182, 334, 1960, 446, 2552, 9, 199, 199, 1361, 1689, 8669, 12855, 10417, 531, 199, 1361, 1689, 4443, 63, 585, 20815, 3659, 63, 585, 9, 199, 199, 3, 10144, 199, 6710, 715, 26, 272, 862, 26, 267, 327, 2372, 8778, 574, 267, 8778, 63, 585, 275, 1335, 386, 2033, 10175, 14, 290, 2548, 3284, 8, 8956, 9, 398, 327, 12707, 30921, 20508, 334, 6458, 15, 83, 9, 267, 20508, 275, 3666, 1609, 5130, 8956, 63, 585, 446, 3659, 63, 585, 9, 627, 12260, 1216, 14, 16, 9, 1182, 12996, 19, 14, 16, 1182, 378, 14, 1822, 398, 870, 1689, 8956, 63, 585, 20815, 8778, 63, 585, 12, 298, 20508, 20815, 20508, 9, 267, 900, 14, 4532, 13417, 21, 9, 339, 871, 5925, 26, 2126, 870, 1689, 547, 531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cpe/VAMDC-VALD
nodes/basecol/bastest/views.py
4
3565
# -*- coding: utf-8 -*- # Create your views here. from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.db.models import Q from DjBASECOL.bastest.models import RefsArticles,RefsGroups,ETables,Elements from DjNode.tapservice.sqlparse import where2q RETURNABLES={\ 'SourceID':'"BAS"+str(Source.article.idarticle)', 'SourceTitle':'Source.article.title', 'SourceCategory':'"journal"', 'SourceYear':'Source.article.year', 'SourceName':'Source.article.journal.name', 'SourceVolume':'Source.article.volume', 'SourcePageBegin':'re.compile(r"\D+").split(Source.article.page)[0]', 'SourcePageEnd':'re.compile(r"\D+").split(Source.article.page)[1]', 'SourceURI':'Source.article.url', 'SourceAuthorName':'[obj.fullname for obj in Source.article.authors.all()]', 'MolecularSpeciesOrdinaryStructuralFormula':'Moldesc.designation', 'MolecularSpeciesStoichiometrcFormula':'Moldesc.stchform', 'MolecularSpeciesChemicalName':'Moldesc.latex', 'MolecularSpeciesMolecularWeightUnits':'amu', 'MolecularSpeciesMolecularWeight':'Moldesc.molecularmass', 'MolecularSpeciesComment':'Moldesc.idelementtype' } RESTRICTABLES={\ 'MolecularStateEnergyValue':'symmels__etables__levels__energy', 'mscn':'designation', 'MolecularSpeciesChemicalName':'designation', 'MolecularSpeciesMolecularWeight':'molecularmass', } # this imports the sql-parser and some helper-functions, notably where2q() from DjNode.tapservice.sqlparse import * def getBASECOLSources(states): ris=set([]) for se in states.all(): for syme in se.symmels.all(): for et in syme.etables.all(): ris.add(et.idrefgroup) #refids = [obj.symmels.all().etables.all().idrefgroup for obj in states.all()] #rarts=RefsGroups.objects.select_related('article__journal','article__authors','article__adsnote').filter(pk=1121) return RefsGroups.objects.select_related('article__journal','article__authors','article__adsnote').filter(pk__in= ris) #return rarts def getBASECOLStates(q): return Elements.objects.select_related(depth=4).filter(q) def setupResults(sql): q=where2q(sql.where,RESTRICTABLES) try: q=eval(q) except: return {} #states = getBASECOLStates(q) states = Elements.objects.filter(q) sources = getBASECOLSources(states) return {\ 'Sources':sources, 'MoleStates':states } # "real" views. def index(request): return HttpResponse("Hello, world. You're at the basecol index.") def authors(request, ref_id): rarts=RefsGroups.objects.select_related('article__journal','article__authors','article__adsnote').filter(pk=ref_id) resp="Titles:<br>" resp+="<UL>" for rag in rarts.all(): rart=rag.article resp+="<li> %s in %s (%s)<ol>"%(rart.title,rart.journal.smallname,rart.adsnote.value) for raut in rart.authors.all(): resp+="<li>%s %s" %(raut.surname,raut.firstname) resp+="</ol>" resp+="</UL>" return HttpResponse(resp) def etable(request, ref_id): eta=Energytables.objects.select_related('symmelement__element','symmelement__symmetry').filter(pk=ref_id) resp="ETable:" for et in eta.all(): resp+='<ul><li>%s'%et.title resp+='<br>el %s %s'%(et.symmelement.symmetry.designation,et.symmelement.element.designation) resp+='<br>levels<ol>' elevs=ELevels.objects.filter(idenergytable=ref_id) for elev in elevs.all(): resp+='<li>level %s energy %s'%(elev.level,elev.energy) resp+='</ol></ul>' return HttpResponse(resp)
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2790, 2195, 6858, 2348, 14, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 199, 504, 577, 74, 5825, 3978, 14, 31917, 396, 14, 992, 492, 22165, 7221, 83, 12, 25730, 10177, 12, 775, 5921, 12, 6255, 199, 504, 577, 74, 1716, 14, 16609, 1364, 14, 3009, 1122, 492, 2382, 18, 81, 421, 199, 9677, 17041, 3126, 60, 199, 7, 2980, 998, 356, 4065, 20205, 7709, 495, 8, 2980, 14, 6934, 14, 344, 6934, 3196, 199, 7, 2980, 6888, 5242, 2980, 14, 6934, 14, 1213, 297, 199, 7, 2980, 7841, 356, 4065, 7067, 6949, 199, 7, 2980, 15731, 5242, 2980, 14, 6934, 14, 3403, 297, 199, 7, 2980, 985, 5242, 2980, 14, 6934, 14, 7067, 14, 354, 297, 199, 7, 2980, 6464, 5242, 2980, 14, 6934, 14, 2405, 297, 199, 7, 2980, 3276, 5595, 5242, 264, 14, 2014, 8, 82, 3212, 36, 11, 3471, 1294, 8, 2980, 14, 6934, 14, 1606, 2788, 16, 4300, 199, 7, 2980, 3276, 3005, 5242, 264, 14, 2014, 8, 82, 3212, 36, 11, 3471, 1294, 8, 2980, 14, 6934, 14, 1606, 2788, 17, 4300, 199, 7, 2980, 7639, 5242, 2980, 14, 6934, 14, 633, 297, 199, 7, 2980, 5949, 985, 356, 3894, 1113, 14, 9930, 367, 1559, 315, 5800, 14, 6934, 14, 8149, 14, 452, 342, 4300, 199, 199, 7, 3716, 10251, 2238, 6154, 397, 2844, 68, 5354, 4836, 4889, 28533, 5242, 45, 393, 3257, 14, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 4759, 1158, 73, 1377, 454, 67, 28533, 5242, 45, 393, 3257, 14, 270, 335, 964, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 20335, 77, 2652, 985, 5242, 45, 393, 3257, 14, 7572, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 15121, 5242, 455, 85, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 5242, 45, 393, 3257, 14, 573, 10251, 2238, 11535, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 7488, 5242, 45, 393, 3257, 14, 2655, 968, 466, 7, 199, 199, 93, 199, 199, 15740, 50, 6196, 17041, 3126, 60, 199, 7, 3716, 10251, 2238, 2223, 9900, 1110, 5242, 3840, 278, 478, 363, 386, 5921, 363, 11402, 363, 8443, 297, 199, 6704, 551, 78, 5242, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 20335, 77, 2652, 985, 5242, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 5242, 573, 10251, 2238, 11535, 297, 199, 93, 421, 199, 3, 642, 8925, 314, 3875, 13, 2087, 436, 2005, 5922, 13, 5777, 12, 440, 6665, 2382, 18, 81, 342, 199, 504, 577, 74, 1716, 14, 16609, 1364, 14, 3009, 1122, 492, 627, 199, 199, 318, 664, 5825, 3978, 13959, 8, 4981, 304, 272, 221, 5719, 29, 409, 4157, 272, 367, 542, 315, 6363, 14, 452, 837, 267, 367, 1847, 278, 315, 542, 14, 3840, 278, 478, 14, 452, 837, 881, 367, 10844, 315, 1847, 278, 14, 386, 5921, 14, 452, 837, 1598, 221, 5719, 14, 525, 8, 386, 14, 344, 1121, 923, 9, 489, 327, 264, 329, 795, 275, 359, 1113, 14, 3840, 278, 478, 14, 452, 1252, 386, 5921, 14, 452, 1252, 344, 1121, 923, 367, 1559, 315, 6363, 14, 452, 5106, 272, 327, 82, 32611, 29, 25730, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 29, 6094, 17, 9, 272, 372, 22165, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 363, 262, 29, 221, 5719, 9, 272, 327, 1107, 519, 32611, 199, 199, 318, 664, 5825, 3978, 18010, 8, 81, 304, 272, 372, 6566, 83, 14, 1462, 14, 2416, 63, 2407, 8, 4631, 29, 20, 680, 1541, 8, 81, 9, 199, 199, 318, 3272, 6579, 8, 3009, 304, 272, 1894, 29, 4509, 18, 81, 8, 3009, 14, 4509, 12, 15740, 50, 6196, 17041, 9, 272, 862, 26, 1894, 29, 2579, 8, 81, 9, 272, 871, 26, 372, 1052, 339, 327, 4981, 275, 664, 5825, 3978, 18010, 8, 81, 9, 272, 6363, 275, 6566, 83, 14, 1462, 14, 1541, 8, 81, 9, 272, 5274, 275, 664, 5825, 3978, 13959, 8, 4981, 9, 2286, 372, 9459, 2286, 283, 13959, 356, 4553, 12, 272, 283, 3716, 274, 18010, 356, 4981, 272, 789, 421, 199, 3, 298, 3093, 2, 6858, 14, 199, 199, 318, 1478, 8, 1069, 304, 272, 372, 6183, 480, 6257, 12, 6701, 14, 2047, 3984, 737, 314, 1300, 761, 1478, 2685, 1362, 199, 318, 11462, 8, 1069, 12, 2984, 63, 344, 304, 272, 519, 32611, 29, 25730, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 29, 1121, 63, 344, 9, 272, 3085, 628, 52, 390, 2978, 16875, 3289, 4335, 272, 3085, 11, 28066, 1293, 4335, 272, 367, 25627, 315, 519, 32611, 14, 452, 837, 267, 519, 580, 29, 2527, 14, 6934, 267, 3085, 11, 28066, 317, 30, 450, 83, 315, 450, 83, 4366, 83, 21528, 393, 4335, 2840, 82, 580, 14, 1213, 12, 82, 580, 14, 7067, 14, 7241, 354, 12, 82, 580, 14, 9402, 4610, 14, 585, 9, 267, 367, 660, 337, 315, 519, 580, 14, 8149, 14, 452, 837, 288, 3085, 11, 28066, 317, 6598, 83, 450, 83, 2, 2818, 345, 337, 14, 30959, 12, 345, 337, 14, 25603, 9, 267, 3085, 11, 628, 1108, 393, 4335, 272, 3085, 11, 628, 1108, 1293, 4335, 272, 372, 6183, 8, 4518, 9, 421, 199, 318, 325, 1224, 8, 1069, 12, 2984, 63, 344, 304, 272, 20356, 29, 9900, 5987, 14, 1462, 14, 2416, 63, 2407, 360, 3840, 278, 968, 363, 2108, 1673, 3840, 278, 968, 363, 3840, 10987, 1959, 1541, 8, 2051, 29, 1121, 63, 344, 9, 272, 3085, 628, 775, 461, 5424, 272, 367, 10844, 315, 20356, 14, 452, 837, 267, 3085, 11, 15829, 348, 2535, 317, 6598, 83, 5956, 386, 14, 1213, 267, 3085, 11, 15829, 3289, 30 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 2790, 2195, 6858, 2348, 14, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 664, 63, 785, 63, 269, 63, 5188, 199, 504, 1639, 14, 697, 14, 992, 492, 1413, 199, 199, 504, 577, 74, 5825, 3978, 14, 31917, 396, 14, 992, 492, 22165, 7221, 83, 12, 25730, 10177, 12, 775, 5921, 12, 6255, 199, 504, 577, 74, 1716, 14, 16609, 1364, 14, 3009, 1122, 492, 2382, 18, 81, 421, 199, 9677, 17041, 3126, 60, 199, 7, 2980, 998, 356, 4065, 20205, 7709, 495, 8, 2980, 14, 6934, 14, 344, 6934, 3196, 199, 7, 2980, 6888, 5242, 2980, 14, 6934, 14, 1213, 297, 199, 7, 2980, 7841, 356, 4065, 7067, 6949, 199, 7, 2980, 15731, 5242, 2980, 14, 6934, 14, 3403, 297, 199, 7, 2980, 985, 5242, 2980, 14, 6934, 14, 7067, 14, 354, 297, 199, 7, 2980, 6464, 5242, 2980, 14, 6934, 14, 2405, 297, 199, 7, 2980, 3276, 5595, 5242, 264, 14, 2014, 8, 82, 3212, 36, 11, 3471, 1294, 8, 2980, 14, 6934, 14, 1606, 2788, 16, 4300, 199, 7, 2980, 3276, 3005, 5242, 264, 14, 2014, 8, 82, 3212, 36, 11, 3471, 1294, 8, 2980, 14, 6934, 14, 1606, 2788, 17, 4300, 199, 7, 2980, 7639, 5242, 2980, 14, 6934, 14, 633, 297, 199, 7, 2980, 5949, 985, 356, 3894, 1113, 14, 9930, 367, 1559, 315, 5800, 14, 6934, 14, 8149, 14, 452, 342, 4300, 199, 199, 7, 3716, 10251, 2238, 6154, 397, 2844, 68, 5354, 4836, 4889, 28533, 5242, 45, 393, 3257, 14, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 4759, 1158, 73, 1377, 454, 67, 28533, 5242, 45, 393, 3257, 14, 270, 335, 964, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 20335, 77, 2652, 985, 5242, 45, 393, 3257, 14, 7572, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 15121, 5242, 455, 85, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 5242, 45, 393, 3257, 14, 573, 10251, 2238, 11535, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 7488, 5242, 45, 393, 3257, 14, 2655, 968, 466, 7, 199, 199, 93, 199, 199, 15740, 50, 6196, 17041, 3126, 60, 199, 7, 3716, 10251, 2238, 2223, 9900, 1110, 5242, 3840, 278, 478, 363, 386, 5921, 363, 11402, 363, 8443, 297, 199, 6704, 551, 78, 5242, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 20335, 77, 2652, 985, 5242, 14748, 425, 297, 199, 7, 3716, 10251, 2238, 6154, 397, 3716, 10251, 2238, 16359, 5242, 573, 10251, 2238, 11535, 297, 199, 93, 421, 199, 3, 642, 8925, 314, 3875, 13, 2087, 436, 2005, 5922, 13, 5777, 12, 440, 6665, 2382, 18, 81, 342, 199, 504, 577, 74, 1716, 14, 16609, 1364, 14, 3009, 1122, 492, 627, 199, 199, 318, 664, 5825, 3978, 13959, 8, 4981, 304, 272, 221, 5719, 29, 409, 4157, 272, 367, 542, 315, 6363, 14, 452, 837, 267, 367, 1847, 278, 315, 542, 14, 3840, 278, 478, 14, 452, 837, 881, 367, 10844, 315, 1847, 278, 14, 386, 5921, 14, 452, 837, 1598, 221, 5719, 14, 525, 8, 386, 14, 344, 1121, 923, 9, 489, 327, 264, 329, 795, 275, 359, 1113, 14, 3840, 278, 478, 14, 452, 1252, 386, 5921, 14, 452, 1252, 344, 1121, 923, 367, 1559, 315, 6363, 14, 452, 5106, 272, 327, 82, 32611, 29, 25730, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 29, 6094, 17, 9, 272, 372, 22165, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 363, 262, 29, 221, 5719, 9, 272, 327, 1107, 519, 32611, 199, 199, 318, 664, 5825, 3978, 18010, 8, 81, 304, 272, 372, 6566, 83, 14, 1462, 14, 2416, 63, 2407, 8, 4631, 29, 20, 680, 1541, 8, 81, 9, 199, 199, 318, 3272, 6579, 8, 3009, 304, 272, 1894, 29, 4509, 18, 81, 8, 3009, 14, 4509, 12, 15740, 50, 6196, 17041, 9, 272, 862, 26, 1894, 29, 2579, 8, 81, 9, 272, 871, 26, 372, 1052, 339, 327, 4981, 275, 664, 5825, 3978, 18010, 8, 81, 9, 272, 6363, 275, 6566, 83, 14, 1462, 14, 1541, 8, 81, 9, 272, 5274, 275, 664, 5825, 3978, 13959, 8, 4981, 9, 2286, 372, 9459, 2286, 283, 13959, 356, 4553, 12, 272, 283, 3716, 274, 18010, 356, 4981, 272, 789, 421, 199, 3, 298, 3093, 2, 6858, 14, 199, 199, 318, 1478, 8, 1069, 304, 272, 372, 6183, 480, 6257, 12, 6701, 14, 2047, 3984, 737, 314, 1300, 761, 1478, 2685, 1362, 199, 318, 11462, 8, 1069, 12, 2984, 63, 344, 304, 272, 519, 32611, 29, 25730, 10177, 14, 1462, 14, 2416, 63, 2407, 360, 6934, 363, 7067, 1673, 6934, 363, 8149, 1673, 6934, 363, 9402, 4610, 1959, 1541, 8, 2051, 29, 1121, 63, 344, 9, 272, 3085, 628, 52, 390, 2978, 16875, 3289, 4335, 272, 3085, 11, 28066, 1293, 4335, 272, 367, 25627, 315, 519, 32611, 14, 452, 837, 267, 519, 580, 29, 2527, 14, 6934, 267, 3085, 11, 28066, 317, 30, 450, 83, 315, 450, 83, 4366, 83, 21528, 393, 4335, 2840, 82, 580, 14, 1213, 12, 82, 580, 14, 7067, 14, 7241, 354, 12, 82, 580, 14, 9402, 4610, 14, 585, 9, 267, 367, 660, 337, 315, 519, 580, 14, 8149, 14, 452, 837, 288, 3085, 11, 28066, 317, 6598, 83, 450, 83, 2, 2818, 345, 337, 14, 30959, 12, 345, 337, 14, 25603, 9, 267, 3085, 11, 628, 1108, 393, 4335, 272, 3085, 11, 628, 1108, 1293, 4335, 272, 372, 6183, 8, 4518, 9, 421, 199, 318, 325, 1224, 8, 1069, 12, 2984, 63, 344, 304, 272, 20356, 29, 9900, 5987, 14, 1462, 14, 2416, 63, 2407, 360, 3840, 278, 968, 363, 2108, 1673, 3840, 278, 968, 363, 3840, 10987, 1959, 1541, 8, 2051, 29, 1121, 63, 344, 9, 272, 3085, 628, 775, 461, 5424, 272, 367, 10844, 315, 20356, 14, 452, 837, 267, 3085, 11, 15829, 348, 2535, 317, 6598, 83, 5956, 386, 14, 1213, 267, 3085, 11, 15829, 3289, 30, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
oconnorr/nixops
tests/unit/test_nix_expr.py
11
10994
import unittest from textwrap import dedent from nixops.nix_expr import py2nix, nix2py, nixmerge from nixops.nix_expr import RawValue, Function __all__ = ['Py2NixTest', 'Nix2PyTest', 'NixMergeTest'] class Py2NixTestBase(unittest.TestCase): def assert_nix(self, nix_expr, expected, maxwidth=80, inline=False): result = py2nix(nix_expr, maxwidth=maxwidth, inline=inline) self.assertEqual( result, expected, "Expected:\n{0}\nGot:\n{1}".format(expected, result) ) def test_numeric(self): self.assert_nix(123, "123") self.assert_nix(-123, "builtins.sub 0 123") self.assertRaises(ValueError, py2nix, 123.4) def test_boolean(self): self.assert_nix(True, "true") self.assert_nix(False, "false") def test_null(self): self.assert_nix(None, "null") def test_invalid(self): self.assertRaises(ValueError, py2nix, lambda: 123) self.assertRaises(ValueError, py2nix, Exception) def test_empty(self): self.assert_nix("", "\"\"") self.assert_nix({}, "{}") self.assert_nix([], "[]") def test_string(self): self.assert_nix("xyz", '"xyz"') self.assert_nix("a'b\"c", r'''"a'b\"c"''') self.assert_nix("abc\ndef\nghi", r'"abc\ndef\nghi"') self.assert_nix("abc\ndef\nghi\n", "''\n abc\n def\n ghi\n''", maxwidth=0) self.assert_nix("\\foo", r'"\\foo"') self.assert_nix("xx${yy}zz", r'"xx\${yy}zz"') self.assert_nix("xx\n${yy}\nzz\n", "''\n xx\n ''${yy}\n zz\n''", maxwidth=0) self.assert_nix("xx\n''yy\nzz\n", "''\n xx\n '''yy\n zz\n''", maxwidth=0) def test_raw_value(self): self.assert_nix({'a': RawValue('import <something>')}, '{ a = import <something>; }') self.assert_nix([RawValue("!")], '[ ! ]') def test_list(self): self.assert_nix([1, 2, 3], '[ 1 2 3 ]') self.assert_nix(["a", "b", "c"], '[ "a" "b" "c" ]') self.assert_nix(["a\na\na\n", "b\nb\n", "c"], r'[ "a\na\na\n" "b\nb\n" "c" ]') self.assert_nix(["a\na\na\n", "b\nb\n", "c"], '[\n "a\\na\\na\\n"\n "b\\nb\\n"\n "c"\n]', maxwidth=15) def test_nested_list(self): match = dedent(''' [ [ 1 2 3 ] [ 4 5 6 ] [ [ 6 6 6 ] [ [ 7 7 7 ] [ 8 8 8 ] [ 9 9 9 ] ] ] ] ''').strip() self.assert_nix([ [1, 2, 3], [4, 5, 6], [[6, 6, 6], [[7, 7, 7], [8, 8, 8], [9, 9, 9]]] ], match, maxwidth=12) def test_nested_singletons(self): match = dedent(''' [ [ [ 1 2 [ [ 3 ] ] ] ] ] ''').strip() self.assert_nix([[[1, 2, [[3]]]]], match, maxwidth=12) def test_attrkeys(self): self.assert_nix({'aAa': 123}, '{ aAa = 123; }') self.assert_nix({'a.a': 123}, '{ "a.a" = 123; }') self.assert_nix({'\\': 123}, r'{ "\\" = 123; }') self.assert_nix({'a1': 123}, '{ a1 = 123; }') self.assert_nix({'1a': 123}, '{ "1a" = 123; }') self.assert_nix({'_aA': 123}, '{ _aA = 123; }') self.assertRaises(KeyError, py2nix, {'': 123}) self.assertRaises(KeyError, py2nix, {123: 123}) def test_attrvalues(self): self.assert_nix({'a': "abc"}, '{ a = "abc"; }') self.assert_nix({'a': "a\nb\nc\n"}, r'{ a = "a\nb\nc\n"; }') self.assert_nix({'A': [1, 2, 3]}, r'{ A = [ 1 2 3 ]; }') def test_nested_attrsets(self): match = dedent(''' { aaa = { bbb.ccc = 123; cCc = 456; }; xxx = [ 1 2 3 ]; yyy.y1.y2.y3 = [ "a" "b" { c = "d"; } ]; } ''').strip() self.assert_nix({ 'aaa': { 'bbb': { 'ccc': 123, }, 'cCc': 456, }, 'xxx': [1, 2, 3], 'yyy': { 'y1': {'y2': {'y3': ["a", "b", {'c': 'd'}]}}, }, }, match, maxwidth=0) self.assert_nix({'fileSystems': { '/': {'fsType': 'btrfs', 'label': 'root'} }}, '{ fileSystems."/" = { fsType = "btrfs"; label = "root"; }; }') def test_functions(self): self.assert_nix(Function("Aaa", RawValue("bbb")), "Aaa: bbb") self.assert_nix(Function("{ ... }", [1, 2, 3]), "{ ... }: [ 1 2 3 ]") self.assert_nix(Function("{ ... }", "a\nb\nc\n"), r'{ ... }: "a\nb\nc\n"') self.assert_nix(Function("{ ... }", "a\nb\nc\n"), "{ ... }: ''\n a\n b\n c\n''", maxwidth=0) self.assert_nix(Function("xxx", {'a': {'b': 'c'}}), 'xxx: {\n a.b = "c";\n}', maxwidth=0) def test_nested_functions(self): match = dedent(''' { config, pkgs, ... }: { a.b.c = 1; b.c.d = 2; d.e = [ "e" "f" ]; e = f: { x = '' aaa bbb ccc ''; }; } ''').strip() self.assert_nix(Function( "{ config, pkgs, ... }", {'a': {'b': {'c': 1}}, 'b': {'c': {'d': 2}}, 'd': {'e': ['e', 'f']}, 'e': Function('f', { 'x': "aaa\nbbb\nccc\n" })} ), match, maxwidth=26) def test_function_call(self): self.assert_nix(Function("fun_call", {'a': 'b'}, call=True), 'fun_call { a = "b"; }') self.assert_nix(Function("multiline_call", {'a': 'b'}, call=True), 'multiline_call {\n a = "b";\n}', maxwidth=0) def test_stacked_attrs(self): self.assert_nix({('a', 'b'): 'c', ('d'): 'e'}, '{ a.b = "c"; d = "e"; }') self.assert_nix({'a': {('b', 'c'): {}}, ('a', 'b', 'c', 'd'): 'x'}, '{ a.b.c.d = "x"; }') self.assert_nix({('a', 'a'): 1, ('a', 'b'): 2, 'a': {'c': 3}}, '{ a = { a = 1; b = 2; c = 3; }; }') self.assert_nix({('a', 'b'): [1, 2], 'a': {'b': [3, 4]}}, '{ a.b = [ 1 2 3 4 ]; }') # a more real-world example self.assert_nix({ ('services', 'xserver'): { 'enable': True, 'layout': 'dvorak', ('windowManager', 'default'): 'i3', ('windowManager', 'i3'): { 'enable': True, 'configFile': '/somepath', }, ('desktopManager', 'default'): 'none', 'desktopManager': {'e17': {'enable': True}}, } }, dedent(''' { services.xserver = { desktopManager = { default = "none"; e17.enable = true; }; enable = true; layout = "dvorak"; windowManager = { default = "i3"; i3 = { configFile = "/somepath"; enable = true; }; }; }; } ''').strip()) self.assertRaises(KeyError, py2nix, {(): 1}) self.assertRaises(ValueError, py2nix, {('a', 'b'): 1, 'a': 2}) def test_inline(self): self.assert_nix({'foo': ['a\nb\nc\n'], 'bar': ['d\ne\nf\n']}, r'{ bar = [ "d\ne\nf\n" ]; foo = [ "a\nb\nc\n" ]; }', inline=True, maxwidth=0) self.assert_nix({"a\nb": ["c", "d"], "e\nf": ["g", "h"]}, r'{ "a\nb" = [ "c" "d" ]; "e\nf" = [ "g" "h" ]; }', inline=True, maxwidth=0) def test_list_compound(self): self.assert_nix([Function("123 //", 456, call=True), RawValue("a b c")], '[ (123 // 456) (a b c) ]') self.assert_nix([RawValue("a b c"), { 'cde': [RawValue("1,2,3"), RawValue("4 5 6"), RawValue("7\n8\n9")] }], '[ (a b c) { cde = [ 1,2,3 (4 5 6) (7\n8\n9) ]; } ]') class Nix2PyTest(unittest.TestCase): def test_simple(self): self.assertEquals(py2nix(nix2py('{\na = b;\n}'), maxwidth=0), '{\na = b;\n}') self.assertEquals(py2nix(nix2py('\n{\na = b;\n}\n'), maxwidth=0), '{\na = b;\n}') def test_nested(self): self.assertEquals(py2nix([nix2py('a\nb\nc')], maxwidth=0), '[\n (a\n b\n c)\n]') self.assertEquals(py2nix({'foo': nix2py('a\nb\nc'), 'bar': nix2py('d\ne\nf')}, maxwidth=0), # ugly, but probably won't happen in practice '{\n bar = d\n e\n f;\n foo = a\n b\n c;\n}') class NixMergeTest(unittest.TestCase): def assert_merge(self, sources, expect): self.assertEqual(reduce(nixmerge, sources), expect) def test_merge_list(self): self.assert_merge([ [1, 2, 3], [4, 5, 6], [7, 6, 5], ["abc", "def"], ["ghi", "abc"], ], [1, 2, 3, 4, 5, 6, 7, "abc", "ghi", "def"]) def test_merge_dict(self): self.assert_merge([ {}, {'a': {'b': {'c': 'd'}}}, {'a': {'c': 'e'}}, {'b': {'a': ['a']}}, {'b': {'a': ['b']}}, {'b': {'A': ['B']}}, {'e': 'f'}, {}, ], { 'a': { 'c': 'e', 'b': {'c': 'd'} }, 'b': {'a': ['a', 'b'], 'A': ['B']}, 'e': 'f', }) def test_unhashable(self): self.assertRaises(TypeError, nixmerge, [[1]], [[2]]) self.assertRaises(TypeError, nixmerge, [{'x': 1}], [{'y': 2}]) def test_invalid(self): self.assertRaises(ValueError, nixmerge, [123], {'a': 456}) self.assertRaises(ValueError, nixmerge, "a", "b") self.assertRaises(ValueError, nixmerge, 123, 456) self.assertRaises(ValueError, nixmerge, RawValue("a"), RawValue("b")) self.assertRaises(ValueError, nixmerge, Function("aaa", {'a': 1}), Function("ccc", {'b': 2})) self.assertRaises(ValueError, nixmerge, Function("aaa", {'a': 1}), {'b': 2})
lgpl-3.0
[ 646, 2882, 199, 199, 504, 13390, 492, 22622, 199, 199, 504, 23146, 1483, 14, 78, 1148, 63, 3684, 492, 1134, 18, 78, 1148, 12, 23146, 18, 647, 12, 23146, 5628, 199, 504, 23146, 1483, 14, 78, 1148, 63, 3684, 492, 13480, 1110, 12, 6801, 199, 199, 363, 452, 363, 275, 788, 2713, 18, 46, 1148, 774, 297, 283, 46, 1148, 18, 2713, 774, 297, 283, 46, 1148, 11359, 774, 418, 421, 199, 533, 1611, 18, 46, 1148, 14440, 8, 2796, 14, 1746, 304, 272, 347, 702, 63, 78, 1148, 8, 277, 12, 23146, 63, 3684, 12, 1420, 12, 1390, 2063, 29, 1257, 12, 8308, 29, 797, 304, 267, 754, 275, 1134, 18, 78, 1148, 8, 78, 1148, 63, 3684, 12, 1390, 2063, 29, 988, 2063, 12, 8308, 29, 6460, 9, 267, 291, 14, 629, 8, 288, 754, 12, 1420, 12, 288, 298, 6964, 3427, 78, 91, 16, 4988, 78, 13662, 3427, 78, 91, 17, 5469, 908, 8, 2062, 12, 754, 9, 267, 776, 339, 347, 511, 63, 6677, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 4288, 12, 298, 4288, 531, 267, 291, 14, 479, 63, 78, 1148, 2801, 4288, 12, 298, 10372, 14, 954, 378, 11869, 531, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 11869, 14, 20, 9, 339, 347, 511, 63, 4871, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 549, 12, 298, 2052, 531, 267, 291, 14, 479, 63, 78, 1148, 8, 797, 12, 298, 3910, 531, 339, 347, 511, 63, 2307, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 403, 12, 298, 2307, 531, 339, 347, 511, 63, 3197, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 2400, 26, 11869, 9, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 2186, 9, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 12398, 1867, 3212, 7230, 267, 291, 14, 479, 63, 78, 1148, 16037, 11491, 531, 267, 291, 14, 479, 63, 78, 1148, 8798, 7369, 12523, 339, 347, 511, 63, 875, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 480, 8568, 401, 5522, 8568, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 65, 7, 66, 4451, 67, 401, 519, 2344, 2, 65, 7, 66, 4451, 67, 2, 12310, 267, 291, 14, 479, 63, 78, 1148, 480, 3175, 60, 18467, 60, 2753, 5812, 401, 519, 4065, 3175, 60, 18467, 60, 2753, 5812, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 3175, 60, 18467, 60, 2753, 5812, 60, 78, 401, 17172, 60, 78, 221, 13022, 60, 78, 221, 347, 60, 78, 221, 486, 5812, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 267, 291, 14, 479, 63, 78, 1148, 23236, 1421, 401, 519, 4065, 1103, 1421, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 10545, 7566, 93, 4348, 401, 519, 4065, 2154, 60, 10545, 7566, 93, 4348, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 60, 78, 10545, 7566, 4988, 78, 4348, 60, 78, 401, 17172, 60, 78, 221, 19379, 60, 78, 221, 2125, 10545, 7566, 4988, 78, 221, 1315, 90, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 60, 78, 891, 7566, 60, 78, 4348, 60, 78, 401, 17172, 60, 78, 221, 19379, 60, 78, 221, 1449, 7566, 60, 78, 221, 1315, 90, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 339, 347, 511, 63, 1773, 63, 585, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 3252, 65, 356, 13480, 1110, 360, 646, 665, 10297, 30, 3904, 717, 5041, 282, 275, 492, 665, 10297, 30, 27, 789, 358, 267, 291, 14, 479, 63, 78, 1148, 779, 7963, 1110, 480, 9124, 467, 6730, 8546, 1622, 358, 339, 347, 511, 63, 513, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 779, 17, 12, 499, 12, 650, 467, 6730, 413, 499, 650, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 401, 298, 66, 401, 298, 67, 2255, 6730, 298, 65, 2, 298, 66, 2, 298, 67, 2, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 60, 3540, 60, 3540, 60, 78, 401, 298, 66, 60, 4994, 60, 78, 401, 298, 67, 2255, 717, 519, 3894, 298, 65, 60, 3540, 60, 3540, 60, 78, 2, 298, 66, 60, 4994, 60, 78, 2, 298, 67, 2, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 60, 3540, 60, 3540, 60, 78, 401, 298, 66, 60, 4994, 60, 78, 401, 298, 67, 2255, 717, 6730, 60, 78, 221, 298, 65, 1103, 3540, 1103, 3540, 1103, 78, 3212, 78, 221, 298, 66, 1103, 4994, 1103, 78, 3212, 78, 221, 298, 67, 3212, 78, 4300, 717, 1390, 2063, 29, 1046, 9, 339, 347, 511, 63, 6376, 63, 513, 8, 277, 304, 267, 1336, 275, 22622, 10505, 267, 359, 881, 359, 413, 499, 650, 1622, 881, 359, 841, 959, 1227, 1622, 881, 359, 288, 359, 1598, 1227, 1598, 1227, 1598, 1227, 288, 1622, 288, 359, 1598, 359, 355, 1520, 355, 1520, 355, 1520, 1598, 1622, 1598, 359, 355, 1695, 355, 1695, 355, 1695, 1598, 1622, 1598, 359, 355, 1749, 355, 1749, 355, 1749, 1598, 1622, 288, 1622, 881, 1622, 267, 1622, 267, 2125, 1959, 1913, 342, 398, 291, 14, 479, 63, 78, 1148, 779, 288, 359, 17, 12, 499, 12, 650, 467, 288, 359, 20, 12, 959, 12, 1227, 467, 288, 3474, 22, 12, 1227, 12, 1227, 467, 3474, 23, 12, 1520, 12, 1520, 467, 359, 24, 12, 1695, 12, 1695, 467, 359, 25, 12, 1749, 12, 1749, 20737, 267, 2156, 1336, 12, 1390, 2063, 29, 713, 9, 339, 347, 511, 63, 6376, 63, 24675, 83, 8, 277, 304, 267, 1336, 275, 22622, 10505, 267, 359, 359, 359, 881, 413, 881, 499, 881, 359, 359, 650, 1622, 1622, 267, 1622, 1622, 1622, 267, 2125, 1959, 1913, 342, 398, 291, 14, 479, 63, 78, 1148, 23930, 17, 12, 499, 12, 3474, 19, 2677, 15559, 1336, 12, 1390, 2063, 29, 713, 9, 339, 347, 511, 63, 962, 1612 ]
[ 2882, 199, 199, 504, 13390, 492, 22622, 199, 199, 504, 23146, 1483, 14, 78, 1148, 63, 3684, 492, 1134, 18, 78, 1148, 12, 23146, 18, 647, 12, 23146, 5628, 199, 504, 23146, 1483, 14, 78, 1148, 63, 3684, 492, 13480, 1110, 12, 6801, 199, 199, 363, 452, 363, 275, 788, 2713, 18, 46, 1148, 774, 297, 283, 46, 1148, 18, 2713, 774, 297, 283, 46, 1148, 11359, 774, 418, 421, 199, 533, 1611, 18, 46, 1148, 14440, 8, 2796, 14, 1746, 304, 272, 347, 702, 63, 78, 1148, 8, 277, 12, 23146, 63, 3684, 12, 1420, 12, 1390, 2063, 29, 1257, 12, 8308, 29, 797, 304, 267, 754, 275, 1134, 18, 78, 1148, 8, 78, 1148, 63, 3684, 12, 1390, 2063, 29, 988, 2063, 12, 8308, 29, 6460, 9, 267, 291, 14, 629, 8, 288, 754, 12, 1420, 12, 288, 298, 6964, 3427, 78, 91, 16, 4988, 78, 13662, 3427, 78, 91, 17, 5469, 908, 8, 2062, 12, 754, 9, 267, 776, 339, 347, 511, 63, 6677, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 4288, 12, 298, 4288, 531, 267, 291, 14, 479, 63, 78, 1148, 2801, 4288, 12, 298, 10372, 14, 954, 378, 11869, 531, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 11869, 14, 20, 9, 339, 347, 511, 63, 4871, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 549, 12, 298, 2052, 531, 267, 291, 14, 479, 63, 78, 1148, 8, 797, 12, 298, 3910, 531, 339, 347, 511, 63, 2307, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 8, 403, 12, 298, 2307, 531, 339, 347, 511, 63, 3197, 8, 277, 304, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 2400, 26, 11869, 9, 267, 291, 14, 1855, 8, 3393, 12, 1134, 18, 78, 1148, 12, 2186, 9, 339, 347, 511, 63, 1667, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 12398, 1867, 3212, 7230, 267, 291, 14, 479, 63, 78, 1148, 16037, 11491, 531, 267, 291, 14, 479, 63, 78, 1148, 8798, 7369, 12523, 339, 347, 511, 63, 875, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 480, 8568, 401, 5522, 8568, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 65, 7, 66, 4451, 67, 401, 519, 2344, 2, 65, 7, 66, 4451, 67, 2, 12310, 267, 291, 14, 479, 63, 78, 1148, 480, 3175, 60, 18467, 60, 2753, 5812, 401, 519, 4065, 3175, 60, 18467, 60, 2753, 5812, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 3175, 60, 18467, 60, 2753, 5812, 60, 78, 401, 17172, 60, 78, 221, 13022, 60, 78, 221, 347, 60, 78, 221, 486, 5812, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 267, 291, 14, 479, 63, 78, 1148, 23236, 1421, 401, 519, 4065, 1103, 1421, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 10545, 7566, 93, 4348, 401, 519, 4065, 2154, 60, 10545, 7566, 93, 4348, 9008, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 60, 78, 10545, 7566, 4988, 78, 4348, 60, 78, 401, 17172, 60, 78, 221, 19379, 60, 78, 221, 2125, 10545, 7566, 4988, 78, 221, 1315, 90, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 267, 291, 14, 479, 63, 78, 1148, 480, 2154, 60, 78, 891, 7566, 60, 78, 4348, 60, 78, 401, 17172, 60, 78, 221, 19379, 60, 78, 221, 1449, 7566, 60, 78, 221, 1315, 90, 60, 78, 891, 401, 717, 1390, 2063, 29, 16, 9, 339, 347, 511, 63, 1773, 63, 585, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 3252, 65, 356, 13480, 1110, 360, 646, 665, 10297, 30, 3904, 717, 5041, 282, 275, 492, 665, 10297, 30, 27, 789, 358, 267, 291, 14, 479, 63, 78, 1148, 779, 7963, 1110, 480, 9124, 467, 6730, 8546, 1622, 358, 339, 347, 511, 63, 513, 8, 277, 304, 267, 291, 14, 479, 63, 78, 1148, 779, 17, 12, 499, 12, 650, 467, 6730, 413, 499, 650, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 401, 298, 66, 401, 298, 67, 2255, 6730, 298, 65, 2, 298, 66, 2, 298, 67, 2, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 60, 3540, 60, 3540, 60, 78, 401, 298, 66, 60, 4994, 60, 78, 401, 298, 67, 2255, 717, 519, 3894, 298, 65, 60, 3540, 60, 3540, 60, 78, 2, 298, 66, 60, 4994, 60, 78, 2, 298, 67, 2, 1622, 358, 267, 291, 14, 479, 63, 78, 1148, 5234, 65, 60, 3540, 60, 3540, 60, 78, 401, 298, 66, 60, 4994, 60, 78, 401, 298, 67, 2255, 717, 6730, 60, 78, 221, 298, 65, 1103, 3540, 1103, 3540, 1103, 78, 3212, 78, 221, 298, 66, 1103, 4994, 1103, 78, 3212, 78, 221, 298, 67, 3212, 78, 4300, 717, 1390, 2063, 29, 1046, 9, 339, 347, 511, 63, 6376, 63, 513, 8, 277, 304, 267, 1336, 275, 22622, 10505, 267, 359, 881, 359, 413, 499, 650, 1622, 881, 359, 841, 959, 1227, 1622, 881, 359, 288, 359, 1598, 1227, 1598, 1227, 1598, 1227, 288, 1622, 288, 359, 1598, 359, 355, 1520, 355, 1520, 355, 1520, 1598, 1622, 1598, 359, 355, 1695, 355, 1695, 355, 1695, 1598, 1622, 1598, 359, 355, 1749, 355, 1749, 355, 1749, 1598, 1622, 288, 1622, 881, 1622, 267, 1622, 267, 2125, 1959, 1913, 342, 398, 291, 14, 479, 63, 78, 1148, 779, 288, 359, 17, 12, 499, 12, 650, 467, 288, 359, 20, 12, 959, 12, 1227, 467, 288, 3474, 22, 12, 1227, 12, 1227, 467, 3474, 23, 12, 1520, 12, 1520, 467, 359, 24, 12, 1695, 12, 1695, 467, 359, 25, 12, 1749, 12, 1749, 20737, 267, 2156, 1336, 12, 1390, 2063, 29, 713, 9, 339, 347, 511, 63, 6376, 63, 24675, 83, 8, 277, 304, 267, 1336, 275, 22622, 10505, 267, 359, 359, 359, 881, 413, 881, 499, 881, 359, 359, 650, 1622, 1622, 267, 1622, 1622, 1622, 267, 2125, 1959, 1913, 342, 398, 291, 14, 479, 63, 78, 1148, 23930, 17, 12, 499, 12, 3474, 19, 2677, 15559, 1336, 12, 1390, 2063, 29, 713, 9, 339, 347, 511, 63, 962, 1612, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shaobozi/googletest
test/gtest_break_on_failure_unittest.py
2140
7339
#!/usr/bin/env python # # Copyright 2006, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Unit test for Google Test's break-on-failure mode. A user can ask Google Test to seg-fault when an assertion fails, using either the GTEST_BREAK_ON_FAILURE environment variable or the --gtest_break_on_failure flag. This script tests such functionality by invoking gtest_break_on_failure_unittest_ (a program written with Google Test) with different environments and command line flags. """ __author__ = 'wan@google.com (Zhanyong Wan)' import gtest_test_utils import os import sys # Constants. IS_WINDOWS = os.name == 'nt' # The environment variable for enabling/disabling the break-on-failure mode. BREAK_ON_FAILURE_ENV_VAR = 'GTEST_BREAK_ON_FAILURE' # The command line flag for enabling/disabling the break-on-failure mode. BREAK_ON_FAILURE_FLAG = 'gtest_break_on_failure' # The environment variable for enabling/disabling the throw-on-failure mode. THROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE' # The environment variable for enabling/disabling the catch-exceptions mode. CATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS' # Path to the gtest_break_on_failure_unittest_ program. EXE_PATH = gtest_test_utils.GetTestExecutablePath( 'gtest_break_on_failure_unittest_') environ = gtest_test_utils.environ SetEnvVar = gtest_test_utils.SetEnvVar # Tests in this file run a Google-Test-based test program and expect it # to terminate prematurely. Therefore they are incompatible with # the premature-exit-file protocol by design. Unset the # premature-exit filepath to prevent Google Test from creating # the file. SetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None) def Run(command): """Runs a command; returns 1 if it was killed by a signal, or 0 otherwise.""" p = gtest_test_utils.Subprocess(command, env=environ) if p.terminated_by_signal: return 1 else: return 0 # The tests. class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): """Tests using the GTEST_BREAK_ON_FAILURE environment variable or the --gtest_break_on_failure flag to turn assertion failures into segmentation faults. """ def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault): """Runs gtest_break_on_failure_unittest_ and verifies that it does (or does not) have a seg-fault. Args: env_var_value: value of the GTEST_BREAK_ON_FAILURE environment variable; None if the variable should be unset. flag_value: value of the --gtest_break_on_failure flag; None if the flag should not be present. expect_seg_fault: 1 if the program is expected to generate a seg-fault; 0 otherwise. """ SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, env_var_value) if env_var_value is None: env_var_value_msg = ' is not set' else: env_var_value_msg = '=' + env_var_value if flag_value is None: flag = '' elif flag_value == '0': flag = '--%s=0' % BREAK_ON_FAILURE_FLAG else: flag = '--%s' % BREAK_ON_FAILURE_FLAG command = [EXE_PATH] if flag: command.append(flag) if expect_seg_fault: should_or_not = 'should' else: should_or_not = 'should not' has_seg_fault = Run(command) SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, None) msg = ('when %s%s, an assertion failure in "%s" %s cause a seg-fault.' % (BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command), should_or_not)) self.assert_(has_seg_fault == expect_seg_fault, msg) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" self.RunAndVerify(env_var_value=None, flag_value=None, expect_seg_fault=0) def testEnvVar(self): """Tests using the GTEST_BREAK_ON_FAILURE environment variable.""" self.RunAndVerify(env_var_value='0', flag_value=None, expect_seg_fault=0) self.RunAndVerify(env_var_value='1', flag_value=None, expect_seg_fault=1) def testFlag(self): """Tests using the --gtest_break_on_failure flag.""" self.RunAndVerify(env_var_value=None, flag_value='0', expect_seg_fault=0) self.RunAndVerify(env_var_value=None, flag_value='1', expect_seg_fault=1) def testFlagOverridesEnvVar(self): """Tests that the flag overrides the environment variable.""" self.RunAndVerify(env_var_value='0', flag_value='0', expect_seg_fault=0) self.RunAndVerify(env_var_value='0', flag_value='1', expect_seg_fault=1) self.RunAndVerify(env_var_value='1', flag_value='0', expect_seg_fault=0) self.RunAndVerify(env_var_value='1', flag_value='1', expect_seg_fault=1) def testBreakOnFailureOverridesThrowOnFailure(self): """Tests that gtest_break_on_failure overrides gtest_throw_on_failure.""" SetEnvVar(THROW_ON_FAILURE_ENV_VAR, '1') try: self.RunAndVerify(env_var_value=None, flag_value='1', expect_seg_fault=1) finally: SetEnvVar(THROW_ON_FAILURE_ENV_VAR, None) if IS_WINDOWS: def testCatchExceptionsDoesNotInterfere(self): """Tests that gtest_catch_exceptions doesn't interfere.""" SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, '1') try: self.RunAndVerify(env_var_value='1', flag_value='1', expect_seg_fault=1) finally: SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, None) if __name__ == '__main__': gtest_test_utils.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8315, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 5072, 511, 367, 4475, 1379, 1159, 2059, 13, 265, 13, 5328, 818, 14, 199, 199, 33, 922, 883, 7198, 4475, 1379, 370, 8812, 13, 1879, 1380, 376, 14412, 6918, 12, 1808, 199, 22051, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 1750, 503, 314, 199, 306, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 14, 221, 961, 2884, 2295, 4066, 9330, 199, 991, 26750, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 334, 65, 2240, 5313, 543, 199, 13266, 1379, 9, 543, 3365, 22196, 436, 1414, 1004, 3285, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 9088, 63, 396, 63, 1208, 199, 646, 747, 199, 646, 984, 421, 199, 3, 22296, 14, 199, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 2059, 13, 265, 13, 5328, 818, 14, 199, 14731, 63, 615, 63, 13989, 63, 9984, 63, 5568, 275, 283, 16151, 63, 14731, 63, 615, 63, 13989, 7, 199, 199, 3, 710, 1414, 1004, 3305, 367, 29310, 15, 2297, 14744, 314, 2059, 13, 265, 13, 5328, 818, 14, 199, 14731, 63, 615, 63, 13989, 63, 3719, 275, 283, 8385, 63, 4785, 63, 265, 63, 5328, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 7978, 13, 265, 13, 5328, 818, 14, 199, 2080, 11415, 63, 615, 63, 13989, 63, 9984, 63, 5568, 275, 283, 16151, 63, 2080, 11415, 63, 615, 63, 13989, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 8579, 13, 3924, 818, 14, 199, 35, 8078, 63, 25054, 63, 9984, 63, 5568, 275, 283, 16151, 63, 35, 8078, 63, 25054, 7, 199, 199, 3, 6912, 370, 314, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 2240, 14, 199, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 4785, 63, 265, 63, 5328, 63, 2796, 15452, 421, 199, 2314, 275, 9088, 63, 396, 63, 1208, 14, 2314, 199, 1084, 19342, 275, 9088, 63, 396, 63, 1208, 14, 1084, 19342, 199, 199, 3, 6496, 315, 642, 570, 1255, 282, 4475, 13, 774, 13, 6788, 511, 2240, 436, 4282, 652, 199, 3, 370, 15095, 876, 19925, 590, 14, 221, 21039, 2985, 787, 18457, 543, 199, 3, 314, 876, 19925, 13, 2224, 13, 493, 4113, 701, 12899, 14, 221, 1910, 409, 314, 199, 3, 876, 19925, 13, 2224, 9911, 370, 7981, 4475, 1379, 687, 6425, 199, 3, 314, 570, 14, 199, 1084, 19342, 8, 8385, 63, 396, 63, 1208, 14, 4225, 45, 13214, 63, 17219, 63, 3817, 63, 9984, 63, 5568, 12, 488, 9, 421, 199, 318, 3378, 8, 1531, 304, 523, 408, 16291, 282, 1414, 27, 2529, 413, 340, 652, 1990, 26659, 701, 282, 4673, 12, 503, 378, 4257, 1041, 819, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 1531, 12, 2589, 29, 2314, 9, 523, 340, 299, 14, 18375, 63, 991, 63, 4653, 26, 272, 372, 413, 523, 587, 26, 272, 372, 378, 421, 199, 3, 710, 2295, 14, 421, 199, 533, 598, 774, 13948, 3314, 6782, 29037, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 408, 2925, 1808, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 1750, 503, 523, 314, 1553, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 370, 7485, 14412, 9081, 1901, 523, 27315, 16898, 83, 14, 523, 408, 819, 347, 3378, 14222, 8, 277, 12, 2589, 63, 1391, 63, 585, 12, 3305, 63, 585, 12, 4282, 63, 8359, 63, 1879, 304, 272, 408, 16291, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 436, 22694, 626, 652, 1630, 272, 334, 269, 1630, 440, 9, 1172, 282, 8812, 13, 1879, 14, 339, 3033, 26, 489, 2589, 63, 1391, 63, 585, 26, 259, 574, 402, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 717, 1750, 27, 488, 340, 314, 1750, 1077, 506, 15376, 14, 489, 3305, 63, 585, 26, 755, 574, 402, 314, 1553, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 27, 717, 488, 340, 314 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8315, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 624, 5072, 511, 367, 4475, 1379, 1159, 2059, 13, 265, 13, 5328, 818, 14, 199, 199, 33, 922, 883, 7198, 4475, 1379, 370, 8812, 13, 1879, 1380, 376, 14412, 6918, 12, 1808, 199, 22051, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 1750, 503, 314, 199, 306, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 14, 221, 961, 2884, 2295, 4066, 9330, 199, 991, 26750, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 334, 65, 2240, 5313, 543, 199, 13266, 1379, 9, 543, 3365, 22196, 436, 1414, 1004, 3285, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 9088, 63, 396, 63, 1208, 199, 646, 747, 199, 646, 984, 421, 199, 3, 22296, 14, 199, 199, 1311, 63, 20509, 275, 747, 14, 354, 508, 283, 343, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 2059, 13, 265, 13, 5328, 818, 14, 199, 14731, 63, 615, 63, 13989, 63, 9984, 63, 5568, 275, 283, 16151, 63, 14731, 63, 615, 63, 13989, 7, 199, 199, 3, 710, 1414, 1004, 3305, 367, 29310, 15, 2297, 14744, 314, 2059, 13, 265, 13, 5328, 818, 14, 199, 14731, 63, 615, 63, 13989, 63, 3719, 275, 283, 8385, 63, 4785, 63, 265, 63, 5328, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 7978, 13, 265, 13, 5328, 818, 14, 199, 2080, 11415, 63, 615, 63, 13989, 63, 9984, 63, 5568, 275, 283, 16151, 63, 2080, 11415, 63, 615, 63, 13989, 7, 199, 199, 3, 710, 3734, 1750, 367, 29310, 15, 2297, 14744, 314, 8579, 13, 3924, 818, 14, 199, 35, 8078, 63, 25054, 63, 9984, 63, 5568, 275, 283, 16151, 63, 35, 8078, 63, 25054, 7, 199, 199, 3, 6912, 370, 314, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 2240, 14, 199, 23017, 63, 3243, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 8, 272, 283, 8385, 63, 4785, 63, 265, 63, 5328, 63, 2796, 15452, 421, 199, 2314, 275, 9088, 63, 396, 63, 1208, 14, 2314, 199, 1084, 19342, 275, 9088, 63, 396, 63, 1208, 14, 1084, 19342, 199, 199, 3, 6496, 315, 642, 570, 1255, 282, 4475, 13, 774, 13, 6788, 511, 2240, 436, 4282, 652, 199, 3, 370, 15095, 876, 19925, 590, 14, 221, 21039, 2985, 787, 18457, 543, 199, 3, 314, 876, 19925, 13, 2224, 13, 493, 4113, 701, 12899, 14, 221, 1910, 409, 314, 199, 3, 876, 19925, 13, 2224, 9911, 370, 7981, 4475, 1379, 687, 6425, 199, 3, 314, 570, 14, 199, 1084, 19342, 8, 8385, 63, 396, 63, 1208, 14, 4225, 45, 13214, 63, 17219, 63, 3817, 63, 9984, 63, 5568, 12, 488, 9, 421, 199, 318, 3378, 8, 1531, 304, 523, 408, 16291, 282, 1414, 27, 2529, 413, 340, 652, 1990, 26659, 701, 282, 4673, 12, 503, 378, 4257, 1041, 819, 299, 275, 9088, 63, 396, 63, 1208, 14, 22299, 8, 1531, 12, 2589, 29, 2314, 9, 523, 340, 299, 14, 18375, 63, 991, 63, 4653, 26, 272, 372, 413, 523, 587, 26, 272, 372, 378, 421, 199, 3, 710, 2295, 14, 421, 199, 533, 598, 774, 13948, 3314, 6782, 29037, 8, 8385, 63, 396, 63, 1208, 14, 1746, 304, 523, 408, 2925, 1808, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 1750, 503, 523, 314, 1553, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 370, 7485, 14412, 9081, 1901, 523, 27315, 16898, 83, 14, 523, 408, 819, 347, 3378, 14222, 8, 277, 12, 2589, 63, 1391, 63, 585, 12, 3305, 63, 585, 12, 4282, 63, 8359, 63, 1879, 304, 272, 408, 16291, 9088, 63, 4785, 63, 265, 63, 5328, 63, 2796, 63, 436, 22694, 626, 652, 1630, 272, 334, 269, 1630, 440, 9, 1172, 282, 8812, 13, 1879, 14, 339, 3033, 26, 489, 2589, 63, 1391, 63, 585, 26, 259, 574, 402, 314, 18652, 63, 14731, 63, 615, 63, 13989, 3734, 717, 1750, 27, 488, 340, 314, 1750, 1077, 506, 15376, 14, 489, 3305, 63, 585, 26, 755, 574, 402, 314, 1553, 8385, 63, 4785, 63, 265, 63, 5328, 3305, 27, 717, 488, 340, 314, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hakujyo/chessplaying_robot
machintest.py
1
1166
# uArm Swift Pro - Python Library Example # Created by: Richard Garsthagen - the.anykey@gmail.com # V0.1 - June 2017 - Still under development import uArmRobot import time #Configure Serial Port serialport = "com5" # for windows #serialport = "/dev/ttyACM0" # for linux like system # Connect to uArm myRobot = uArmRobot.robot(serialport) # myRobot.__init__(serialport) myRobot.debug = True # Enable / Disable debug output on screen, by default disabled myRobot.connect() myRobot.mode(0) # Set mode to Normal time.sleep(1) # Move robot, command will complete when motion is completed myRobot.goto(150, 0, 100, 30000) for x in range(150,262,14): for y in range(-112, 112, 14): myRobot.goto(120, 0, 100, 30000) myRobot.pump(True) time.sleep(5) # 一格14mm # 落下33mm myRobot.goto(x, y, 35, 30000) time.sleep(2) myRobot.pump(False) time.sleep(3) # myRobot.async_goto(112,0,32,6000) myRobot.goto(150, 0, 100, 30000) time.sleep(5) #Disconnect serial connection myRobot.disconnect()
gpl-3.0
[ 3, 399, 1596, 77, 16666, 2949, 2165, 446, 2018, 11243, 5679, 202, 199, 3, 18208, 701, 26, 30846, 1005, 598, 285, 17082, 24758, 446, 314, 14, 1629, 498, 32, 6799, 14, 957, 202, 199, 3, 812, 16, 14, 17, 446, 1603, 11474, 9708, 446, 428, 12587, 1334, 16367, 2999, 199, 646, 399, 1596, 77, 21823, 202, 199, 646, 900, 2999, 199, 3, 17324, 11973, 10977, 202, 199, 2171, 719, 275, 298, 957, 21, 2, 3515, 327, 367, 10061, 202, 199, 3, 2171, 719, 275, 3286, 2374, 15, 4707, 1348, 45, 16, 2, 221, 327, 367, 18369, 2839, 2656, 2999, 199, 3, 15175, 370, 399, 1596, 77, 202, 199, 1662, 21823, 275, 399, 1596, 77, 21823, 14, 9751, 8, 2171, 719, 9, 202, 199, 3, 3002, 21823, 855, 826, 721, 2171, 719, 9, 202, 199, 1662, 21823, 14, 1757, 275, 715, 257, 327, 12030, 1182, 17534, 3105, 1072, 641, 6426, 12, 701, 849, 6980, 202, 199, 1662, 21823, 14, 2242, 342, 202, 199, 1662, 21823, 14, 632, 8, 16, 9, 257, 327, 2494, 818, 370, 11514, 2999, 199, 521, 14, 4532, 8, 17, 9, 2999, 199, 3, 14171, 14544, 12, 1414, 911, 4890, 1380, 25134, 365, 9709, 202, 199, 1662, 21823, 14, 14867, 8, 8251, 12, 378, 12, 2948, 12, 650, 993, 9, 1223, 8065, 199, 509, 671, 315, 1425, 8, 8251, 12, 14820, 12, 1079, 304, 1128, 367, 612, 315, 1425, 2801, 6094, 12, 20240, 12, 4329, 304, 1039, 3002, 21823, 14, 14867, 8, 6708, 12, 378, 12, 2948, 12, 650, 993, 9, 1039, 3002, 21823, 14, 29547, 8, 549, 9, 1039, 900, 14, 4532, 8, 21, 9, 4341, 327, 221, 9372, 13750, 121, 1079, 596, 1039, 327, 9065, 239, 122, 24233, 1153, 596, 1039, 3002, 21823, 14, 14867, 8, 88, 12, 612, 12, 8685, 12, 650, 993, 9, 1039, 900, 14, 4532, 8, 18, 9, 1039, 3002, 21823, 14, 29547, 8, 797, 9, 1039, 900, 14, 4532, 8, 19, 9, 1039, 327, 3002, 21823, 14, 4146, 63, 14867, 8, 6094, 12, 16, 12, 708, 12, 32623, 9, 1039, 3002, 21823, 14, 14867, 8, 8251, 12, 378, 12, 2948, 12, 650, 993, 9, 10060, 10060, 10060, 10060, 8065, 199, 521, 14, 4532, 8, 21, 9, 2999, 199, 3, 16761, 3012, 1950, 202, 199, 1662, 21823, 14, 10673, 342, 10060, 10060, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 399, 1596, 77, 16666, 2949, 2165, 446, 2018, 11243, 5679, 202, 199, 3, 18208, 701, 26, 30846, 1005, 598, 285, 17082, 24758, 446, 314, 14, 1629, 498, 32, 6799, 14, 957, 202, 199, 3, 812, 16, 14, 17, 446, 1603, 11474, 9708, 446, 428, 12587, 1334, 16367, 2999, 199, 646, 399, 1596, 77, 21823, 202, 199, 646, 900, 2999, 199, 3, 17324, 11973, 10977, 202, 199, 2171, 719, 275, 298, 957, 21, 2, 3515, 327, 367, 10061, 202, 199, 3, 2171, 719, 275, 3286, 2374, 15, 4707, 1348, 45, 16, 2, 221, 327, 367, 18369, 2839, 2656, 2999, 199, 3, 15175, 370, 399, 1596, 77, 202, 199, 1662, 21823, 275, 399, 1596, 77, 21823, 14, 9751, 8, 2171, 719, 9, 202, 199, 3, 3002, 21823, 855, 826, 721, 2171, 719, 9, 202, 199, 1662, 21823, 14, 1757, 275, 715, 257, 327, 12030, 1182, 17534, 3105, 1072, 641, 6426, 12, 701, 849, 6980, 202, 199, 1662, 21823, 14, 2242, 342, 202, 199, 1662, 21823, 14, 632, 8, 16, 9, 257, 327, 2494, 818, 370, 11514, 2999, 199, 521, 14, 4532, 8, 17, 9, 2999, 199, 3, 14171, 14544, 12, 1414, 911, 4890, 1380, 25134, 365, 9709, 202, 199, 1662, 21823, 14, 14867, 8, 8251, 12, 378, 12, 2948, 12, 650, 993, 9, 1223, 8065, 199, 509, 671, 315, 1425, 8, 8251, 12, 14820, 12, 1079, 304, 1128, 367, 612, 315, 1425, 2801, 6094, 12, 20240, 12, 4329, 304, 1039, 3002, 21823, 14, 14867, 8, 6708, 12, 378, 12, 2948, 12, 650, 993, 9, 1039, 3002, 21823, 14, 29547, 8, 549, 9, 1039, 900, 14, 4532, 8, 21, 9, 4341, 327, 221, 9372, 13750, 121, 1079, 596, 1039, 327, 9065, 239, 122, 24233, 1153, 596, 1039, 3002, 21823, 14, 14867, 8, 88, 12, 612, 12, 8685, 12, 650, 993, 9, 1039, 900, 14, 4532, 8, 18, 9, 1039, 3002, 21823, 14, 29547, 8, 797, 9, 1039, 900, 14, 4532, 8, 19, 9, 1039, 327, 3002, 21823, 14, 4146, 63, 14867, 8, 6094, 12, 16, 12, 708, 12, 32623, 9, 1039, 3002, 21823, 14, 14867, 8, 8251, 12, 378, 12, 2948, 12, 650, 993, 9, 10060, 10060, 10060, 10060, 8065, 199, 521, 14, 4532, 8, 21, 9, 2999, 199, 3, 16761, 3012, 1950, 202, 199, 1662, 21823, 14, 10673, 342, 10060, 10060, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
laiqiqi886/kbengine
kbe/res/scripts/common/Lib/test/test_minidom.py
60
64328
# test for xml.dom.minidom import pickle from test.support import run_unittest, findfile import unittest import xml.dom.minidom from xml.dom.minidom import parse, Node, Document, parseString from xml.dom.minidom import getDOMImplementation tstfile = findfile("test.xml", subdir="xmltestdata") # The tests of DocumentType importing use these helpers to construct # the documents to work with, since not all DOM builders actually # create the DocumentType nodes. def create_doc_without_doctype(doctype=None): return getDOMImplementation().createDocument(None, "doc", doctype) def create_nonempty_doctype(): doctype = getDOMImplementation().createDocumentType("doc", None, None) doctype.entities._seq = [] doctype.notations._seq = [] notation = xml.dom.minidom.Notation("my-notation", None, "http://xml.python.org/notations/my") doctype.notations._seq.append(notation) entity = xml.dom.minidom.Entity("my-entity", None, "http://xml.python.org/entities/my", "my-notation") entity.version = "1.0" entity.encoding = "utf-8" entity.actualEncoding = "us-ascii" doctype.entities._seq.append(entity) return doctype def create_doc_with_doctype(): doctype = create_nonempty_doctype() doc = create_doc_without_doctype(doctype) doctype.entities.item(0).ownerDocument = doc doctype.notations.item(0).ownerDocument = doc return doc class MinidomTest(unittest.TestCase): def confirm(self, test, testname = "Test"): self.assertTrue(test, testname) def checkWholeText(self, node, s): t = node.wholeText self.confirm(t == s, "looking for %r, found %r" % (s, t)) def testParseFromFile(self): with open(tstfile) as file: dom = parse(file) dom.unlink() self.confirm(isinstance(dom, Document)) def testGetElementsByTagName(self): dom = parse(tstfile) self.confirm(dom.getElementsByTagName("LI") == \ dom.documentElement.getElementsByTagName("LI")) dom.unlink() def testInsertBefore(self): dom = parseString("<doc><foo/></doc>") root = dom.documentElement elem = root.childNodes[0] nelem = dom.createElement("element") root.insertBefore(nelem, elem) self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2 and root.childNodes[0] is nelem and root.childNodes.item(0) is nelem and root.childNodes[1] is elem and root.childNodes.item(1) is elem and root.firstChild is nelem and root.lastChild is elem and root.toxml() == "<doc><element/><foo/></doc>" , "testInsertBefore -- node properly placed in tree") nelem = dom.createElement("element") root.insertBefore(nelem, None) self.confirm(len(root.childNodes) == 3 and root.childNodes.length == 3 and root.childNodes[1] is elem and root.childNodes.item(1) is elem and root.childNodes[2] is nelem and root.childNodes.item(2) is nelem and root.lastChild is nelem and nelem.previousSibling is elem and root.toxml() == "<doc><element/><foo/><element/></doc>" , "testInsertBefore -- node properly placed in tree") nelem2 = dom.createElement("bar") root.insertBefore(nelem2, nelem) self.confirm(len(root.childNodes) == 4 and root.childNodes.length == 4 and root.childNodes[2] is nelem2 and root.childNodes.item(2) is nelem2 and root.childNodes[3] is nelem and root.childNodes.item(3) is nelem and nelem2.nextSibling is nelem and nelem.previousSibling is nelem2 and root.toxml() == "<doc><element/><foo/><bar/><element/></doc>" , "testInsertBefore -- node properly placed in tree") dom.unlink() def _create_fragment_test_nodes(self): dom = parseString("<doc/>") orig = dom.createTextNode("original") c1 = dom.createTextNode("foo") c2 = dom.createTextNode("bar") c3 = dom.createTextNode("bat") dom.documentElement.appendChild(orig) frag = dom.createDocumentFragment() frag.appendChild(c1) frag.appendChild(c2) frag.appendChild(c3) return dom, orig, c1, c2, c3, frag def testInsertBeforeFragment(self): dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes() dom.documentElement.insertBefore(frag, None) self.confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3), "insertBefore(<fragment>, None)") frag.unlink() dom.unlink() dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes() dom.documentElement.insertBefore(frag, orig) self.confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3, orig), "insertBefore(<fragment>, orig)") frag.unlink() dom.unlink() def testAppendChild(self): dom = parse(tstfile) dom.documentElement.appendChild(dom.createComment("Hello")) self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment") self.confirm(dom.documentElement.childNodes[-1].data == "Hello") dom.unlink() def testAppendChildFragment(self): dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes() dom.documentElement.appendChild(frag) self.confirm(tuple(dom.documentElement.childNodes) == (orig, c1, c2, c3), "appendChild(<fragment>)") frag.unlink() dom.unlink() def testReplaceChildFragment(self): dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes() dom.documentElement.replaceChild(frag, orig) orig.unlink() self.confirm(tuple(dom.documentElement.childNodes) == (c1, c2, c3), "replaceChild(<fragment>)") frag.unlink() dom.unlink() def testLegalChildren(self): dom = Document() elem = dom.createElement('element') text = dom.createTextNode('text') self.assertRaises(xml.dom.HierarchyRequestErr, dom.appendChild, text) dom.appendChild(elem) self.assertRaises(xml.dom.HierarchyRequestErr, dom.insertBefore, text, elem) self.assertRaises(xml.dom.HierarchyRequestErr, dom.replaceChild, text, elem) nodemap = elem.attributes self.assertRaises(xml.dom.HierarchyRequestErr, nodemap.setNamedItem, text) self.assertRaises(xml.dom.HierarchyRequestErr, nodemap.setNamedItemNS, text) elem.appendChild(text) dom.unlink() def testNamedNodeMapSetItem(self): dom = Document() elem = dom.createElement('element') attrs = elem.attributes attrs["foo"] = "bar" a = attrs.item(0) self.confirm(a.ownerDocument is dom, "NamedNodeMap.__setitem__() sets ownerDocument") self.confirm(a.ownerElement is elem, "NamedNodeMap.__setitem__() sets ownerElement") self.confirm(a.value == "bar", "NamedNodeMap.__setitem__() sets value") self.confirm(a.nodeValue == "bar", "NamedNodeMap.__setitem__() sets nodeValue") elem.unlink() dom.unlink() def testNonZero(self): dom = parse(tstfile) self.confirm(dom)# should not be zero dom.appendChild(dom.createComment("foo")) self.confirm(not dom.childNodes[-1].childNodes) dom.unlink() def testUnlink(self): dom = parse(tstfile) self.assertTrue(dom.childNodes) dom.unlink() self.assertFalse(dom.childNodes) def testContext(self): with parse(tstfile) as dom: self.assertTrue(dom.childNodes) self.assertFalse(dom.childNodes) def testElement(self): dom = Document() dom.appendChild(dom.createElement("abc")) self.confirm(dom.documentElement) dom.unlink() def testAAA(self): dom = parseString("<abc/>") el = dom.documentElement el.setAttribute("spam", "jam2") self.confirm(el.toxml() == '<abc spam="jam2"/>', "testAAA") a = el.getAttributeNode("spam") self.confirm(a.ownerDocument is dom, "setAttribute() sets ownerDocument") self.confirm(a.ownerElement is dom.documentElement, "setAttribute() sets ownerElement") dom.unlink() def testAAB(self): dom = parseString("<abc/>") el = dom.documentElement el.setAttribute("spam", "jam") el.setAttribute("spam", "jam2") self.confirm(el.toxml() == '<abc spam="jam2"/>', "testAAB") dom.unlink() def testAddAttr(self): dom = Document() child = dom.appendChild(dom.createElement("abc")) child.setAttribute("def", "ghi") self.confirm(child.getAttribute("def") == "ghi") self.confirm(child.attributes["def"].value == "ghi") child.setAttribute("jkl", "mno") self.confirm(child.getAttribute("jkl") == "mno") self.confirm(child.attributes["jkl"].value == "mno") self.confirm(len(child.attributes) == 2) child.setAttribute("def", "newval") self.confirm(child.getAttribute("def") == "newval") self.confirm(child.attributes["def"].value == "newval") self.confirm(len(child.attributes) == 2) dom.unlink() def testDeleteAttr(self): dom = Document() child = dom.appendChild(dom.createElement("abc")) self.confirm(len(child.attributes) == 0) child.setAttribute("def", "ghi") self.confirm(len(child.attributes) == 1) del child.attributes["def"] self.confirm(len(child.attributes) == 0) dom.unlink() def testRemoveAttr(self): dom = Document() child = dom.appendChild(dom.createElement("abc")) child.setAttribute("def", "ghi") self.confirm(len(child.attributes) == 1) self.assertRaises(xml.dom.NotFoundErr, child.removeAttribute, "foo") child.removeAttribute("def") self.confirm(len(child.attributes) == 0) dom.unlink() def testRemoveAttrNS(self): dom = Document() child = dom.appendChild( dom.createElementNS("http://www.python.org", "python:abc")) child.setAttributeNS("http://www.w3.org", "xmlns:python", "http://www.python.org") child.setAttributeNS("http://www.python.org", "python:abcattr", "foo") self.assertRaises(xml.dom.NotFoundErr, child.removeAttributeNS, "foo", "http://www.python.org") self.confirm(len(child.attributes) == 2) child.removeAttributeNS("http://www.python.org", "abcattr") self.confirm(len(child.attributes) == 1) dom.unlink() def testRemoveAttributeNode(self): dom = Document() child = dom.appendChild(dom.createElement("foo")) child.setAttribute("spam", "jam") self.confirm(len(child.attributes) == 1) node = child.getAttributeNode("spam") self.assertRaises(xml.dom.NotFoundErr, child.removeAttributeNode, None) child.removeAttributeNode(node) self.confirm(len(child.attributes) == 0 and child.getAttributeNode("spam") is None) dom2 = Document() child2 = dom2.appendChild(dom2.createElement("foo")) node2 = child2.getAttributeNode("spam") self.assertRaises(xml.dom.NotFoundErr, child2.removeAttributeNode, node2) dom.unlink() def testHasAttribute(self): dom = Document() child = dom.appendChild(dom.createElement("foo")) child.setAttribute("spam", "jam") self.confirm(child.hasAttribute("spam")) def testChangeAttr(self): dom = parseString("<abc/>") el = dom.documentElement el.setAttribute("spam", "jam") self.confirm(len(el.attributes) == 1) el.setAttribute("spam", "bam") # Set this attribute to be an ID and make sure that doesn't change # when changing the value: el.setIdAttribute("spam") self.confirm(len(el.attributes) == 1 and el.attributes["spam"].value == "bam" and el.attributes["spam"].nodeValue == "bam" and el.getAttribute("spam") == "bam" and el.getAttributeNode("spam").isId) el.attributes["spam"] = "ham" self.confirm(len(el.attributes) == 1 and el.attributes["spam"].value == "ham" and el.attributes["spam"].nodeValue == "ham" and el.getAttribute("spam") == "ham" and el.attributes["spam"].isId) el.setAttribute("spam2", "bam") self.confirm(len(el.attributes) == 2 and el.attributes["spam"].value == "ham" and el.attributes["spam"].nodeValue == "ham" and el.getAttribute("spam") == "ham" and el.attributes["spam2"].value == "bam" and el.attributes["spam2"].nodeValue == "bam" and el.getAttribute("spam2") == "bam") el.attributes["spam2"] = "bam2" self.confirm(len(el.attributes) == 2 and el.attributes["spam"].value == "ham" and el.attributes["spam"].nodeValue == "ham" and el.getAttribute("spam") == "ham" and el.attributes["spam2"].value == "bam2" and el.attributes["spam2"].nodeValue == "bam2" and el.getAttribute("spam2") == "bam2") dom.unlink() def testGetAttrList(self): pass def testGetAttrValues(self): pass def testGetAttrLength(self): pass def testGetAttribute(self): dom = Document() child = dom.appendChild( dom.createElementNS("http://www.python.org", "python:abc")) self.assertEqual(child.getAttribute('missing'), '') def testGetAttributeNS(self): dom = Document() child = dom.appendChild( dom.createElementNS("http://www.python.org", "python:abc")) child.setAttributeNS("http://www.w3.org", "xmlns:python", "http://www.python.org") self.assertEqual(child.getAttributeNS("http://www.w3.org", "python"), 'http://www.python.org') self.assertEqual(child.getAttributeNS("http://www.w3.org", "other"), '') child2 = child.appendChild(dom.createElement('abc')) self.assertEqual(child2.getAttributeNS("http://www.python.org", "missing"), '') def testGetAttributeNode(self): pass def testGetElementsByTagNameNS(self): d="""<foo xmlns:minidom='http://pyxml.sf.net/minidom'> <minidom:myelem/> </foo>""" dom = parseString(d) elems = dom.getElementsByTagNameNS("http://pyxml.sf.net/minidom", "myelem") self.confirm(len(elems) == 1 and elems[0].namespaceURI == "http://pyxml.sf.net/minidom" and elems[0].localName == "myelem" and elems[0].prefix == "minidom" and elems[0].tagName == "minidom:myelem" and elems[0].nodeName == "minidom:myelem") dom.unlink() def get_empty_nodelist_from_elements_by_tagName_ns_helper(self, doc, nsuri, lname): nodelist = doc.getElementsByTagNameNS(nsuri, lname) self.confirm(len(nodelist) == 0) def testGetEmptyNodeListFromElementsByTagNameNS(self): doc = parseString('<doc/>') self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, 'http://xml.python.org/namespaces/a', 'localname') self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, '*', 'splat') self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, 'http://xml.python.org/namespaces/a', '*') doc = parseString('<doc xmlns="http://xml.python.org/splat"><e/></doc>') self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, "http://xml.python.org/splat", "not-there") self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, "*", "not-there") self.get_empty_nodelist_from_elements_by_tagName_ns_helper( doc, "http://somewhere.else.net/not-there", "e") def testElementReprAndStr(self): dom = Document() el = dom.appendChild(dom.createElement("abc")) string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) dom.unlink() def testElementReprAndStrUnicode(self): dom = Document() el = dom.appendChild(dom.createElement("abc")) string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) dom.unlink() def testElementReprAndStrUnicodeNS(self): dom = Document() el = dom.appendChild( dom.createElementNS("http://www.slashdot.org", "slash:abc")) string1 = repr(el) string2 = str(el) self.confirm(string1 == string2) self.confirm("slash:abc" in string1) dom.unlink() def testAttributeRepr(self): dom = Document() el = dom.appendChild(dom.createElement("abc")) node = el.setAttribute("abc", "def") self.confirm(str(node) == repr(node)) dom.unlink() def testTextNodeRepr(self): pass def testWriteXML(self): str = '<?xml version="1.0" ?><a b="c"/>' dom = parseString(str) domstr = dom.toxml() dom.unlink() self.confirm(str == domstr) def testAltNewline(self): str = '<?xml version="1.0" ?>\n<a b="c"/>\n' dom = parseString(str) domstr = dom.toprettyxml(newl="\r\n") dom.unlink() self.confirm(domstr == str.replace("\n", "\r\n")) def test_toprettyxml_with_text_nodes(self): # see issue #4147, text nodes are not indented decl = '<?xml version="1.0" ?>\n' self.assertEqual(parseString('<B>A</B>').toprettyxml(), decl + '<B>A</B>\n') self.assertEqual(parseString('<C>A<B>A</B></C>').toprettyxml(), decl + '<C>\n\tA\n\t<B>A</B>\n</C>\n') self.assertEqual(parseString('<C><B>A</B>A</C>').toprettyxml(), decl + '<C>\n\t<B>A</B>\n\tA\n</C>\n') self.assertEqual(parseString('<C><B>A</B><B>A</B></C>').toprettyxml(), decl + '<C>\n\t<B>A</B>\n\t<B>A</B>\n</C>\n') self.assertEqual(parseString('<C><B>A</B>A<B>A</B></C>').toprettyxml(), decl + '<C>\n\t<B>A</B>\n\tA\n\t<B>A</B>\n</C>\n') def test_toprettyxml_with_adjacent_text_nodes(self): # see issue #4147, adjacent text nodes are indented normally dom = Document() elem = dom.createElement('elem') elem.appendChild(dom.createTextNode('TEXT')) elem.appendChild(dom.createTextNode('TEXT')) dom.appendChild(elem) decl = '<?xml version="1.0" ?>\n' self.assertEqual(dom.toprettyxml(), decl + '<elem>\n\tTEXT\n\tTEXT\n</elem>\n') def test_toprettyxml_preserves_content_of_text_node(self): # see issue #4147 for str in ('<B>A</B>', '<A><B>C</B></A>'): dom = parseString(str) dom2 = parseString(dom.toprettyxml()) self.assertEqual( dom.getElementsByTagName('B')[0].childNodes[0].toxml(), dom2.getElementsByTagName('B')[0].childNodes[0].toxml()) def testProcessingInstruction(self): dom = parseString('<e><?mypi \t\n data \t\n ?></e>') pi = dom.documentElement.firstChild self.confirm(pi.target == "mypi" and pi.data == "data \t\n " and pi.nodeName == "mypi" and pi.nodeType == Node.PROCESSING_INSTRUCTION_NODE and pi.attributes is None and not pi.hasChildNodes() and len(pi.childNodes) == 0 and pi.firstChild is None and pi.lastChild is None and pi.localName is None and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE) def testProcessingInstructionRepr(self): pass def testTextRepr(self): pass def testWriteText(self): pass def testDocumentElement(self): pass def testTooManyDocumentElements(self): doc = parseString("<doc/>") elem = doc.createElement("extra") # Should raise an exception when adding an extra document element. self.assertRaises(xml.dom.HierarchyRequestErr, doc.appendChild, elem) elem.unlink() doc.unlink() def testCreateElementNS(self): pass def testCreateAttributeNS(self): pass def testParse(self): pass def testParseString(self): pass def testComment(self): pass def testAttrListItem(self): pass def testAttrListItems(self): pass def testAttrListItemNS(self): pass def testAttrListKeys(self): pass def testAttrListKeysNS(self): pass def testRemoveNamedItem(self): doc = parseString("<doc a=''/>") e = doc.documentElement attrs = e.attributes a1 = e.getAttributeNode("a") a2 = attrs.removeNamedItem("a") self.confirm(a1.isSameNode(a2)) self.assertRaises(xml.dom.NotFoundErr, attrs.removeNamedItem, "a") def testRemoveNamedItemNS(self): doc = parseString("<doc xmlns:a='http://xml.python.org/' a:b=''/>") e = doc.documentElement attrs = e.attributes a1 = e.getAttributeNodeNS("http://xml.python.org/", "b") a2 = attrs.removeNamedItemNS("http://xml.python.org/", "b") self.confirm(a1.isSameNode(a2)) self.assertRaises(xml.dom.NotFoundErr, attrs.removeNamedItemNS, "http://xml.python.org/", "b") def testAttrListValues(self): pass def testAttrListLength(self): pass def testAttrList__getitem__(self): pass def testAttrList__setitem__(self): pass def testSetAttrValueandNodeValue(self): pass def testParseElement(self): pass def testParseAttributes(self): pass def testParseElementNamespaces(self): pass def testParseAttributeNamespaces(self): pass def testParseProcessingInstructions(self): pass def testChildNodes(self): pass def testFirstChild(self): pass def testHasChildNodes(self): dom = parseString("<doc><foo/></doc>") doc = dom.documentElement self.assertTrue(doc.hasChildNodes()) dom2 = parseString("<doc/>") doc2 = dom2.documentElement self.assertFalse(doc2.hasChildNodes()) def _testCloneElementCopiesAttributes(self, e1, e2, test): attrs1 = e1.attributes attrs2 = e2.attributes keys1 = list(attrs1.keys()) keys2 = list(attrs2.keys()) keys1.sort() keys2.sort() self.confirm(keys1 == keys2, "clone of element has same attribute keys") for i in range(len(keys1)): a1 = attrs1.item(i) a2 = attrs2.item(i) self.confirm(a1 is not a2 and a1.value == a2.value and a1.nodeValue == a2.nodeValue and a1.namespaceURI == a2.namespaceURI and a1.localName == a2.localName , "clone of attribute node has proper attribute values") self.confirm(a2.ownerElement is e2, "clone of attribute node correctly owned") def _setupCloneElement(self, deep): dom = parseString("<doc attr='value'><foo/></doc>") root = dom.documentElement clone = root.cloneNode(deep) self._testCloneElementCopiesAttributes( root, clone, "testCloneElement" + (deep and "Deep" or "Shallow")) # mutilate the original so shared data is detected root.tagName = root.nodeName = "MODIFIED" root.setAttribute("attr", "NEW VALUE") root.setAttribute("added", "VALUE") return dom, clone def testCloneElementShallow(self): dom, clone = self._setupCloneElement(0) self.confirm(len(clone.childNodes) == 0 and clone.childNodes.length == 0 and clone.parentNode is None and clone.toxml() == '<doc attr="value"/>' , "testCloneElementShallow") dom.unlink() def testCloneElementDeep(self): dom, clone = self._setupCloneElement(1) self.confirm(len(clone.childNodes) == 1 and clone.childNodes.length == 1 and clone.parentNode is None and clone.toxml() == '<doc attr="value"><foo/></doc>' , "testCloneElementDeep") dom.unlink() def testCloneDocumentShallow(self): doc = parseString("<?xml version='1.0'?>\n" "<!-- comment -->" "<!DOCTYPE doc [\n" "<!NOTATION notation SYSTEM 'http://xml.python.org/'>\n" "]>\n" "<doc attr='value'/>") doc2 = doc.cloneNode(0) self.confirm(doc2 is None, "testCloneDocumentShallow:" " shallow cloning of documents makes no sense!") def testCloneDocumentDeep(self): doc = parseString("<?xml version='1.0'?>\n" "<!-- comment -->" "<!DOCTYPE doc [\n" "<!NOTATION notation SYSTEM 'http://xml.python.org/'>\n" "]>\n" "<doc attr='value'/>") doc2 = doc.cloneNode(1) self.confirm(not (doc.isSameNode(doc2) or doc2.isSameNode(doc)), "testCloneDocumentDeep: document objects not distinct") self.confirm(len(doc.childNodes) == len(doc2.childNodes), "testCloneDocumentDeep: wrong number of Document children") self.confirm(doc2.documentElement.nodeType == Node.ELEMENT_NODE, "testCloneDocumentDeep: documentElement not an ELEMENT_NODE") self.confirm(doc2.documentElement.ownerDocument.isSameNode(doc2), "testCloneDocumentDeep: documentElement owner is not new document") self.confirm(not doc.documentElement.isSameNode(doc2.documentElement), "testCloneDocumentDeep: documentElement should not be shared") if doc.doctype is not None: # check the doctype iff the original DOM maintained it self.confirm(doc2.doctype.nodeType == Node.DOCUMENT_TYPE_NODE, "testCloneDocumentDeep: doctype not a DOCUMENT_TYPE_NODE") self.confirm(doc2.doctype.ownerDocument.isSameNode(doc2)) self.confirm(not doc.doctype.isSameNode(doc2.doctype)) def testCloneDocumentTypeDeepOk(self): doctype = create_nonempty_doctype() clone = doctype.cloneNode(1) self.confirm(clone is not None and clone.nodeName == doctype.nodeName and clone.name == doctype.name and clone.publicId == doctype.publicId and clone.systemId == doctype.systemId and len(clone.entities) == len(doctype.entities) and clone.entities.item(len(clone.entities)) is None and len(clone.notations) == len(doctype.notations) and clone.notations.item(len(clone.notations)) is None and len(clone.childNodes) == 0) for i in range(len(doctype.entities)): se = doctype.entities.item(i) ce = clone.entities.item(i) self.confirm((not se.isSameNode(ce)) and (not ce.isSameNode(se)) and ce.nodeName == se.nodeName and ce.notationName == se.notationName and ce.publicId == se.publicId and ce.systemId == se.systemId and ce.encoding == se.encoding and ce.actualEncoding == se.actualEncoding and ce.version == se.version) for i in range(len(doctype.notations)): sn = doctype.notations.item(i) cn = clone.notations.item(i) self.confirm((not sn.isSameNode(cn)) and (not cn.isSameNode(sn)) and cn.nodeName == sn.nodeName and cn.publicId == sn.publicId and cn.systemId == sn.systemId) def testCloneDocumentTypeDeepNotOk(self): doc = create_doc_with_doctype() clone = doc.doctype.cloneNode(1) self.confirm(clone is None, "testCloneDocumentTypeDeepNotOk") def testCloneDocumentTypeShallowOk(self): doctype = create_nonempty_doctype() clone = doctype.cloneNode(0) self.confirm(clone is not None and clone.nodeName == doctype.nodeName and clone.name == doctype.name and clone.publicId == doctype.publicId and clone.systemId == doctype.systemId and len(clone.entities) == 0 and clone.entities.item(0) is None and len(clone.notations) == 0 and clone.notations.item(0) is None and len(clone.childNodes) == 0) def testCloneDocumentTypeShallowNotOk(self): doc = create_doc_with_doctype() clone = doc.doctype.cloneNode(0) self.confirm(clone is None, "testCloneDocumentTypeShallowNotOk") def check_import_document(self, deep, testName): doc1 = parseString("<doc/>") doc2 = parseString("<doc/>") self.assertRaises(xml.dom.NotSupportedErr, doc1.importNode, doc2, deep) def testImportDocumentShallow(self): self.check_import_document(0, "testImportDocumentShallow") def testImportDocumentDeep(self): self.check_import_document(1, "testImportDocumentDeep") def testImportDocumentTypeShallow(self): src = create_doc_with_doctype() target = create_doc_without_doctype() self.assertRaises(xml.dom.NotSupportedErr, target.importNode, src.doctype, 0) def testImportDocumentTypeDeep(self): src = create_doc_with_doctype() target = create_doc_without_doctype() self.assertRaises(xml.dom.NotSupportedErr, target.importNode, src.doctype, 1) # Testing attribute clones uses a helper, and should always be deep, # even if the argument to cloneNode is false. def check_clone_attribute(self, deep, testName): doc = parseString("<doc attr='value'/>") attr = doc.documentElement.getAttributeNode("attr") self.assertNotEqual(attr, None) clone = attr.cloneNode(deep) self.confirm(not clone.isSameNode(attr)) self.confirm(not attr.isSameNode(clone)) self.confirm(clone.ownerElement is None, testName + ": ownerElement should be None") self.confirm(clone.ownerDocument.isSameNode(attr.ownerDocument), testName + ": ownerDocument does not match") self.confirm(clone.specified, testName + ": cloned attribute must have specified == True") def testCloneAttributeShallow(self): self.check_clone_attribute(0, "testCloneAttributeShallow") def testCloneAttributeDeep(self): self.check_clone_attribute(1, "testCloneAttributeDeep") def check_clone_pi(self, deep, testName): doc = parseString("<?target data?><doc/>") pi = doc.firstChild self.assertEqual(pi.nodeType, Node.PROCESSING_INSTRUCTION_NODE) clone = pi.cloneNode(deep) self.confirm(clone.target == pi.target and clone.data == pi.data) def testClonePIShallow(self): self.check_clone_pi(0, "testClonePIShallow") def testClonePIDeep(self): self.check_clone_pi(1, "testClonePIDeep") def testNormalize(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("first")) root.appendChild(doc.createTextNode("second")) self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2, "testNormalize -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 1 and root.childNodes.length == 1 and root.firstChild is root.lastChild and root.firstChild.data == "firstsecond" , "testNormalize -- result") doc.unlink() doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("")) doc.normalize() self.confirm(len(root.childNodes) == 0 and root.childNodes.length == 0, "testNormalize -- single empty node removed") doc.unlink() def testNormalizeCombineAndNextSibling(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("first")) root.appendChild(doc.createTextNode("second")) root.appendChild(doc.createElement("i")) self.confirm(len(root.childNodes) == 3 and root.childNodes.length == 3, "testNormalizeCombineAndNextSibling -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2 and root.firstChild.data == "firstsecond" and root.firstChild is not root.lastChild and root.firstChild.nextSibling is root.lastChild and root.firstChild.previousSibling is None and root.lastChild.previousSibling is root.firstChild and root.lastChild.nextSibling is None , "testNormalizeCombinedAndNextSibling -- result") doc.unlink() def testNormalizeDeleteWithPrevSibling(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("first")) root.appendChild(doc.createTextNode("")) self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2, "testNormalizeDeleteWithPrevSibling -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 1 and root.childNodes.length == 1 and root.firstChild.data == "first" and root.firstChild is root.lastChild and root.firstChild.nextSibling is None and root.firstChild.previousSibling is None , "testNormalizeDeleteWithPrevSibling -- result") doc.unlink() def testNormalizeDeleteWithNextSibling(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("")) root.appendChild(doc.createTextNode("second")) self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2, "testNormalizeDeleteWithNextSibling -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 1 and root.childNodes.length == 1 and root.firstChild.data == "second" and root.firstChild is root.lastChild and root.firstChild.nextSibling is None and root.firstChild.previousSibling is None , "testNormalizeDeleteWithNextSibling -- result") doc.unlink() def testNormalizeDeleteWithTwoNonTextSiblings(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createElement("i")) root.appendChild(doc.createTextNode("")) root.appendChild(doc.createElement("i")) self.confirm(len(root.childNodes) == 3 and root.childNodes.length == 3, "testNormalizeDeleteWithTwoSiblings -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2 and root.firstChild is not root.lastChild and root.firstChild.nextSibling is root.lastChild and root.firstChild.previousSibling is None and root.lastChild.previousSibling is root.firstChild and root.lastChild.nextSibling is None , "testNormalizeDeleteWithTwoSiblings -- result") doc.unlink() def testNormalizeDeleteAndCombine(self): doc = parseString("<doc/>") root = doc.documentElement root.appendChild(doc.createTextNode("")) root.appendChild(doc.createTextNode("second")) root.appendChild(doc.createTextNode("")) root.appendChild(doc.createTextNode("fourth")) root.appendChild(doc.createTextNode("")) self.confirm(len(root.childNodes) == 5 and root.childNodes.length == 5, "testNormalizeDeleteAndCombine -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 1 and root.childNodes.length == 1 and root.firstChild is root.lastChild and root.firstChild.data == "secondfourth" and root.firstChild.previousSibling is None and root.firstChild.nextSibling is None , "testNormalizeDeleteAndCombine -- result") doc.unlink() def testNormalizeRecursion(self): doc = parseString("<doc>" "<o>" "<i/>" "t" # #x "</o>" "<o>" "<o>" "t2" #x2 "</o>" "t3" #x3 "</o>" # "</doc>") root = doc.documentElement root.childNodes[0].appendChild(doc.createTextNode("")) root.childNodes[0].appendChild(doc.createTextNode("x")) root.childNodes[1].childNodes[0].appendChild(doc.createTextNode("x2")) root.childNodes[1].appendChild(doc.createTextNode("x3")) root.appendChild(doc.createTextNode("")) self.confirm(len(root.childNodes) == 3 and root.childNodes.length == 3 and len(root.childNodes[0].childNodes) == 4 and root.childNodes[0].childNodes.length == 4 and len(root.childNodes[1].childNodes) == 3 and root.childNodes[1].childNodes.length == 3 and len(root.childNodes[1].childNodes[0].childNodes) == 2 and root.childNodes[1].childNodes[0].childNodes.length == 2 , "testNormalize2 -- preparation") doc.normalize() self.confirm(len(root.childNodes) == 2 and root.childNodes.length == 2 and len(root.childNodes[0].childNodes) == 2 and root.childNodes[0].childNodes.length == 2 and len(root.childNodes[1].childNodes) == 2 and root.childNodes[1].childNodes.length == 2 and len(root.childNodes[1].childNodes[0].childNodes) == 1 and root.childNodes[1].childNodes[0].childNodes.length == 1 , "testNormalize2 -- childNodes lengths") self.confirm(root.childNodes[0].childNodes[1].data == "tx" and root.childNodes[1].childNodes[0].childNodes[0].data == "t2x2" and root.childNodes[1].childNodes[1].data == "t3x3" , "testNormalize2 -- joined text fields") self.confirm(root.childNodes[0].childNodes[1].nextSibling is None and root.childNodes[0].childNodes[1].previousSibling is root.childNodes[0].childNodes[0] and root.childNodes[0].childNodes[0].previousSibling is None and root.childNodes[0].childNodes[0].nextSibling is root.childNodes[0].childNodes[1] and root.childNodes[1].childNodes[1].nextSibling is None and root.childNodes[1].childNodes[1].previousSibling is root.childNodes[1].childNodes[0] and root.childNodes[1].childNodes[0].previousSibling is None and root.childNodes[1].childNodes[0].nextSibling is root.childNodes[1].childNodes[1] , "testNormalize2 -- sibling pointers") doc.unlink() def testBug0777884(self): doc = parseString("<o>text</o>") text = doc.documentElement.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) # Should run quietly, doing nothing. text.normalize() doc.unlink() def testBug1433694(self): doc = parseString("<o><i/>t</o>") node = doc.documentElement node.childNodes[1].nodeValue = "" node.normalize() self.confirm(node.childNodes[-1].nextSibling is None, "Final child's .nextSibling should be None") def testSiblings(self): doc = parseString("<doc><?pi?>text?<elm/></doc>") root = doc.documentElement (pi, text, elm) = root.childNodes self.confirm(pi.nextSibling is text and pi.previousSibling is None and text.nextSibling is elm and text.previousSibling is pi and elm.nextSibling is None and elm.previousSibling is text, "testSiblings") doc.unlink() def testParents(self): doc = parseString( "<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>") root = doc.documentElement elm1 = root.childNodes[0] (elm2a, elm2b) = elm1.childNodes elm3 = elm2b.childNodes[0] self.confirm(root.parentNode is doc and elm1.parentNode is root and elm2a.parentNode is elm1 and elm2b.parentNode is elm1 and elm3.parentNode is elm2b, "testParents") doc.unlink() def testNodeListItem(self): doc = parseString("<doc><e/><e/></doc>") children = doc.childNodes docelem = children[0] self.confirm(children[0] is children.item(0) and children.item(1) is None and docelem.childNodes.item(0) is docelem.childNodes[0] and docelem.childNodes.item(1) is docelem.childNodes[1] and docelem.childNodes.item(0).childNodes.item(0) is None, "test NodeList.item()") doc.unlink() def testEncodings(self): doc = parseString('<foo>&#x20ac;</foo>') self.assertEqual(doc.toxml(), '<?xml version="1.0" ?><foo>\u20ac</foo>') self.assertEqual(doc.toxml('utf-8'), b'<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>') self.assertEqual(doc.toxml('iso-8859-15'), b'<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>') self.assertEqual(doc.toxml('us-ascii'), b'<?xml version="1.0" encoding="us-ascii"?><foo>&#8364;</foo>') self.assertEqual(doc.toxml('utf-16'), '<?xml version="1.0" encoding="utf-16"?>' '<foo>\u20ac</foo>'.encode('utf-16')) # Verify that character decoding errors raise exceptions instead # of crashing self.assertRaises(UnicodeDecodeError, parseString, b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>') doc.unlink() class UserDataHandler: called = 0 def handle(self, operation, key, data, src, dst): dst.setUserData(key, data + 1, self) src.setUserData(key, None, None) self.called = 1 def testUserData(self): dom = Document() n = dom.createElement('e') self.confirm(n.getUserData("foo") is None) n.setUserData("foo", None, None) self.confirm(n.getUserData("foo") is None) n.setUserData("foo", 12, 12) n.setUserData("bar", 13, 13) self.confirm(n.getUserData("foo") == 12) self.confirm(n.getUserData("bar") == 13) n.setUserData("foo", None, None) self.confirm(n.getUserData("foo") is None) self.confirm(n.getUserData("bar") == 13) handler = self.UserDataHandler() n.setUserData("bar", 12, handler) c = n.cloneNode(1) self.confirm(handler.called and n.getUserData("bar") is None and c.getUserData("bar") == 13) n.unlink() c.unlink() dom.unlink() def checkRenameNodeSharedConstraints(self, doc, node): # Make sure illegal NS usage is detected: self.assertRaises(xml.dom.NamespaceErr, doc.renameNode, node, "http://xml.python.org/ns", "xmlns:foo") doc2 = parseString("<doc/>") self.assertRaises(xml.dom.WrongDocumentErr, doc2.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") def testRenameAttribute(self): doc = parseString("<doc a='v'/>") elem = doc.documentElement attrmap = elem.attributes attr = elem.attributes['a'] # Simple renaming attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b") self.confirm(attr.name == "b" and attr.nodeName == "b" and attr.localName is None and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE and attr.prefix is None and attr.value == "v" and elem.getAttributeNode("a") is None and elem.getAttributeNode("b").isSameNode(attr) and attrmap["b"].isSameNode(attr) and attr.ownerDocument.isSameNode(doc) and attr.ownerElement.isSameNode(elem)) # Rename to have a namespace, no prefix attr = doc.renameNode(attr, "http://xml.python.org/ns", "c") self.confirm(attr.name == "c" and attr.nodeName == "c" and attr.localName == "c" and attr.namespaceURI == "http://xml.python.org/ns" and attr.prefix is None and attr.value == "v" and elem.getAttributeNode("a") is None and elem.getAttributeNode("b") is None and elem.getAttributeNode("c").isSameNode(attr) and elem.getAttributeNodeNS( "http://xml.python.org/ns", "c").isSameNode(attr) and attrmap["c"].isSameNode(attr) and attrmap[("http://xml.python.org/ns", "c")].isSameNode(attr)) # Rename to have a namespace, with prefix attr = doc.renameNode(attr, "http://xml.python.org/ns2", "p:d") self.confirm(attr.name == "p:d" and attr.nodeName == "p:d" and attr.localName == "d" and attr.namespaceURI == "http://xml.python.org/ns2" and attr.prefix == "p" and attr.value == "v" and elem.getAttributeNode("a") is None and elem.getAttributeNode("b") is None and elem.getAttributeNode("c") is None and elem.getAttributeNodeNS( "http://xml.python.org/ns", "c") is None and elem.getAttributeNode("p:d").isSameNode(attr) and elem.getAttributeNodeNS( "http://xml.python.org/ns2", "d").isSameNode(attr) and attrmap["p:d"].isSameNode(attr) and attrmap[("http://xml.python.org/ns2", "d")].isSameNode(attr)) # Rename back to a simple non-NS node attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e") self.confirm(attr.name == "e" and attr.nodeName == "e" and attr.localName is None and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE and attr.prefix is None and attr.value == "v" and elem.getAttributeNode("a") is None and elem.getAttributeNode("b") is None and elem.getAttributeNode("c") is None and elem.getAttributeNode("p:d") is None and elem.getAttributeNodeNS( "http://xml.python.org/ns", "c") is None and elem.getAttributeNode("e").isSameNode(attr) and attrmap["e"].isSameNode(attr)) self.assertRaises(xml.dom.NamespaceErr, doc.renameNode, attr, "http://xml.python.org/ns", "xmlns") self.checkRenameNodeSharedConstraints(doc, attr) doc.unlink() def testRenameElement(self): doc = parseString("<doc/>") elem = doc.documentElement # Simple renaming elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "a") self.confirm(elem.tagName == "a" and elem.nodeName == "a" and elem.localName is None and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE and elem.prefix is None and elem.ownerDocument.isSameNode(doc)) # Rename to have a namespace, no prefix elem = doc.renameNode(elem, "http://xml.python.org/ns", "b") self.confirm(elem.tagName == "b" and elem.nodeName == "b" and elem.localName == "b" and elem.namespaceURI == "http://xml.python.org/ns" and elem.prefix is None and elem.ownerDocument.isSameNode(doc)) # Rename to have a namespace, with prefix elem = doc.renameNode(elem, "http://xml.python.org/ns2", "p:c") self.confirm(elem.tagName == "p:c" and elem.nodeName == "p:c" and elem.localName == "c" and elem.namespaceURI == "http://xml.python.org/ns2" and elem.prefix == "p" and elem.ownerDocument.isSameNode(doc)) # Rename back to a simple non-NS node elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "d") self.confirm(elem.tagName == "d" and elem.nodeName == "d" and elem.localName is None and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE and elem.prefix is None and elem.ownerDocument.isSameNode(doc)) self.checkRenameNodeSharedConstraints(doc, elem) doc.unlink() def testRenameOther(self): # We have to create a comment node explicitly since not all DOM # builders used with minidom add comments to the DOM. doc = xml.dom.minidom.getDOMImplementation().createDocument( xml.dom.EMPTY_NAMESPACE, "e", None) node = doc.createComment("comment") self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node, xml.dom.EMPTY_NAMESPACE, "foo") doc.unlink() def testWholeText(self): doc = parseString("<doc>a</doc>") elem = doc.documentElement text = elem.childNodes[0] self.assertEqual(text.nodeType, Node.TEXT_NODE) self.checkWholeText(text, "a") elem.appendChild(doc.createTextNode("b")) self.checkWholeText(text, "ab") elem.insertBefore(doc.createCDATASection("c"), text) self.checkWholeText(text, "cab") # make sure we don't cross other nodes splitter = doc.createComment("comment") elem.appendChild(splitter) text2 = doc.createTextNode("d") elem.appendChild(text2) self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createElement("x") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") x = doc.createProcessingInstruction("y", "z") elem.replaceChild(x, splitter) splitter = x self.checkWholeText(text, "cab") self.checkWholeText(text2, "d") elem.removeChild(splitter) self.checkWholeText(text, "cabd") self.checkWholeText(text2, "cabd") def testPatch1094164(self): doc = parseString("<doc><e/></doc>") elem = doc.documentElement e = elem.firstChild self.confirm(e.parentNode is elem, "Before replaceChild()") # Check that replacing a child with itself leaves the tree unchanged elem.replaceChild(e, e) self.confirm(e.parentNode is elem, "After replaceChild()") def testReplaceWholeText(self): def setup(): doc = parseString("<doc>a<e/>d</doc>") elem = doc.documentElement text1 = elem.firstChild text2 = elem.lastChild splitter = text1.nextSibling elem.insertBefore(doc.createTextNode("b"), splitter) elem.insertBefore(doc.createCDATASection("c"), text1) return doc, elem, text1, splitter, text2 doc, elem, text1, splitter, text2 = setup() text = text1.replaceWholeText("new content") self.checkWholeText(text, "new content") self.checkWholeText(text2, "d") self.confirm(len(elem.childNodes) == 3) doc, elem, text1, splitter, text2 = setup() text = text2.replaceWholeText("new content") self.checkWholeText(text, "new content") self.checkWholeText(text1, "cab") self.confirm(len(elem.childNodes) == 5) doc, elem, text1, splitter, text2 = setup() text = text1.replaceWholeText("") self.checkWholeText(text2, "d") self.confirm(text is None and len(elem.childNodes) == 2) def testSchemaType(self): doc = parseString( "<!DOCTYPE doc [\n" " <!ENTITY e1 SYSTEM 'http://xml.python.org/e1'>\n" " <!ENTITY e2 SYSTEM 'http://xml.python.org/e2'>\n" " <!ATTLIST doc id ID #IMPLIED \n" " ref IDREF #IMPLIED \n" " refs IDREFS #IMPLIED \n" " enum (a|b) #IMPLIED \n" " ent ENTITY #IMPLIED \n" " ents ENTITIES #IMPLIED \n" " nm NMTOKEN #IMPLIED \n" " nms NMTOKENS #IMPLIED \n" " text CDATA #IMPLIED \n" " >\n" "]><doc id='name' notid='name' text='splat!' enum='b'" " ref='name' refs='name name' ent='e1' ents='e1 e2'" " nm='123' nms='123 abc' />") elem = doc.documentElement # We don't want to rely on any specific loader at this point, so # just make sure we can get to all the names, and that the # DTD-based namespace is right. The names can vary by loader # since each supports a different level of DTD information. t = elem.schemaType self.confirm(t.name is None and t.namespace == xml.dom.EMPTY_NAMESPACE) names = "id notid text enum ref refs ent ents nm nms".split() for name in names: a = elem.getAttributeNode(name) t = a.schemaType self.confirm(hasattr(t, "name") and t.namespace == xml.dom.EMPTY_NAMESPACE) def testSetIdAttribute(self): doc = parseString("<doc a1='v' a2='w'/>") e = doc.documentElement a1 = e.getAttributeNode("a1") a2 = e.getAttributeNode("a2") self.confirm(doc.getElementById("v") is None and not a1.isId and not a2.isId) e.setIdAttribute("a1") self.confirm(e.isSameNode(doc.getElementById("v")) and a1.isId and not a2.isId) e.setIdAttribute("a2") self.confirm(e.isSameNode(doc.getElementById("v")) and e.isSameNode(doc.getElementById("w")) and a1.isId and a2.isId) # replace the a1 node; the new node should *not* be an ID a3 = doc.createAttribute("a1") a3.value = "v" e.setAttributeNode(a3) self.confirm(doc.getElementById("v") is None and e.isSameNode(doc.getElementById("w")) and not a1.isId and a2.isId and not a3.isId) # renaming an attribute should not affect its ID-ness: doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an") self.confirm(e.isSameNode(doc.getElementById("w")) and a2.isId) def testSetIdAttributeNS(self): NS1 = "http://xml.python.org/ns1" NS2 = "http://xml.python.org/ns2" doc = parseString("<doc" " xmlns:ns1='" + NS1 + "'" " xmlns:ns2='" + NS2 + "'" " ns1:a1='v' ns2:a2='w'/>") e = doc.documentElement a1 = e.getAttributeNodeNS(NS1, "a1") a2 = e.getAttributeNodeNS(NS2, "a2") self.confirm(doc.getElementById("v") is None and not a1.isId and not a2.isId) e.setIdAttributeNS(NS1, "a1") self.confirm(e.isSameNode(doc.getElementById("v")) and a1.isId and not a2.isId) e.setIdAttributeNS(NS2, "a2") self.confirm(e.isSameNode(doc.getElementById("v")) and e.isSameNode(doc.getElementById("w")) and a1.isId and a2.isId) # replace the a1 node; the new node should *not* be an ID a3 = doc.createAttributeNS(NS1, "a1") a3.value = "v" e.setAttributeNode(a3) self.confirm(e.isSameNode(doc.getElementById("w"))) self.confirm(not a1.isId) self.confirm(a2.isId) self.confirm(not a3.isId) self.confirm(doc.getElementById("v") is None) # renaming an attribute should not affect its ID-ness: doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an") self.confirm(e.isSameNode(doc.getElementById("w")) and a2.isId) def testSetIdAttributeNode(self): NS1 = "http://xml.python.org/ns1" NS2 = "http://xml.python.org/ns2" doc = parseString("<doc" " xmlns:ns1='" + NS1 + "'" " xmlns:ns2='" + NS2 + "'" " ns1:a1='v' ns2:a2='w'/>") e = doc.documentElement a1 = e.getAttributeNodeNS(NS1, "a1") a2 = e.getAttributeNodeNS(NS2, "a2") self.confirm(doc.getElementById("v") is None and not a1.isId and not a2.isId) e.setIdAttributeNode(a1) self.confirm(e.isSameNode(doc.getElementById("v")) and a1.isId and not a2.isId) e.setIdAttributeNode(a2) self.confirm(e.isSameNode(doc.getElementById("v")) and e.isSameNode(doc.getElementById("w")) and a1.isId and a2.isId) # replace the a1 node; the new node should *not* be an ID a3 = doc.createAttributeNS(NS1, "a1") a3.value = "v" e.setAttributeNode(a3) self.confirm(e.isSameNode(doc.getElementById("w"))) self.confirm(not a1.isId) self.confirm(a2.isId) self.confirm(not a3.isId) self.confirm(doc.getElementById("v") is None) # renaming an attribute should not affect its ID-ness: doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an") self.confirm(e.isSameNode(doc.getElementById("w")) and a2.isId) def testPickledDocument(self): doc = parseString("<?xml version='1.0' encoding='us-ascii'?>\n" "<!DOCTYPE doc PUBLIC 'http://xml.python.org/public'" " 'http://xml.python.org/system' [\n" " <!ELEMENT e EMPTY>\n" " <!ENTITY ent SYSTEM 'http://xml.python.org/entity'>\n" "]><doc attr='value'> text\n" "<?pi sample?> <!-- comment --> <e/> </doc>") s = pickle.dumps(doc) doc2 = pickle.loads(s) stack = [(doc, doc2)] while stack: n1, n2 = stack.pop() self.confirm(n1.nodeType == n2.nodeType and len(n1.childNodes) == len(n2.childNodes) and n1.nodeName == n2.nodeName and not n1.isSameNode(n2) and not n2.isSameNode(n1)) if n1.nodeType == Node.DOCUMENT_TYPE_NODE: len(n1.entities) len(n2.entities) len(n1.notations) len(n2.notations) self.confirm(len(n1.entities) == len(n2.entities) and len(n1.notations) == len(n2.notations)) for i in range(len(n1.notations)): # XXX this loop body doesn't seem to be executed? no1 = n1.notations.item(i) no2 = n1.notations.item(i) self.confirm(no1.name == no2.name and no1.publicId == no2.publicId and no1.systemId == no2.systemId) stack.append((no1, no2)) for i in range(len(n1.entities)): e1 = n1.entities.item(i) e2 = n2.entities.item(i) self.confirm(e1.notationName == e2.notationName and e1.publicId == e2.publicId and e1.systemId == e2.systemId) stack.append((e1, e2)) if n1.nodeType != Node.DOCUMENT_NODE: self.confirm(n1.ownerDocument.isSameNode(doc) and n2.ownerDocument.isSameNode(doc2)) for i in range(len(n1.childNodes)): stack.append((n1.childNodes[i], n2.childNodes[i])) def testSerializeCommentNodeWithDoubleHyphen(self): doc = create_doc_without_doctype() doc.appendChild(doc.createComment("foo--bar")) self.assertRaises(ValueError, doc.toxml) def testEmptyXMLNSValue(self): doc = parseString("<element xmlns=''>\n" "<foo/>\n</element>") doc2 = parseString(doc.toxml()) self.confirm(doc2.namespaceURI == xml.dom.EMPTY_NAMESPACE) def testExceptionOnSpacesInXMLNSValue(self): with self.assertRaisesRegex(ValueError, 'Unsupported syntax'): parseString('<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>') def testDocRemoveChild(self): doc = parse(tstfile) title_tag = doc.documentElement.getElementsByTagName("TITLE")[0] self.assertRaises( xml.dom.NotFoundErr, doc.removeChild, title_tag) num_children_before = len(doc.childNodes) doc.removeChild(doc.childNodes[0]) num_children_after = len(doc.childNodes) self.assertTrue(num_children_after == num_children_before - 1) def testProcessingInstructionNameError(self): # wrong variable in .nodeValue property will # lead to "NameError: name 'data' is not defined" doc = parse(tstfile) pi = doc.createProcessingInstruction("y", "z") pi.nodeValue = "crash" def test_main(): run_unittest(MinidomTest) if __name__ == "__main__": test_main()
lgpl-3.0
[ 3, 511, 367, 2748, 14, 4556, 14, 21827, 199, 199, 646, 5927, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 12, 2342, 493, 199, 646, 2882, 199, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 12, 5013, 12, 7543, 12, 2198, 1558, 199, 504, 2748, 14, 4556, 14, 21827, 492, 664, 10462, 7921, 421, 199, 84, 270, 493, 275, 2342, 493, 480, 396, 14, 1652, 401, 15488, 628, 1652, 18481, 531, 199, 199, 3, 710, 2295, 402, 7543, 804, 16306, 675, 3520, 10897, 370, 6982, 199, 3, 314, 8247, 370, 1736, 543, 12, 3967, 440, 1006, 14316, 27378, 5965, 199, 3, 1218, 314, 7543, 804, 3380, 14, 199, 318, 1218, 63, 1301, 63, 7395, 63, 6356, 8, 6356, 29, 403, 304, 272, 372, 664, 10462, 7921, 1252, 981, 5564, 8, 403, 12, 298, 1301, 401, 13265, 9, 199, 199, 318, 1218, 63, 3592, 1171, 63, 6356, 837, 272, 13265, 275, 664, 10462, 7921, 1252, 981, 5564, 804, 480, 1301, 401, 488, 12, 488, 9, 272, 13265, 14, 8327, 423, 3610, 275, 942, 272, 13265, 14, 1397, 1298, 423, 3610, 275, 942, 272, 15843, 275, 2748, 14, 4556, 14, 21827, 14, 1763, 425, 480, 1662, 13, 12251, 401, 488, 12, 3147, 298, 1014, 921, 1652, 14, 1548, 14, 1308, 15, 1397, 1298, 15, 1662, 531, 272, 13265, 14, 1397, 1298, 423, 3610, 14, 740, 8, 12251, 9, 272, 4642, 275, 2748, 14, 4556, 14, 21827, 14, 7302, 480, 1662, 13, 4502, 401, 488, 12, 2511, 298, 1014, 921, 1652, 14, 1548, 14, 1308, 15, 8327, 15, 1662, 401, 2511, 298, 1662, 13, 12251, 531, 272, 4642, 14, 1023, 275, 298, 17, 14, 16, 2, 272, 4642, 14, 2991, 275, 298, 1624, 13, 24, 2, 272, 4642, 14, 6514, 7630, 275, 298, 527, 13, 4371, 2, 272, 13265, 14, 8327, 423, 3610, 14, 740, 8, 4502, 9, 272, 372, 13265, 199, 199, 318, 1218, 63, 1301, 63, 1045, 63, 6356, 837, 272, 13265, 275, 1218, 63, 3592, 1171, 63, 6356, 342, 272, 1382, 275, 1218, 63, 1301, 63, 7395, 63, 6356, 8, 6356, 9, 272, 13265, 14, 8327, 14, 1053, 8, 16, 680, 30518, 275, 1382, 272, 13265, 14, 1397, 1298, 14, 1053, 8, 16, 680, 30518, 275, 1382, 272, 372, 1382, 199, 199, 533, 10195, 13674, 774, 8, 2796, 14, 1746, 304, 272, 347, 12679, 8, 277, 12, 511, 12, 511, 354, 275, 298, 774, 2349, 267, 291, 14, 1815, 8, 396, 12, 511, 354, 9, 339, 347, 1104, 55, 16668, 1872, 8, 277, 12, 1031, 12, 308, 304, 267, 307, 275, 1031, 14, 21224, 1872, 267, 291, 14, 9548, 8, 84, 508, 308, 12, 298, 11660, 316, 367, 450, 82, 12, 1911, 450, 82, 2, 450, 334, 83, 12, 307, 430, 339, 347, 511, 4003, 26637, 8, 277, 304, 267, 543, 1551, 8, 84, 270, 493, 9, 465, 570, 26, 288, 8266, 275, 2198, 8, 493, 9, 288, 8266, 14, 7162, 342, 288, 291, 14, 9548, 8, 6074, 8, 4556, 12, 7543, 430, 339, 347, 19970, 13843, 12902, 8, 277, 304, 267, 8266, 275, 2198, 8, 84, 270, 493, 9, 267, 291, 14, 9548, 8, 4556, 14, 15045, 480, 2673, 531, 508, 971, 355, 8266, 14, 22464, 14, 15045, 480, 2673, 2237, 267, 8266, 14, 7162, 342, 339, 347, 511, 9971, 13569, 8, 277, 304, 267, 8266, 275, 2198, 1558, 6757, 1301, 2535, 1421, 15, 2957, 1301, 9579, 267, 1738, 275, 8266, 14, 22464, 267, 6193, 275, 1738, 14, 10626, 59, 16, 61, 267, 1279, 3701, 275, 8266, 14, 20296, 480, 2108, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 12, 6193, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 499, 355, 436, 1738, 14, 10626, 14, 1267, 508, 499, 355, 436, 1738, 14, 10626, 59, 16, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 16, 9, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 59, 17, 61, 365, 6193, 355, 436, 1738, 14, 10626, 14, 1053, 8, 17, 9, 365, 6193, 355, 436, 1738, 14, 22262, 365, 1279, 3701, 355, 436, 1738, 14, 2019, 3493, 365, 6193, 355, 436, 1738, 14, 475, 1652, 342, 508, 3886, 1301, 2535, 2108, 31022, 1421, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 1279, 3701, 275, 8266, 14, 20296, 480, 2108, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 12, 488, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 650, 355, 436, 1738, 14, 10626, 14, 1267, 508, 650, 355, 436, 1738, 14, 10626, 59, 17, 61, 365, 6193, 355, 436, 1738, 14, 10626, 14, 1053, 8, 17, 9, 365, 6193, 355, 436, 1738, 14, 10626, 59, 18, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 18, 9, 365, 1279, 3701, 355, 436, 1738, 14, 2019, 3493, 365, 1279, 3701, 355, 436, 1279, 3701, 14, 6352, 16016, 365, 6193, 355, 436, 1738, 14, 475, 1652, 342, 508, 3886, 1301, 2535, 2108, 31022, 1421, 31022, 2108, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 1279, 3701, 18, 275, 8266, 14, 20296, 480, 1700, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 18, 12, 1279, 3701, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 841, 355, 436, 1738, 14, 10626, 14, 1267, 508, 841, 355, 436, 1738, 14, 10626, 59, 18, 61, 365, 1279, 3701, 18, 355, 436, 1738, 14, 10626, 14, 1053, 8, 18, 9, 365, 1279, 3701, 18, 355, 436, 1738, 14, 10626, 59, 19, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 19, 9, 365, 1279, 3701, 355, 436, 1279, 3701, 18, 14, 30336, 365, 1279, 3701, 355, 436, 1279, 3701, 14, 6352, 16016, 365, 1279, 3701, 18, 355, 436, 1738, 14, 475, 1652, 342, 508, 355, 3886, 1301, 2535, 2108, 31022, 1421, 31022, 1700, 31022, 2108, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 8266, 14, 7162, 342, 339, 347, 485, 981, 63, 7677, 63 ]
[ 511, 367, 2748, 14, 4556, 14, 21827, 199, 199, 646, 5927, 199, 504, 511, 14, 4058, 492, 1255, 63, 2796, 12, 2342, 493, 199, 646, 2882, 199, 199, 646, 2748, 14, 4556, 14, 21827, 199, 199, 504, 2748, 14, 4556, 14, 21827, 492, 2198, 12, 5013, 12, 7543, 12, 2198, 1558, 199, 504, 2748, 14, 4556, 14, 21827, 492, 664, 10462, 7921, 421, 199, 84, 270, 493, 275, 2342, 493, 480, 396, 14, 1652, 401, 15488, 628, 1652, 18481, 531, 199, 199, 3, 710, 2295, 402, 7543, 804, 16306, 675, 3520, 10897, 370, 6982, 199, 3, 314, 8247, 370, 1736, 543, 12, 3967, 440, 1006, 14316, 27378, 5965, 199, 3, 1218, 314, 7543, 804, 3380, 14, 199, 318, 1218, 63, 1301, 63, 7395, 63, 6356, 8, 6356, 29, 403, 304, 272, 372, 664, 10462, 7921, 1252, 981, 5564, 8, 403, 12, 298, 1301, 401, 13265, 9, 199, 199, 318, 1218, 63, 3592, 1171, 63, 6356, 837, 272, 13265, 275, 664, 10462, 7921, 1252, 981, 5564, 804, 480, 1301, 401, 488, 12, 488, 9, 272, 13265, 14, 8327, 423, 3610, 275, 942, 272, 13265, 14, 1397, 1298, 423, 3610, 275, 942, 272, 15843, 275, 2748, 14, 4556, 14, 21827, 14, 1763, 425, 480, 1662, 13, 12251, 401, 488, 12, 3147, 298, 1014, 921, 1652, 14, 1548, 14, 1308, 15, 1397, 1298, 15, 1662, 531, 272, 13265, 14, 1397, 1298, 423, 3610, 14, 740, 8, 12251, 9, 272, 4642, 275, 2748, 14, 4556, 14, 21827, 14, 7302, 480, 1662, 13, 4502, 401, 488, 12, 2511, 298, 1014, 921, 1652, 14, 1548, 14, 1308, 15, 8327, 15, 1662, 401, 2511, 298, 1662, 13, 12251, 531, 272, 4642, 14, 1023, 275, 298, 17, 14, 16, 2, 272, 4642, 14, 2991, 275, 298, 1624, 13, 24, 2, 272, 4642, 14, 6514, 7630, 275, 298, 527, 13, 4371, 2, 272, 13265, 14, 8327, 423, 3610, 14, 740, 8, 4502, 9, 272, 372, 13265, 199, 199, 318, 1218, 63, 1301, 63, 1045, 63, 6356, 837, 272, 13265, 275, 1218, 63, 3592, 1171, 63, 6356, 342, 272, 1382, 275, 1218, 63, 1301, 63, 7395, 63, 6356, 8, 6356, 9, 272, 13265, 14, 8327, 14, 1053, 8, 16, 680, 30518, 275, 1382, 272, 13265, 14, 1397, 1298, 14, 1053, 8, 16, 680, 30518, 275, 1382, 272, 372, 1382, 199, 199, 533, 10195, 13674, 774, 8, 2796, 14, 1746, 304, 272, 347, 12679, 8, 277, 12, 511, 12, 511, 354, 275, 298, 774, 2349, 267, 291, 14, 1815, 8, 396, 12, 511, 354, 9, 339, 347, 1104, 55, 16668, 1872, 8, 277, 12, 1031, 12, 308, 304, 267, 307, 275, 1031, 14, 21224, 1872, 267, 291, 14, 9548, 8, 84, 508, 308, 12, 298, 11660, 316, 367, 450, 82, 12, 1911, 450, 82, 2, 450, 334, 83, 12, 307, 430, 339, 347, 511, 4003, 26637, 8, 277, 304, 267, 543, 1551, 8, 84, 270, 493, 9, 465, 570, 26, 288, 8266, 275, 2198, 8, 493, 9, 288, 8266, 14, 7162, 342, 288, 291, 14, 9548, 8, 6074, 8, 4556, 12, 7543, 430, 339, 347, 19970, 13843, 12902, 8, 277, 304, 267, 8266, 275, 2198, 8, 84, 270, 493, 9, 267, 291, 14, 9548, 8, 4556, 14, 15045, 480, 2673, 531, 508, 971, 355, 8266, 14, 22464, 14, 15045, 480, 2673, 2237, 267, 8266, 14, 7162, 342, 339, 347, 511, 9971, 13569, 8, 277, 304, 267, 8266, 275, 2198, 1558, 6757, 1301, 2535, 1421, 15, 2957, 1301, 9579, 267, 1738, 275, 8266, 14, 22464, 267, 6193, 275, 1738, 14, 10626, 59, 16, 61, 267, 1279, 3701, 275, 8266, 14, 20296, 480, 2108, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 12, 6193, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 499, 355, 436, 1738, 14, 10626, 14, 1267, 508, 499, 355, 436, 1738, 14, 10626, 59, 16, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 16, 9, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 59, 17, 61, 365, 6193, 355, 436, 1738, 14, 10626, 14, 1053, 8, 17, 9, 365, 6193, 355, 436, 1738, 14, 22262, 365, 1279, 3701, 355, 436, 1738, 14, 2019, 3493, 365, 6193, 355, 436, 1738, 14, 475, 1652, 342, 508, 3886, 1301, 2535, 2108, 31022, 1421, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 1279, 3701, 275, 8266, 14, 20296, 480, 2108, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 12, 488, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 650, 355, 436, 1738, 14, 10626, 14, 1267, 508, 650, 355, 436, 1738, 14, 10626, 59, 17, 61, 365, 6193, 355, 436, 1738, 14, 10626, 14, 1053, 8, 17, 9, 365, 6193, 355, 436, 1738, 14, 10626, 59, 18, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 18, 9, 365, 1279, 3701, 355, 436, 1738, 14, 2019, 3493, 365, 1279, 3701, 355, 436, 1279, 3701, 14, 6352, 16016, 365, 6193, 355, 436, 1738, 14, 475, 1652, 342, 508, 3886, 1301, 2535, 2108, 31022, 1421, 31022, 2108, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 1279, 3701, 18, 275, 8266, 14, 20296, 480, 1700, 531, 267, 1738, 14, 3176, 13569, 8, 685, 3701, 18, 12, 1279, 3701, 9, 267, 291, 14, 9548, 8, 552, 8, 1231, 14, 10626, 9, 508, 841, 355, 436, 1738, 14, 10626, 14, 1267, 508, 841, 355, 436, 1738, 14, 10626, 59, 18, 61, 365, 1279, 3701, 18, 355, 436, 1738, 14, 10626, 14, 1053, 8, 18, 9, 365, 1279, 3701, 18, 355, 436, 1738, 14, 10626, 59, 19, 61, 365, 1279, 3701, 355, 436, 1738, 14, 10626, 14, 1053, 8, 19, 9, 365, 1279, 3701, 355, 436, 1279, 3701, 18, 14, 30336, 365, 1279, 3701, 355, 436, 1279, 3701, 14, 6352, 16016, 365, 1279, 3701, 18, 355, 436, 1738, 14, 475, 1652, 342, 508, 355, 3886, 1301, 2535, 2108, 31022, 1421, 31022, 1700, 31022, 2108, 15, 2957, 1301, 4335, 355, 2360, 298, 396, 9971, 13569, 1553, 1031, 7684, 15090, 315, 3123, 531, 267, 8266, 14, 7162, 342, 339, 347, 485, 981, 63, 7677, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
markcn/kernel_huawei_c8812
tools/perf/scripts/python/sctop.py
11180
1924
# system call top # (c) 2010, Tom Zanussi <tzanussi@gmail.com> # Licensed under the terms of the GNU GPL License version 2 # # Periodically displays system-wide system call totals, broken down by # syscall. If a [comm] arg is specified, only syscalls called by # [comm] are displayed. If an [interval] arg is specified, the display # will be refreshed every [interval] seconds. The default interval is # 3 seconds. import os, sys, thread, time sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from perf_trace_context import * from Core import * from Util import * usage = "perf script -s sctop.py [comm] [interval]\n"; for_comm = None default_interval = 3 interval = default_interval if len(sys.argv) > 3: sys.exit(usage) if len(sys.argv) > 2: for_comm = sys.argv[1] interval = int(sys.argv[2]) elif len(sys.argv) > 1: try: interval = int(sys.argv[1]) except ValueError: for_comm = sys.argv[1] interval = default_interval syscalls = autodict() def trace_begin(): thread.start_new_thread(print_syscall_totals, (interval,)) pass def raw_syscalls__sys_enter(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, id, args): if for_comm is not None: if common_comm != for_comm: return try: syscalls[id] += 1 except TypeError: syscalls[id] = 1 def print_syscall_totals(interval): while 1: clear_term() if for_comm is not None: print "\nsyscall events for %s:\n\n" % (for_comm), else: print "\nsyscall events:\n\n", print "%-40s %10s\n" % ("event", "count"), print "%-40s %10s\n" % ("----------------------------------------", \ "----------"), for id, val in sorted(syscalls.iteritems(), key = lambda(k, v): (v, k), \ reverse = True): try: print "%-40s %10d\n" % (syscall_name(id), val), except TypeError: pass syscalls.clear() time.sleep(interval)
gpl-2.0
[ 3, 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2656, 1240, 2746, 199, 3, 334, 67, 9, 7129, 12, 21644, 29385, 665, 29453, 32, 6799, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 3492, 11273, 1183, 17561, 2656, 13, 13062, 2656, 1240, 23576, 12, 10529, 3224, 701, 199, 3, 18901, 14, 221, 982, 282, 359, 1404, 61, 1680, 365, 2013, 12, 1454, 19473, 2797, 701, 199, 3, 359, 1404, 61, 787, 9080, 14, 982, 376, 359, 4284, 61, 1680, 365, 2013, 12, 314, 2929, 199, 3, 911, 506, 9236, 379, 4036, 359, 4284, 61, 4696, 14, 221, 710, 849, 6252, 365, 199, 3, 650, 4696, 14, 199, 199, 646, 747, 12, 984, 12, 2462, 12, 900, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 971, 199, 198, 9807, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 199, 504, 8582, 63, 3446, 63, 1100, 492, 627, 199, 504, 11672, 492, 627, 199, 504, 21248, 492, 627, 199, 199, 3807, 275, 298, 9452, 2884, 446, 83, 308, 319, 411, 14, 647, 359, 1404, 61, 359, 4284, 7272, 78, 11436, 199, 199, 509, 63, 1404, 275, 488, 199, 885, 63, 4284, 275, 650, 199, 4284, 275, 849, 63, 4284, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 650, 26, 199, 198, 1274, 14, 2224, 8, 3807, 9, 199, 199, 692, 822, 8, 1274, 14, 3020, 9, 690, 499, 26, 199, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 199, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 18, 566, 199, 4164, 822, 8, 1274, 14, 3020, 9, 690, 413, 26, 199, 198, 893, 26, 507, 198, 4284, 275, 1109, 8, 1274, 14, 3020, 59, 17, 566, 199, 198, 2590, 1722, 26, 507, 198, 509, 63, 1404, 275, 984, 14, 3020, 59, 17, 61, 507, 198, 4284, 275, 849, 63, 4284, 199, 199, 14507, 275, 27477, 342, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 2671, 14, 928, 63, 1222, 63, 2671, 8, 1361, 63, 19444, 63, 17552, 12, 334, 4284, 4641, 199, 198, 1529, 199, 199, 318, 3066, 63, 14507, 363, 1274, 63, 4200, 8, 1430, 63, 354, 12, 1067, 12, 2863, 63, 3541, 12, 199, 198, 2330, 63, 4855, 12, 2863, 63, 9618, 12, 2863, 63, 3150, 12, 2863, 63, 1404, 12, 199, 198, 344, 12, 1249, 304, 199, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 507, 198, 692, 2863, 63, 1404, 1137, 367, 63, 1404, 26, 686, 198, 1107, 199, 198, 893, 26, 507, 198, 14507, 59, 344, 61, 847, 413, 199, 198, 2590, 3146, 26, 507, 198, 14507, 59, 344, 61, 275, 413, 199, 199, 318, 870, 63, 19444, 63, 17552, 8, 4284, 304, 199, 198, 6710, 413, 26, 507, 198, 3584, 63, 5125, 342, 507, 198, 692, 367, 63, 1404, 365, 440, 488, 26, 686, 198, 1361, 1867, 26605, 4474, 367, 450, 83, 3427, 78, 60, 78, 2, 450, 334, 509, 63, 1404, 395, 507, 198, 2836, 26, 686, 198, 1361, 1867, 26605, 4474, 3427, 78, 60, 78, 401, 2742, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 1430, 401, 298, 835, 1288, 507, 198, 1361, 18301, 2167, 83, 221, 450, 709, 83, 60, 78, 2, 450, 1689, 32111, 401, 971, 5264, 298, 9460, 1288, 2742, 198, 509, 1305, 12, 1139, 315, 3355, 8, 14507, 14, 4611, 1062, 790, 275, 2400, 8, 75, 12, 373, 304, 334, 86, 12, 1022, 395, 971, 4671, 420, 3837, 275, 715, 304, 686, 198, 893, 26, 1585, 198, 1361, 18301, 2167, 83, 221, 450, 709, 68, 60, 78, 2, 450, 334, 19444, 63, 354, 8, 344, 395, 1139, 395, 686, 198, 2590, 3146, 26, 1585, 198, 1529, 507, 198, 14507, 14, 3584, 342, 507, 198, 521, 14, 4532, 8, 4284, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
programadorjc/django
django/utils/numberformat.py
431
1944
from __future__ import unicode_literals from decimal import Decimal from django.conf import settings from django.utils import six from django.utils.safestring import mark_safe def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False): """ Gets a number (as a number or string), and returns it as a string, using formats defined as arguments: * decimal_sep: Decimal separator symbol (for example ".") * decimal_pos: Number of decimal positions * grouping: Number of digits in every group limited by thousand separator * thousand_sep: Thousand separator symbol (for example ",") """ use_grouping = settings.USE_L10N and settings.USE_THOUSAND_SEPARATOR use_grouping = use_grouping or force_grouping use_grouping = use_grouping and grouping > 0 # Make the common case fast if isinstance(number, int) and not use_grouping and not decimal_pos: return mark_safe(six.text_type(number)) # sign sign = '' if isinstance(number, Decimal): str_number = '{:f}'.format(number) else: str_number = six.text_type(number) if str_number[0] == '-': sign = '-' str_number = str_number[1:] # decimal part if '.' in str_number: int_part, dec_part = str_number.split('.') if decimal_pos is not None: dec_part = dec_part[:decimal_pos] else: int_part, dec_part = str_number, '' if decimal_pos is not None: dec_part = dec_part + ('0' * (decimal_pos - len(dec_part))) if dec_part: dec_part = decimal_sep + dec_part # grouping if use_grouping: int_part_gd = '' for cnt, digit in enumerate(int_part[::-1]): if cnt and not cnt % grouping: int_part_gd += thousand_sep[::-1] int_part_gd += digit int_part = int_part_gd[::-1] return sign + int_part + dec_part
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 421, 199, 318, 1475, 8, 1955, 12, 6107, 63, 4127, 12, 6107, 63, 1712, 29, 403, 12, 17786, 29, 16, 12, 294, 1785, 460, 63, 4127, 4581, 1779, 3542, 63, 22390, 29, 797, 304, 272, 408, 272, 14509, 282, 1329, 334, 305, 282, 1329, 503, 1059, 395, 436, 2529, 652, 465, 282, 1059, 12, 272, 1808, 6752, 3247, 465, 2368, 26, 339, 627, 6107, 63, 4127, 26, 6345, 9432, 5272, 334, 509, 2893, 298, 2685, 272, 627, 6107, 63, 1712, 26, 4860, 402, 6107, 12266, 272, 627, 17786, 26, 4860, 402, 7576, 315, 4036, 1572, 13988, 701, 294, 1785, 460, 9432, 272, 627, 294, 1785, 460, 63, 4127, 26, 18049, 527, 460, 9432, 5272, 334, 509, 2893, 3872, 531, 272, 408, 272, 675, 63, 22390, 275, 2202, 14, 4701, 63, 44, 709, 46, 436, 2202, 14, 4701, 63, 28714, 63, 15828, 272, 675, 63, 22390, 275, 675, 63, 22390, 503, 3542, 63, 22390, 272, 675, 63, 22390, 275, 675, 63, 22390, 436, 17786, 690, 378, 272, 327, 4155, 314, 2863, 1930, 7377, 272, 340, 1228, 8, 1955, 12, 1109, 9, 436, 440, 675, 63, 22390, 436, 440, 6107, 63, 1712, 26, 267, 372, 2216, 63, 3489, 8, 4174, 14, 505, 63, 466, 8, 1955, 430, 272, 327, 2070, 272, 2070, 275, 2125, 272, 340, 1228, 8, 1955, 12, 6345, 304, 267, 620, 63, 1955, 275, 5041, 26, 70, 5285, 908, 8, 1955, 9, 272, 587, 26, 267, 620, 63, 1955, 275, 3816, 14, 505, 63, 466, 8, 1955, 9, 272, 340, 620, 63, 1955, 59, 16, 61, 508, 20905, 267, 2070, 275, 10791, 267, 620, 63, 1955, 275, 620, 63, 1955, 59, 17, 2938, 272, 327, 6107, 1777, 272, 340, 7815, 315, 620, 63, 1955, 26, 267, 1109, 63, 2064, 12, 9700, 63, 2064, 275, 620, 63, 1955, 14, 1294, 7563, 267, 340, 6107, 63, 1712, 365, 440, 488, 26, 288, 9700, 63, 2064, 275, 9700, 63, 2064, 1491, 6355, 63, 1712, 61, 272, 587, 26, 267, 1109, 63, 2064, 12, 9700, 63, 2064, 275, 620, 63, 1955, 12, 2125, 272, 340, 6107, 63, 1712, 365, 440, 488, 26, 267, 9700, 63, 2064, 275, 9700, 63, 2064, 435, 661, 16, 7, 627, 334, 6355, 63, 1712, 446, 822, 8, 7778, 63, 2064, 1724, 272, 340, 9700, 63, 2064, 26, 267, 9700, 63, 2064, 275, 6107, 63, 4127, 435, 9700, 63, 2064, 272, 327, 17786, 272, 340, 675, 63, 22390, 26, 267, 1109, 63, 2064, 63, 7136, 275, 2125, 267, 367, 12703, 12, 10964, 315, 3874, 8, 442, 63, 2064, 14172, 17, 4682, 288, 340, 12703, 436, 440, 12703, 450, 17786, 26, 355, 1109, 63, 2064, 63, 7136, 847, 294, 1785, 460, 63, 4127, 14172, 17, 61, 288, 1109, 63, 2064, 63, 7136, 847, 10964, 267, 1109, 63, 2064, 275, 1109, 63, 2064, 63, 7136, 14172, 17, 61, 272, 372, 2070, 435, 1109, 63, 2064, 435, 9700, 63, 2064, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 6107, 492, 6345, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 421, 199, 318, 1475, 8, 1955, 12, 6107, 63, 4127, 12, 6107, 63, 1712, 29, 403, 12, 17786, 29, 16, 12, 294, 1785, 460, 63, 4127, 4581, 1779, 3542, 63, 22390, 29, 797, 304, 272, 408, 272, 14509, 282, 1329, 334, 305, 282, 1329, 503, 1059, 395, 436, 2529, 652, 465, 282, 1059, 12, 272, 1808, 6752, 3247, 465, 2368, 26, 339, 627, 6107, 63, 4127, 26, 6345, 9432, 5272, 334, 509, 2893, 298, 2685, 272, 627, 6107, 63, 1712, 26, 4860, 402, 6107, 12266, 272, 627, 17786, 26, 4860, 402, 7576, 315, 4036, 1572, 13988, 701, 294, 1785, 460, 9432, 272, 627, 294, 1785, 460, 63, 4127, 26, 18049, 527, 460, 9432, 5272, 334, 509, 2893, 3872, 531, 272, 408, 272, 675, 63, 22390, 275, 2202, 14, 4701, 63, 44, 709, 46, 436, 2202, 14, 4701, 63, 28714, 63, 15828, 272, 675, 63, 22390, 275, 675, 63, 22390, 503, 3542, 63, 22390, 272, 675, 63, 22390, 275, 675, 63, 22390, 436, 17786, 690, 378, 272, 327, 4155, 314, 2863, 1930, 7377, 272, 340, 1228, 8, 1955, 12, 1109, 9, 436, 440, 675, 63, 22390, 436, 440, 6107, 63, 1712, 26, 267, 372, 2216, 63, 3489, 8, 4174, 14, 505, 63, 466, 8, 1955, 430, 272, 327, 2070, 272, 2070, 275, 2125, 272, 340, 1228, 8, 1955, 12, 6345, 304, 267, 620, 63, 1955, 275, 5041, 26, 70, 5285, 908, 8, 1955, 9, 272, 587, 26, 267, 620, 63, 1955, 275, 3816, 14, 505, 63, 466, 8, 1955, 9, 272, 340, 620, 63, 1955, 59, 16, 61, 508, 20905, 267, 2070, 275, 10791, 267, 620, 63, 1955, 275, 620, 63, 1955, 59, 17, 2938, 272, 327, 6107, 1777, 272, 340, 7815, 315, 620, 63, 1955, 26, 267, 1109, 63, 2064, 12, 9700, 63, 2064, 275, 620, 63, 1955, 14, 1294, 7563, 267, 340, 6107, 63, 1712, 365, 440, 488, 26, 288, 9700, 63, 2064, 275, 9700, 63, 2064, 1491, 6355, 63, 1712, 61, 272, 587, 26, 267, 1109, 63, 2064, 12, 9700, 63, 2064, 275, 620, 63, 1955, 12, 2125, 272, 340, 6107, 63, 1712, 365, 440, 488, 26, 267, 9700, 63, 2064, 275, 9700, 63, 2064, 435, 661, 16, 7, 627, 334, 6355, 63, 1712, 446, 822, 8, 7778, 63, 2064, 1724, 272, 340, 9700, 63, 2064, 26, 267, 9700, 63, 2064, 275, 6107, 63, 4127, 435, 9700, 63, 2064, 272, 327, 17786, 272, 340, 675, 63, 22390, 26, 267, 1109, 63, 2064, 63, 7136, 275, 2125, 267, 367, 12703, 12, 10964, 315, 3874, 8, 442, 63, 2064, 14172, 17, 4682, 288, 340, 12703, 436, 440, 12703, 450, 17786, 26, 355, 1109, 63, 2064, 63, 7136, 847, 294, 1785, 460, 63, 4127, 14172, 17, 61, 288, 1109, 63, 2064, 63, 7136, 847, 10964, 267, 1109, 63, 2064, 275, 1109, 63, 2064, 63, 7136, 14172, 17, 61, 272, 372, 2070, 435, 1109, 63, 2064, 435, 9700, 63, 2064, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
shannara/subuser
logic/subuserlib/builtInCommands/version.py
2
1274
#!/usr/bin/python3 # -*- coding: utf-8 -*- #external imports import json import sys import optparse #internal imports import subuserlib.version import subuserlib.commandLineArguments import subuserlib.profile from subuserlib.classes.user import User def parseCliArgs(realArgs): usage = "usage: subuser version" description = """Prints subuser's version and other usefull debugging info. """ parser = optparse.OptionParser(usage=usage,description=description,formatter=subuserlib.commandLineArguments.HelpFormatterThatDoesntReformatDescription()) parser.add_option("--json",dest="json",action="store_true",default=False,help="Display results in JSON format.") return parser.parse_args(args=realArgs) @subuserlib.profile.do_cprofile def runCommand(realArgs): """ >>> import version #import self >>> version.runCommand([]) Subuser version: 0.5 Docker info: Foo: bar """ user = User() (options,args) = parseCliArgs(realArgs) if options.json: print(json.dumps(subuserlib.version.getInfo(user),indent=1,separators=(",",": "))) else: print("Subuser version: " + subuserlib.version.getSubuserVersion(user)) print("Docker info:") for key,value in subuserlib.version.getDockerInfo(user).items(): print(" "+key+": "+str(value))
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 5159, 8925, 199, 646, 2022, 199, 646, 984, 199, 646, 8691, 199, 3, 4672, 8925, 199, 646, 1007, 751, 773, 14, 1023, 199, 646, 1007, 751, 773, 14, 1531, 3049, 14517, 199, 646, 1007, 751, 773, 14, 2913, 199, 504, 1007, 751, 773, 14, 2888, 14, 751, 492, 2876, 199, 199, 318, 2198, 20653, 6213, 8, 3093, 6213, 304, 523, 4503, 275, 298, 3807, 26, 1007, 751, 1015, 2, 523, 1369, 275, 408, 26113, 1007, 751, 1159, 1015, 436, 1163, 675, 2861, 10201, 2256, 14, 199, 624, 523, 1798, 275, 8691, 14, 14553, 8, 3807, 29, 3807, 12, 1802, 29, 1802, 12, 8911, 29, 954, 751, 773, 14, 1531, 3049, 14517, 14, 22779, 17231, 6586, 343, 497, 908, 5831, 1012, 523, 1798, 14, 525, 63, 1422, 6739, 1001, 401, 2614, 628, 1001, 401, 1287, 628, 1617, 63, 2052, 401, 885, 29, 797, 12, 3437, 628, 7687, 2058, 315, 4840, 1475, 2685, 523, 372, 1798, 14, 1122, 63, 589, 8, 589, 29, 3093, 6213, 9, 199, 199, 32, 954, 751, 773, 14, 2913, 14, 1117, 63, 67, 2913, 199, 318, 1255, 3110, 8, 3093, 6213, 304, 523, 408, 523, 1306, 492, 1015, 327, 646, 291, 523, 1306, 1015, 14, 1065, 3110, 4157, 523, 4804, 751, 1015, 26, 378, 14, 21, 523, 22067, 2256, 26, 2043, 8024, 26, 4681, 523, 408, 523, 922, 275, 2876, 342, 523, 334, 1419, 12, 589, 9, 275, 2198, 20653, 6213, 8, 3093, 6213, 9, 523, 340, 1511, 14, 1001, 26, 272, 870, 8, 1001, 14, 4180, 8, 954, 751, 773, 14, 1023, 14, 362, 2354, 8, 751, 395, 3724, 29, 17, 12, 29862, 2687, 401, 401, 582, 298, 1724, 523, 587, 26, 272, 870, 480, 2610, 751, 1015, 26, 298, 435, 1007, 751, 773, 14, 1023, 14, 362, 2610, 751, 3353, 8, 751, 430, 272, 870, 480, 31463, 2256, 9107, 272, 367, 790, 12, 585, 315, 1007, 751, 773, 14, 1023, 14, 362, 31463, 2354, 8, 751, 680, 1744, 837, 489, 870, 480, 7210, 498, 11, 582, 7210, 495, 8, 585, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 19, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 5159, 8925, 199, 646, 2022, 199, 646, 984, 199, 646, 8691, 199, 3, 4672, 8925, 199, 646, 1007, 751, 773, 14, 1023, 199, 646, 1007, 751, 773, 14, 1531, 3049, 14517, 199, 646, 1007, 751, 773, 14, 2913, 199, 504, 1007, 751, 773, 14, 2888, 14, 751, 492, 2876, 199, 199, 318, 2198, 20653, 6213, 8, 3093, 6213, 304, 523, 4503, 275, 298, 3807, 26, 1007, 751, 1015, 2, 523, 1369, 275, 408, 26113, 1007, 751, 1159, 1015, 436, 1163, 675, 2861, 10201, 2256, 14, 199, 624, 523, 1798, 275, 8691, 14, 14553, 8, 3807, 29, 3807, 12, 1802, 29, 1802, 12, 8911, 29, 954, 751, 773, 14, 1531, 3049, 14517, 14, 22779, 17231, 6586, 343, 497, 908, 5831, 1012, 523, 1798, 14, 525, 63, 1422, 6739, 1001, 401, 2614, 628, 1001, 401, 1287, 628, 1617, 63, 2052, 401, 885, 29, 797, 12, 3437, 628, 7687, 2058, 315, 4840, 1475, 2685, 523, 372, 1798, 14, 1122, 63, 589, 8, 589, 29, 3093, 6213, 9, 199, 199, 32, 954, 751, 773, 14, 2913, 14, 1117, 63, 67, 2913, 199, 318, 1255, 3110, 8, 3093, 6213, 304, 523, 408, 523, 1306, 492, 1015, 327, 646, 291, 523, 1306, 1015, 14, 1065, 3110, 4157, 523, 4804, 751, 1015, 26, 378, 14, 21, 523, 22067, 2256, 26, 2043, 8024, 26, 4681, 523, 408, 523, 922, 275, 2876, 342, 523, 334, 1419, 12, 589, 9, 275, 2198, 20653, 6213, 8, 3093, 6213, 9, 523, 340, 1511, 14, 1001, 26, 272, 870, 8, 1001, 14, 4180, 8, 954, 751, 773, 14, 1023, 14, 362, 2354, 8, 751, 395, 3724, 29, 17, 12, 29862, 2687, 401, 401, 582, 298, 1724, 523, 587, 26, 272, 870, 480, 2610, 751, 1015, 26, 298, 435, 1007, 751, 773, 14, 1023, 14, 362, 2610, 751, 3353, 8, 751, 430, 272, 870, 480, 31463, 2256, 9107, 272, 367, 790, 12, 585, 315, 1007, 751, 773, 14, 1023, 14, 362, 31463, 2354, 8, 751, 680, 1744, 837, 489, 870, 480, 7210, 498, 11, 582, 7210, 495, 8, 585, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
Shelnutt2/android_kernel_lge_f180k
scripts/gcc-wrapper.py
501
3410
#! /usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Code Aurora nor # the names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NON-INFRINGEMENT 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. # Invoke gcc, looking for warnings, and causing a failure if there are # non-whitelisted warnings. import errno import re import os import sys import subprocess # Note that gcc uses unicode, which may depend on the locale. TODO: # force LANG to be set to en_US.UTF-8 to get consistent warnings. allowed_warnings = set([ "alignment.c:327", "mmu.c:602", "return_address.c:62", ]) # Capture the name of the object file, can find it. ofile = None warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''') def interpret_warning(line): """Decode the message from gcc. The messages we care about have a filename, and a warning""" line = line.rstrip('\n') m = warning_re.match(line) if m and m.group(2) not in allowed_warnings: print "error, forbidden warning:", m.group(2) # If there is a warning, remove any object if it exists. if ofile: try: os.remove(ofile) except OSError: pass sys.exit(1) def run_gcc(): args = sys.argv[1:] # Look for -o try: i = args.index('-o') global ofile ofile = args[i+1] except (ValueError, IndexError): pass compiler = sys.argv[0] try: proc = subprocess.Popen(args, stderr=subprocess.PIPE) for line in proc.stderr: print line, interpret_warning(line) result = proc.wait() except OSError as e: result = e.errno if result == errno.ENOENT: print args[0] + ':',e.strerror print 'Is your PATH set correctly?' else: print ' '.join(args), str(e) return result if __name__ == '__main__': status = run_gcc() sys.exit(status)
gpl-2.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 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, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2004, 275, 1255, 63, 13112, 342, 272, 984, 14, 2224, 8, 1205, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 334, 67, 9, 7760, 13, 7409, 12, 5495, 437, 300, 11131, 2104, 453, 14, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 199, 3, 755, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 199, 3, 755, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 5495, 437, 300, 11131, 6590, 199, 3, 755, 314, 1561, 402, 2399, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 199, 3, 755, 7585, 7131, 687, 642, 2032, 1928, 2488, 6791, 5313, 199, 3, 755, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 199, 3, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 199, 3, 5292, 2990, 1634, 3169, 12, 3092, 2381, 437, 3115, 3104, 2401, 199, 3, 11214, 13, 12799, 9315, 9706, 14, 221, 1621, 4825, 6461, 7000, 2334, 5877, 11489, 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, 9206, 27, 199, 3, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 199, 3, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 199, 3, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 1634, 5749, 4141, 12, 9704, 8036, 199, 3, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 3, 31049, 19443, 12, 10023, 367, 3598, 12, 436, 25498, 282, 5988, 340, 2337, 787, 199, 3, 2222, 13, 7510, 15023, 3598, 14, 199, 199, 646, 7554, 199, 646, 295, 199, 646, 747, 199, 646, 984, 199, 646, 3873, 199, 199, 3, 3390, 626, 19443, 4440, 2649, 12, 1314, 1443, 11687, 641, 314, 5867, 14, 221, 3254, 26, 199, 3, 3542, 25029, 370, 506, 663, 370, 655, 63, 1668, 14, 6610, 13, 24, 370, 664, 12137, 3598, 14, 199, 199, 6541, 63, 5451, 275, 663, 779, 272, 298, 13699, 14, 67, 26, 11754, 401, 272, 298, 596, 85, 14, 67, 26, 28384, 401, 272, 298, 1107, 63, 1562, 14, 67, 26, 2789, 401, 199, 4794, 199, 199, 3, 29828, 314, 536, 402, 314, 909, 570, 12, 883, 2342, 652, 14, 199, 79, 493, 275, 488, 199, 199, 3764, 63, 264, 275, 295, 14, 2014, 8, 82, 2344, 19276, 15, 92, 9, 7059, 15251, 27658, 65, 13, 90, 2807, 3427, 68, 11, 304, 2961, 68, 11, 26, 5547, 5721, 26, 12310, 199, 318, 15579, 63, 3764, 8, 604, 304, 272, 408, 9400, 314, 1245, 687, 19443, 14, 221, 710, 3788, 781, 10296, 3595, 1172, 282, 1788, 12, 436, 282, 5721, 624, 272, 1004, 275, 1004, 14, 6735, 2258, 78, 358, 272, 333, 275, 5721, 63, 264, 14, 1431, 8, 604, 9, 272, 340, 333, 436, 333, 14, 923, 8, 18, 9, 440, 315, 4370, 63, 5451, 26, 267, 870, 298, 705, 12, 24786, 5721, 6783, 333, 14, 923, 8, 18, 9, 398, 327, 982, 2337, 365, 282, 5721, 12, 2813, 1263, 909, 340, 652, 3495, 14, 267, 340, 312, 493, 26, 288, 862, 26, 355, 747, 14, 2168, 8, 79, 493, 9, 288, 871, 6440, 26, 355, 986, 267, 984, 14, 2224, 8, 17, 9, 199, 199, 318, 1255, 63, 13112, 837, 272, 1249, 275, 984, 14, 3020, 59, 17, 2938, 272, 327, 12077, 367, 446, 79, 272, 862, 26, 267, 284, 275, 1249, 14, 1080, 3654, 79, 358, 267, 2288, 312, 493, 267, 312, 493, 275, 1249, 59, 73, 11, 17, 61, 272, 871, 334, 3393, 12, 7888, 304, 267, 986, 339, 6365, 275, 984, 14, 3020, 59, 16, 61, 339, 862, 26, 267, 6499, 275, 3873, 14, 7942, 8, 589, 12, 4635, 29, 5781, 14, 6089, 9, 267, 367, 1004, 315, 6499, 14, 3083, 26, 288, 870, 1004, 12, 288, 15579, 63, 3764, 8, 604, 9, 398, 754, 275, 6499, 14, 2573, 342, 272, 871, 6440, 465, 325, 26, 267, 754, 275, 325, 14, 7931, 267, 340, 754, 508, 7554, 14, 20465, 26, 288, 870, 1249, 59, 16, 61, 435, 25475, 69, 14, 20395, 288, 870, 283, 1831, 2195, 15097, 663, 6657, 14069, 267, 587, 26, 288, 870, 283, 1987, 904, 8, 589, 395, 620, 8, 69, 9, 339, 372, 754, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2004, 275, 1255, 63, 13112, 342, 272, 984, 14, 2224, 8, 1205, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
djurodrljaca/salamander-alm
server/rest_api/usermanagement/__init__.py
1
1336
""" Salamander ALM Copyright (c) 2016 Djuro Drljaca This Python module is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This Python module 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 Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. """ from rest_api.application import api from rest_api.usermanagement import login, logout, user def _create_url(relative_url: str) -> str: """ Creates a full URL from a relative URL :param relative_url: Relative part of the URL :return: Full URL Example: - Relative URL: "login" - Returned URL: "/api/usermanagement/login" """ return "/api/usermanagement/" + relative_url if api is not None: # Add all resources from this package api.add_resource(login.Login, _create_url("login")) api.add_resource(logout.Logout, _create_url("logout")) api.add_resource(user.User, _create_url("user"))
gpl-2.0
[ 624, 199, 27177, 455, 11438, 12112, 45, 199, 7384, 334, 67, 9, 7800, 221, 577, 74, 9129, 577, 4308, 9299, 65, 199, 199, 2765, 2018, 859, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 199, 17732, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3761, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2018, 859, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 199, 7395, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 543, 642, 3555, 14, 982, 199, 1397, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 504, 4618, 63, 1246, 14, 3578, 492, 2986, 199, 504, 4618, 63, 1246, 14, 751, 8110, 492, 4676, 12, 22079, 12, 922, 421, 199, 318, 485, 981, 63, 633, 8, 6188, 63, 633, 26, 620, 9, 1035, 620, 26, 272, 408, 272, 10560, 282, 2615, 2851, 687, 282, 3847, 2851, 339, 520, 635, 3847, 63, 633, 26, 259, 22419, 1777, 402, 314, 2851, 339, 520, 1107, 26, 259, 16579, 2851, 339, 5679, 26, 272, 446, 22419, 2851, 26, 298, 2886, 2, 272, 446, 19907, 2851, 26, 3286, 1246, 15, 751, 8110, 15, 2886, 2, 272, 408, 272, 372, 3286, 1246, 15, 751, 8110, 6687, 435, 3847, 63, 633, 421, 199, 692, 2986, 365, 440, 488, 26, 272, 327, 2654, 1006, 5944, 687, 642, 2559, 272, 2986, 14, 525, 63, 1927, 8, 2886, 14, 8880, 12, 485, 981, 63, 633, 480, 2886, 2237, 272, 2986, 14, 525, 63, 1927, 8, 11646, 14, 2445, 548, 12, 485, 981, 63, 633, 480, 11646, 2237, 272, 2986, 14, 525, 63, 1927, 8, 751, 14, 1899, 12, 485, 981, 63, 633, 480, 751, 2237, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 27177, 455, 11438, 12112, 45, 199, 7384, 334, 67, 9, 7800, 221, 577, 74, 9129, 577, 4308, 9299, 65, 199, 199, 2765, 2018, 859, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 1334, 314, 2895, 402, 314, 199, 17732, 1696, 1684, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3761, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 2765, 2018, 859, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 199, 7395, 2755, 314, 2478, 3750, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 5556, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 543, 642, 3555, 14, 982, 199, 1397, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 624, 199, 199, 504, 4618, 63, 1246, 14, 3578, 492, 2986, 199, 504, 4618, 63, 1246, 14, 751, 8110, 492, 4676, 12, 22079, 12, 922, 421, 199, 318, 485, 981, 63, 633, 8, 6188, 63, 633, 26, 620, 9, 1035, 620, 26, 272, 408, 272, 10560, 282, 2615, 2851, 687, 282, 3847, 2851, 339, 520, 635, 3847, 63, 633, 26, 259, 22419, 1777, 402, 314, 2851, 339, 520, 1107, 26, 259, 16579, 2851, 339, 5679, 26, 272, 446, 22419, 2851, 26, 298, 2886, 2, 272, 446, 19907, 2851, 26, 3286, 1246, 15, 751, 8110, 15, 2886, 2, 272, 408, 272, 372, 3286, 1246, 15, 751, 8110, 6687, 435, 3847, 63, 633, 421, 199, 692, 2986, 365, 440, 488, 26, 272, 327, 2654, 1006, 5944, 687, 642, 2559, 272, 2986, 14, 525, 63, 1927, 8, 2886, 14, 8880, 12, 485, 981, 63, 633, 480, 2886, 2237, 272, 2986, 14, 525, 63, 1927, 8, 11646, 14, 2445, 548, 12, 485, 981, 63, 633, 480, 11646, 2237, 272, 2986, 14, 525, 63, 1927, 8, 751, 14, 1899, 12, 485, 981, 63, 633, 480, 751, 2237, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
penelopy/luigi
test/contrib/spark_test.py
43
11040
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # 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 helpers import unittest import os import luigi import luigi.contrib.hdfs from luigi import six from luigi.mock import MockTarget from helpers import with_config from luigi.contrib.spark import SparkJobError, SparkSubmitTask, PySparkTask, PySpark1xJob, Spark1xJob, SparkJob from mock import patch, MagicMock BytesIO = six.BytesIO def poll_generator(): yield None yield 1 def setup_run_process(proc): poll_gen = poll_generator() proc.return_value.poll = lambda: next(poll_gen) proc.return_value.returncode = 0 proc.return_value.stdout = BytesIO() proc.return_value.stderr = BytesIO() class TestSparkSubmitTask(SparkSubmitTask): deploy_mode = "client" name = "AppName" entry_class = "org.test.MyClass" jars = ["jars/my.jar"] py_files = ["file1.py", "file2.py"] files = ["file1", "file2"] conf = {"Prop": "Value"} properties_file = "conf/spark-defaults.conf" driver_memory = "4G" driver_java_options = "-Xopt" driver_library_path = "library/path" driver_class_path = "class/path" executor_memory = "8G" driver_cores = 8 supervise = True total_executor_cores = 150 executor_cores = 10 queue = "queue" num_executors = 2 archives = ["archive1", "archive2"] app = "file" def app_options(self): return ["arg1", "arg2"] def output(self): return luigi.LocalTarget('output') class TestDefaultSparkSubmitTask(SparkSubmitTask): app = 'test.py' def output(self): return luigi.LocalTarget('output') class TestPySparkTask(PySparkTask): def input(self): return MockTarget('input') def output(self): return MockTarget('output') def main(self, sc, *args): sc.textFile(self.input().path).saveAsTextFile(self.output().path) class HdfsJob(luigi.ExternalTask): def output(self): return luigi.contrib.hdfs.HdfsTarget('test') class TestSparkJob(SparkJob): spark_workers = '2' spark_master_memory = '1g' spark_worker_memory = '1g' def requires_hadoop(self): return HdfsJob() def jar(self): return 'jar' def job_class(self): return 'job_class' def output(self): return luigi.LocalTarget('output') class TestSpark1xJob(Spark1xJob): def jar(self): return 'jar' def job_class(self): return 'job_class' def output(self): return luigi.LocalTarget('output') class TestPySpark1xJob(PySpark1xJob): def program(self): return 'python_file' def output(self): return luigi.LocalTarget('output') class SparkSubmitTaskTest(unittest.TestCase): ss = 'ss-stub' @with_config({'spark': {'spark-submit': ss, 'master': "yarn-client", 'hadoop-conf-dir': 'path'}}) @patch('luigi.contrib.spark.subprocess.Popen') def test_run(self, proc): setup_run_process(proc) job = TestSparkSubmitTask() job.run() self.assertEqual(proc.call_args[0][0], ['ss-stub', '--master', 'yarn-client', '--deploy-mode', 'client', '--name', 'AppName', '--class', 'org.test.MyClass', '--jars', 'jars/my.jar', '--py-files', 'file1.py,file2.py', '--files', 'file1,file2', '--archives', 'archive1,archive2', '--conf', 'Prop=Value', '--properties-file', 'conf/spark-defaults.conf', '--driver-memory', '4G', '--driver-java-options', '-Xopt', '--driver-library-path', 'library/path', '--driver-class-path', 'class/path', '--executor-memory', '8G', '--driver-cores', '8', '--supervise', '--total-executor-cores', '150', '--executor-cores', '10', '--queue', 'queue', '--num-executors', '2', 'file', 'arg1', 'arg2']) @with_config({'spark': {'spark-submit': ss, 'master': 'spark://host:7077', 'conf': 'prop1=val1', 'jars': 'jar1.jar,jar2.jar', 'files': 'file1,file2', 'py-files': 'file1.py,file2.py', 'archives': 'archive1'}}) @patch('luigi.contrib.spark.subprocess.Popen') def test_defaults(self, proc): proc.return_value.returncode = 0 job = TestDefaultSparkSubmitTask() job.run() self.assertEqual(proc.call_args[0][0], ['ss-stub', '--master', 'spark://host:7077', '--jars', 'jar1.jar,jar2.jar', '--py-files', 'file1.py,file2.py', '--files', 'file1,file2', '--archives', 'archive1', '--conf', 'prop1=val1', 'test.py']) @patch('luigi.contrib.spark.tempfile.TemporaryFile') @patch('luigi.contrib.spark.subprocess.Popen') def test_handle_failed_job(self, proc, file): proc.return_value.returncode = 1 file.return_value = BytesIO(b'stderr') try: job = TestSparkSubmitTask() job.run() except SparkJobError as e: self.assertEqual(e.err, 'stderr') self.assertTrue('STDERR: stderr' in six.text_type(e)) else: self.fail("Should have thrown SparkJobError") @patch('luigi.contrib.spark.subprocess.Popen') def test_app_must_be_set(self, proc): with self.assertRaises(NotImplementedError): job = SparkSubmitTask() job.run() @patch('luigi.contrib.spark.subprocess.Popen') def test_app_interruption(self, proc): def interrupt(): raise KeyboardInterrupt() proc.return_value.wait = interrupt try: job = TestSparkSubmitTask() job.run() except KeyboardInterrupt: pass proc.return_value.kill.check_called() class PySparkTaskTest(unittest.TestCase): ss = 'ss-stub' @with_config({'spark': {'spark-submit': ss, 'master': "spark://host:7077"}}) @patch('luigi.contrib.spark.subprocess.Popen') def test_run(self, proc): setup_run_process(proc) job = TestPySparkTask() job.run() proc_arg_list = proc.call_args[0][0] self.assertEqual(proc_arg_list[0:7], ['ss-stub', '--master', 'spark://host:7077', '--deploy-mode', 'client', '--name', 'TestPySparkTask']) self.assertTrue(os.path.exists(proc_arg_list[7])) self.assertTrue(proc_arg_list[8].endswith('TestPySparkTask.pickle')) @with_config({'spark': {'py-packages': 'dummy_test_module'}}) @patch.dict('sys.modules', {'pyspark': MagicMock()}) @patch('pyspark.SparkContext') def test_pyspark_runner(self, spark_context): sc = spark_context.return_value.__enter__.return_value def mock_spark_submit(task): from luigi.contrib.pyspark_runner import PySparkRunner PySparkRunner(*task.app_command()[1:]).run() # Check py-package exists self.assertTrue(os.path.exists(sc.addPyFile.call_args[0][0])) with patch.object(SparkSubmitTask, 'run', mock_spark_submit): job = TestPySparkTask() job.run() sc.textFile.assert_called_with('input') sc.textFile.return_value.saveAsTextFile.assert_called_with('output') class SparkJobTest(unittest.TestCase): hcd = 'hcd-stub' ycd = 'ycd-stub' sj = 'sj-stub' sc = 'sc-sub' @with_config({'spark': {'hadoop-conf-dir': hcd, 'yarn-conf-dir': ycd, 'spark-jar': sj, 'spark-class': sc}}) @patch('luigi.contrib.spark.subprocess.Popen') @patch('luigi.contrib.hdfs.HdfsTarget') def test_run(self, target, proc): setup_run_process(proc) job = TestSparkJob() job.run() self.assertEqual(proc.call_args[0][0], [self.sc, 'org.apache.spark.deploy.yarn.Client', '--jar', job.jar(), '--class', job.job_class(), '--num-workers', '2', '--master-memory', '1g', '--worker-memory', '1g']) @with_config({'spark': {'hadoop-conf-dir': hcd, 'yarn-conf-dir': ycd, 'spark-jar': sj, 'spark-class': sc}}) @patch('luigi.contrib.spark.tempfile.TemporaryFile') @patch('luigi.contrib.spark.subprocess.Popen') def test_handle_failed_job(self, proc, file): proc.return_value.returncode = 1 file.return_value = BytesIO(b'stderr') try: job = TestSparkJob() job.run() except SparkJobError as e: self.assertEqual(e.err, 'stderr') self.assertTrue('STDERR: stderr' in six.text_type(e)) else: self.fail("Should have thrown SparkJobError") class Spark1xTest(unittest.TestCase): ss = 'ss-stub' @with_config({'spark': {'spark-submit': ss}}) @patch('luigi.contrib.spark.subprocess.Popen') def test_run(self, proc): setup_run_process(proc) job = TestSpark1xJob() job.run() self.assertEqual(proc.call_args[0][0], [self.ss, '--master', 'yarn-client', '--class', job.job_class(), job.jar()]) @with_config({'spark': {'spark-submit': ss}}) @patch('luigi.contrib.spark.tempfile.TemporaryFile') @patch('luigi.contrib.spark.subprocess.Popen') def test_handle_failed_job(self, proc, file): proc.return_value.returncode = 1 file.return_value = BytesIO(b'stderr') try: job = TestSpark1xJob() job.run() except SparkJobError as e: self.assertEqual(e.err, 'stderr') self.assertTrue('STDERR: stderr' in six.text_type(e)) else: self.fail("Should have thrown SparkJobError") class PySpark1xTest(unittest.TestCase): ss = 'ss-stub' @with_config({'spark': {'spark-submit': ss}}) @patch('luigi.contrib.spark.subprocess.Popen') def test_run(self, proc): setup_run_process(proc) job = TestPySpark1xJob() job.run() self.assertEqual(proc.call_args[0][0], [self.ss, '--master', 'yarn-client', job.program()]) @with_config({'spark': {'spark-submit': ss}}) @patch('luigi.contrib.spark.tempfile.TemporaryFile') @patch('luigi.contrib.spark.subprocess.Popen') def test_handle_failed_job(self, proc, file): proc.return_value.returncode = 1 file.return_value = BytesIO(b'stderr') try: job = TestPySpark1xJob() job.run() except SparkJobError as e: self.assertEqual(e.err, 'stderr') self.assertTrue('STDERR: stderr' in six.text_type(e)) else: self.fail("Should have thrown SparkJobError")
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6029, 13, 7806, 428, 555, 3338, 14840, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 10897, 492, 2882, 199, 646, 747, 199, 646, 19485, 199, 646, 19485, 14, 2828, 14, 19055, 199, 504, 19485, 492, 3816, 199, 504, 19485, 14, 1805, 492, 4420, 4277, 199, 504, 10897, 492, 543, 63, 888, 199, 504, 19485, 14, 2828, 14, 9852, 492, 13932, 6694, 547, 12, 13932, 17187, 4476, 12, 1611, 27110, 4476, 12, 1611, 27110, 17, 88, 6694, 12, 13932, 17, 88, 6694, 12, 13932, 6694, 199, 504, 1683, 492, 3371, 12, 10079, 199, 199, 15466, 275, 3816, 14, 15466, 421, 199, 318, 11271, 63, 4679, 837, 272, 1995, 488, 272, 1995, 413, 421, 199, 318, 3272, 63, 1065, 63, 1412, 8, 4687, 304, 272, 11271, 63, 2268, 275, 11271, 63, 4679, 342, 272, 6499, 14, 1107, 63, 585, 14, 6843, 275, 2400, 26, 2163, 8, 6843, 63, 2268, 9, 272, 6499, 14, 1107, 63, 585, 14, 9913, 275, 378, 272, 6499, 14, 1107, 63, 585, 14, 2703, 275, 11808, 342, 272, 6499, 14, 1107, 63, 585, 14, 3083, 275, 11808, 342, 421, 199, 533, 1379, 27110, 17187, 4476, 8, 27110, 17187, 4476, 304, 272, 12287, 63, 632, 275, 298, 1258, 2, 272, 536, 275, 298, 28258, 2, 272, 2397, 63, 533, 275, 298, 1308, 14, 396, 14, 5713, 2543, 2, 272, 1335, 4291, 275, 2097, 32262, 15, 1662, 14, 7338, 937, 272, 1134, 63, 1725, 275, 2097, 493, 17, 14, 647, 401, 298, 493, 18, 14, 647, 937, 272, 1584, 275, 2097, 493, 17, 401, 298, 493, 18, 937, 272, 3743, 275, 2420, 9955, 582, 298, 1110, 3570, 272, 4382, 63, 493, 275, 298, 2190, 15, 9852, 13, 4322, 14, 2190, 2, 272, 5253, 63, 4844, 275, 298, 20, 39, 2, 272, 5253, 63, 6138, 63, 1419, 275, 3905, 56, 2992, 2, 272, 5253, 63, 4342, 63, 515, 275, 298, 4342, 15, 515, 2, 272, 5253, 63, 533, 63, 515, 275, 298, 533, 15, 515, 2, 272, 13270, 63, 4844, 275, 298, 24, 39, 2, 272, 5253, 63, 4630, 275, 1695, 272, 1613, 433, 261, 275, 715, 272, 3141, 63, 13471, 63, 4630, 275, 14711, 272, 13270, 63, 4630, 275, 1616, 272, 4126, 275, 298, 1825, 2, 272, 1967, 63, 1628, 6622, 275, 499, 272, 25993, 275, 2097, 6404, 17, 401, 298, 6404, 18, 937, 272, 1145, 275, 298, 493, 2, 339, 347, 1145, 63, 1419, 8, 277, 304, 267, 372, 2097, 1273, 17, 401, 298, 1273, 18, 937, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2698, 27110, 17187, 4476, 8, 27110, 17187, 4476, 304, 272, 1145, 275, 283, 396, 14, 647, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2713, 27110, 4476, 8, 2713, 27110, 4476, 304, 339, 347, 1324, 8, 277, 304, 267, 372, 4420, 4277, 360, 1210, 358, 339, 347, 1072, 8, 277, 304, 267, 372, 4420, 4277, 360, 1199, 358, 339, 347, 2446, 8, 277, 12, 4061, 12, 627, 589, 304, 267, 4061, 14, 505, 1173, 8, 277, 14, 1210, 1252, 515, 680, 2117, 2822, 1872, 1173, 8, 277, 14, 1199, 1252, 515, 9, 421, 199, 533, 869, 10434, 6694, 8, 26795, 14, 11389, 4476, 304, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 2828, 14, 19055, 14, 40, 10434, 4277, 360, 396, 358, 421, 199, 533, 1379, 27110, 6694, 8, 27110, 6694, 304, 339, 15442, 63, 11009, 275, 283, 18, 7, 272, 15442, 63, 4133, 63, 4844, 275, 283, 17, 71, 7, 272, 15442, 63, 6599, 63, 4844, 275, 283, 17, 71, 7, 339, 347, 5074, 63, 15449, 8, 277, 304, 267, 372, 869, 10434, 6694, 342, 339, 347, 16290, 8, 277, 304, 267, 372, 283, 7338, 7, 339, 347, 3906, 63, 533, 8, 277, 304, 267, 372, 283, 2423, 63, 533, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 27110, 17, 88, 6694, 8, 27110, 17, 88, 6694, 304, 339, 347, 16290, 8, 277, 304, 267, 372, 283, 7338, 7, 339, 347, 3906, 63, 533, 8, 277, 304, 267, 372, 283, 2423, 63, 533, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2713, 27110, 17, 88, 6694, 8, 2713, 27110, 17, 88, 6694, 304, 339, 347, 2240, 8, 277, 304, 267, 372, 283, 1548, 63, 493, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 13932, 17187, 4476, 774, 8, 2796, 14, 1746, 304, 272, 10110, 275, 283, 385, 13, 5811, 7, 339, 768, 1045, 63, 888, 3252, 9852, 356, 791, 9852, 13, 7275, 356, 10110, 12, 283, 4133, 356, 298, 89, 1060, 13, 1258, 401, 283, 15449, 13, 2190, 13, 694, 356, 283, 515, 936, 1552, 272, 768, 2068, 360, 26795, 14, 2828, 14, 9852, 14, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 8, 277, 12, 6499, 304, 267, 3272, 63, 1065, 63, 1412, 8, 4687, 9, 267, 3906, 275, 1379, 27110, 17187, 4476, 342, 267, 3906, 14, 1065, 342, 398, 291, 14, 629, 8, 4687, 14, 1250, 63, 589, 59, 16, 1527, 16, 467, 586, 788, 385, 13, 5811, 297, 2850, 4133, 297, 283, 89 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 6029, 13, 7806, 428, 555, 3338, 14840, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 504, 10897, 492, 2882, 199, 646, 747, 199, 646, 19485, 199, 646, 19485, 14, 2828, 14, 19055, 199, 504, 19485, 492, 3816, 199, 504, 19485, 14, 1805, 492, 4420, 4277, 199, 504, 10897, 492, 543, 63, 888, 199, 504, 19485, 14, 2828, 14, 9852, 492, 13932, 6694, 547, 12, 13932, 17187, 4476, 12, 1611, 27110, 4476, 12, 1611, 27110, 17, 88, 6694, 12, 13932, 17, 88, 6694, 12, 13932, 6694, 199, 504, 1683, 492, 3371, 12, 10079, 199, 199, 15466, 275, 3816, 14, 15466, 421, 199, 318, 11271, 63, 4679, 837, 272, 1995, 488, 272, 1995, 413, 421, 199, 318, 3272, 63, 1065, 63, 1412, 8, 4687, 304, 272, 11271, 63, 2268, 275, 11271, 63, 4679, 342, 272, 6499, 14, 1107, 63, 585, 14, 6843, 275, 2400, 26, 2163, 8, 6843, 63, 2268, 9, 272, 6499, 14, 1107, 63, 585, 14, 9913, 275, 378, 272, 6499, 14, 1107, 63, 585, 14, 2703, 275, 11808, 342, 272, 6499, 14, 1107, 63, 585, 14, 3083, 275, 11808, 342, 421, 199, 533, 1379, 27110, 17187, 4476, 8, 27110, 17187, 4476, 304, 272, 12287, 63, 632, 275, 298, 1258, 2, 272, 536, 275, 298, 28258, 2, 272, 2397, 63, 533, 275, 298, 1308, 14, 396, 14, 5713, 2543, 2, 272, 1335, 4291, 275, 2097, 32262, 15, 1662, 14, 7338, 937, 272, 1134, 63, 1725, 275, 2097, 493, 17, 14, 647, 401, 298, 493, 18, 14, 647, 937, 272, 1584, 275, 2097, 493, 17, 401, 298, 493, 18, 937, 272, 3743, 275, 2420, 9955, 582, 298, 1110, 3570, 272, 4382, 63, 493, 275, 298, 2190, 15, 9852, 13, 4322, 14, 2190, 2, 272, 5253, 63, 4844, 275, 298, 20, 39, 2, 272, 5253, 63, 6138, 63, 1419, 275, 3905, 56, 2992, 2, 272, 5253, 63, 4342, 63, 515, 275, 298, 4342, 15, 515, 2, 272, 5253, 63, 533, 63, 515, 275, 298, 533, 15, 515, 2, 272, 13270, 63, 4844, 275, 298, 24, 39, 2, 272, 5253, 63, 4630, 275, 1695, 272, 1613, 433, 261, 275, 715, 272, 3141, 63, 13471, 63, 4630, 275, 14711, 272, 13270, 63, 4630, 275, 1616, 272, 4126, 275, 298, 1825, 2, 272, 1967, 63, 1628, 6622, 275, 499, 272, 25993, 275, 2097, 6404, 17, 401, 298, 6404, 18, 937, 272, 1145, 275, 298, 493, 2, 339, 347, 1145, 63, 1419, 8, 277, 304, 267, 372, 2097, 1273, 17, 401, 298, 1273, 18, 937, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2698, 27110, 17187, 4476, 8, 27110, 17187, 4476, 304, 272, 1145, 275, 283, 396, 14, 647, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2713, 27110, 4476, 8, 2713, 27110, 4476, 304, 339, 347, 1324, 8, 277, 304, 267, 372, 4420, 4277, 360, 1210, 358, 339, 347, 1072, 8, 277, 304, 267, 372, 4420, 4277, 360, 1199, 358, 339, 347, 2446, 8, 277, 12, 4061, 12, 627, 589, 304, 267, 4061, 14, 505, 1173, 8, 277, 14, 1210, 1252, 515, 680, 2117, 2822, 1872, 1173, 8, 277, 14, 1199, 1252, 515, 9, 421, 199, 533, 869, 10434, 6694, 8, 26795, 14, 11389, 4476, 304, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 2828, 14, 19055, 14, 40, 10434, 4277, 360, 396, 358, 421, 199, 533, 1379, 27110, 6694, 8, 27110, 6694, 304, 339, 15442, 63, 11009, 275, 283, 18, 7, 272, 15442, 63, 4133, 63, 4844, 275, 283, 17, 71, 7, 272, 15442, 63, 6599, 63, 4844, 275, 283, 17, 71, 7, 339, 347, 5074, 63, 15449, 8, 277, 304, 267, 372, 869, 10434, 6694, 342, 339, 347, 16290, 8, 277, 304, 267, 372, 283, 7338, 7, 339, 347, 3906, 63, 533, 8, 277, 304, 267, 372, 283, 2423, 63, 533, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 27110, 17, 88, 6694, 8, 27110, 17, 88, 6694, 304, 339, 347, 16290, 8, 277, 304, 267, 372, 283, 7338, 7, 339, 347, 3906, 63, 533, 8, 277, 304, 267, 372, 283, 2423, 63, 533, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 1379, 2713, 27110, 17, 88, 6694, 8, 2713, 27110, 17, 88, 6694, 304, 339, 347, 2240, 8, 277, 304, 267, 372, 283, 1548, 63, 493, 7, 339, 347, 1072, 8, 277, 304, 267, 372, 19485, 14, 5339, 4277, 360, 1199, 358, 421, 199, 533, 13932, 17187, 4476, 774, 8, 2796, 14, 1746, 304, 272, 10110, 275, 283, 385, 13, 5811, 7, 339, 768, 1045, 63, 888, 3252, 9852, 356, 791, 9852, 13, 7275, 356, 10110, 12, 283, 4133, 356, 298, 89, 1060, 13, 1258, 401, 283, 15449, 13, 2190, 13, 694, 356, 283, 515, 936, 1552, 272, 768, 2068, 360, 26795, 14, 2828, 14, 9852, 14, 5781, 14, 7942, 358, 272, 347, 511, 63, 1065, 8, 277, 12, 6499, 304, 267, 3272, 63, 1065, 63, 1412, 8, 4687, 9, 267, 3906, 275, 1379, 27110, 17187, 4476, 342, 267, 3906, 14, 1065, 342, 398, 291, 14, 629, 8, 4687, 14, 1250, 63, 589, 59, 16, 1527, 16, 467, 586, 788, 385, 13, 5811, 297, 2850, 4133, 297, 283, 89, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bhargav2408/kivy
examples/canvas/circle.py
40
2154
''' Circle Example ============== This example exercises circle (ellipse) drawing. You should see sliders at the top of the screen with the Kivy logo below it. The sliders control the angle start and stop and the height and width scales. There is a button to reset the sliders. The logo used for the circle's background image is from the kivy/data directory. The entire example is coded in the kv language description. ''' from kivy.app import App from kivy.lang import Builder kv = ''' BoxLayout: orientation: 'vertical' BoxLayout: size_hint_y: None height: sp(100) BoxLayout: orientation: 'vertical' Slider: id: e1 min: -360. max: 360. Label: text: 'angle_start = {}'.format(e1.value) BoxLayout: orientation: 'vertical' Slider: id: e2 min: -360. max: 360. value: 360 Label: text: 'angle_end = {}'.format(e2.value) BoxLayout: size_hint_y: None height: sp(100) BoxLayout: orientation: 'vertical' Slider: id: wm min: 0 max: 2 value: 1 Label: text: 'Width mult. = {}'.format(wm.value) BoxLayout: orientation: 'vertical' Slider: id: hm min: 0 max: 2 value: 1 Label: text: 'Height mult. = {}'.format(hm.value) Button: text: 'Reset ratios' on_press: wm.value = 1; hm.value = 1 FloatLayout: canvas: Color: rgb: 1, 1, 1 Ellipse: pos: 100, 100 size: 200 * wm.value, 201 * hm.value source: 'data/logo/kivy-icon-512.png' angle_start: e1.value angle_end: e2.value ''' class CircleApp(App): def build(self): return Builder.load_string(kv) CircleApp().run()
mit
[ 2344, 199, 24587, 5679, 199, 17224, 199, 199, 2765, 2893, 444, 281, 559, 874, 17990, 334, 16514, 261, 9, 17455, 14, 2047, 1077, 1937, 27498, 7735, 737, 314, 199, 2119, 402, 314, 6426, 543, 314, 1804, 10241, 23623, 5084, 652, 14, 710, 27498, 7735, 3304, 314, 199, 4593, 1343, 436, 3631, 436, 314, 4569, 436, 3462, 29823, 14, 6006, 365, 282, 5528, 199, 475, 5305, 314, 27498, 7735, 14, 710, 23623, 1202, 367, 314, 17990, 1159, 8020, 1834, 365, 199, 504, 314, 17227, 15, 576, 2082, 14, 710, 8039, 2893, 365, 1233, 68, 315, 314, 199, 11475, 2637, 1369, 14, 199, 2344, 199, 199, 504, 17227, 14, 571, 492, 4693, 199, 504, 17227, 14, 4159, 492, 19286, 199, 199, 11475, 275, 1449, 199, 18536, 26, 272, 16774, 26, 283, 7870, 7, 272, 20783, 4798, 26, 267, 1568, 63, 6479, 63, 89, 26, 488, 267, 4569, 26, 2249, 8, 1960, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 325, 17, 355, 1748, 26, 446, 11197, 14, 355, 1390, 26, 19434, 14, 288, 10354, 26, 355, 1318, 26, 283, 4593, 63, 928, 275, 9499, 908, 8, 69, 17, 14, 585, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 325, 18, 355, 1748, 26, 446, 11197, 14, 355, 1390, 26, 19434, 14, 355, 574, 26, 19434, 288, 10354, 26, 355, 1318, 26, 283, 4593, 63, 500, 275, 9499, 908, 8, 69, 18, 14, 585, 9, 339, 20783, 4798, 26, 267, 1568, 63, 6479, 63, 89, 26, 488, 267, 4569, 26, 2249, 8, 1960, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 29835, 355, 1748, 26, 378, 355, 1390, 26, 499, 355, 574, 26, 413, 288, 10354, 26, 355, 1318, 26, 283, 6216, 20861, 14, 275, 9499, 908, 8, 16240, 14, 585, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 394, 77, 355, 1748, 26, 378, 355, 1390, 26, 499, 355, 574, 26, 413, 288, 10354, 26, 355, 1318, 26, 283, 8436, 20861, 14, 275, 9499, 908, 8, 14038, 14, 585, 9, 267, 16005, 26, 288, 1318, 26, 283, 9637, 660, 9636, 7, 288, 641, 63, 2915, 26, 29835, 14, 585, 275, 413, 27, 394, 77, 14, 585, 275, 413, 339, 11140, 4798, 26, 267, 10218, 26, 288, 11581, 26, 355, 15180, 26, 413, 12, 413, 12, 413, 288, 27761, 261, 26, 355, 2086, 26, 2948, 12, 2948, 355, 1568, 26, 1926, 627, 29835, 14, 585, 12, 1784, 627, 394, 77, 14, 585, 355, 1350, 26, 283, 576, 15, 9733, 15, 16941, 13, 4677, 13, 7736, 14, 4524, 7, 355, 9324, 63, 928, 26, 325, 17, 14, 585, 355, 9324, 63, 500, 26, 325, 18, 14, 585, 199, 199, 2344, 421, 199, 533, 445, 12571, 2640, 8, 2640, 304, 272, 347, 1900, 8, 277, 304, 267, 372, 19286, 14, 912, 63, 875, 8, 11475, 9, 199, 199, 24587, 2640, 1252, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 24587, 5679, 199, 17224, 199, 199, 2765, 2893, 444, 281, 559, 874, 17990, 334, 16514, 261, 9, 17455, 14, 2047, 1077, 1937, 27498, 7735, 737, 314, 199, 2119, 402, 314, 6426, 543, 314, 1804, 10241, 23623, 5084, 652, 14, 710, 27498, 7735, 3304, 314, 199, 4593, 1343, 436, 3631, 436, 314, 4569, 436, 3462, 29823, 14, 6006, 365, 282, 5528, 199, 475, 5305, 314, 27498, 7735, 14, 710, 23623, 1202, 367, 314, 17990, 1159, 8020, 1834, 365, 199, 504, 314, 17227, 15, 576, 2082, 14, 710, 8039, 2893, 365, 1233, 68, 315, 314, 199, 11475, 2637, 1369, 14, 199, 2344, 199, 199, 504, 17227, 14, 571, 492, 4693, 199, 504, 17227, 14, 4159, 492, 19286, 199, 199, 11475, 275, 1449, 199, 18536, 26, 272, 16774, 26, 283, 7870, 7, 272, 20783, 4798, 26, 267, 1568, 63, 6479, 63, 89, 26, 488, 267, 4569, 26, 2249, 8, 1960, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 325, 17, 355, 1748, 26, 446, 11197, 14, 355, 1390, 26, 19434, 14, 288, 10354, 26, 355, 1318, 26, 283, 4593, 63, 928, 275, 9499, 908, 8, 69, 17, 14, 585, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 325, 18, 355, 1748, 26, 446, 11197, 14, 355, 1390, 26, 19434, 14, 355, 574, 26, 19434, 288, 10354, 26, 355, 1318, 26, 283, 4593, 63, 500, 275, 9499, 908, 8, 69, 18, 14, 585, 9, 339, 20783, 4798, 26, 267, 1568, 63, 6479, 63, 89, 26, 488, 267, 4569, 26, 2249, 8, 1960, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 29835, 355, 1748, 26, 378, 355, 1390, 26, 499, 355, 574, 26, 413, 288, 10354, 26, 355, 1318, 26, 283, 6216, 20861, 14, 275, 9499, 908, 8, 16240, 14, 585, 9, 267, 20783, 4798, 26, 288, 16774, 26, 283, 7870, 7, 288, 428, 11306, 26, 355, 1305, 26, 394, 77, 355, 1748, 26, 378, 355, 1390, 26, 499, 355, 574, 26, 413, 288, 10354, 26, 355, 1318, 26, 283, 8436, 20861, 14, 275, 9499, 908, 8, 14038, 14, 585, 9, 267, 16005, 26, 288, 1318, 26, 283, 9637, 660, 9636, 7, 288, 641, 63, 2915, 26, 29835, 14, 585, 275, 413, 27, 394, 77, 14, 585, 275, 413, 339, 11140, 4798, 26, 267, 10218, 26, 288, 11581, 26, 355, 15180, 26, 413, 12, 413, 12, 413, 288, 27761, 261, 26, 355, 2086, 26, 2948, 12, 2948, 355, 1568, 26, 1926, 627, 29835, 14, 585, 12, 1784, 627, 394, 77, 14, 585, 355, 1350, 26, 283, 576, 15, 9733, 15, 16941, 13, 4677, 13, 7736, 14, 4524, 7, 355, 9324, 63, 928, 26, 325, 17, 14, 585, 355, 9324, 63, 500, 26, 325, 18, 14, 585, 199, 199, 2344, 421, 199, 533, 445, 12571, 2640, 8, 2640, 304, 272, 347, 1900, 8, 277, 304, 267, 372, 19286, 14, 912, 63, 875, 8, 11475, 9, 199, 199, 24587, 2640, 1252, 1065, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
MayOneUS/pledgeservice
testlib/bs4/tests/test_soup.py
272
17391
# -*- coding: utf-8 -*- """Tests of Beautiful Soup as a whole.""" import logging import unittest import sys import tempfile from bs4 import ( BeautifulSoup, BeautifulStoneSoup, ) from bs4.element import ( CharsetMetaAttributeValue, ContentMetaAttributeValue, SoupStrainer, NamespacedAttribute, ) import bs4.dammit from bs4.dammit import ( EntitySubstitution, UnicodeDammit, ) from bs4.testing import ( SoupTest, skipIf, ) import warnings try: from bs4.builder import LXMLTreeBuilder, LXMLTreeBuilderForXML LXML_PRESENT = True except ImportError, e: LXML_PRESENT = False PYTHON_2_PRE_2_7 = (sys.version_info < (2,7)) PYTHON_3_PRE_3_2 = (sys.version_info[0] == 3 and sys.version_info < (3,2)) class TestConstructor(SoupTest): def test_short_unicode_input(self): data = u"<h1>éé</h1>" soup = self.soup(data) self.assertEqual(u"éé", soup.h1.string) def test_embedded_null(self): data = u"<h1>foo\0bar</h1>" soup = self.soup(data) self.assertEqual(u"foo\0bar", soup.h1.string) class TestDeprecatedConstructorArguments(SoupTest): def test_parseOnlyThese_renamed_to_parse_only(self): with warnings.catch_warnings(record=True) as w: soup = self.soup("<a><b></b></a>", parseOnlyThese=SoupStrainer("b")) msg = str(w[0].message) self.assertTrue("parseOnlyThese" in msg) self.assertTrue("parse_only" in msg) self.assertEqual(b"<b></b>", soup.encode()) def test_fromEncoding_renamed_to_from_encoding(self): with warnings.catch_warnings(record=True) as w: utf8 = b"\xc3\xa9" soup = self.soup(utf8, fromEncoding="utf8") msg = str(w[0].message) self.assertTrue("fromEncoding" in msg) self.assertTrue("from_encoding" in msg) self.assertEqual("utf8", soup.original_encoding) def test_unrecognized_keyword_argument(self): self.assertRaises( TypeError, self.soup, "<a>", no_such_argument=True) class TestWarnings(SoupTest): def test_disk_file_warning(self): filehandle = tempfile.NamedTemporaryFile() filename = filehandle.name try: with warnings.catch_warnings(record=True) as w: soup = self.soup(filename) msg = str(w[0].message) self.assertTrue("looks like a filename" in msg) finally: filehandle.close() # The file no longer exists, so Beautiful Soup will no longer issue the warning. with warnings.catch_warnings(record=True) as w: soup = self.soup(filename) self.assertEqual(0, len(w)) def test_url_warning(self): with warnings.catch_warnings(record=True) as w: soup = self.soup("http://www.crummy.com/") msg = str(w[0].message) self.assertTrue("looks like a URL" in msg) with warnings.catch_warnings(record=True) as w: soup = self.soup("http://www.crummy.com/ is great") self.assertEqual(0, len(w)) class TestSelectiveParsing(SoupTest): def test_parse_with_soupstrainer(self): markup = "No<b>Yes</b><a>No<b>Yes <c>Yes</c></b>" strainer = SoupStrainer("b") soup = self.soup(markup, parse_only=strainer) self.assertEqual(soup.encode(), b"<b>Yes</b><b>Yes <c>Yes</c></b>") class TestEntitySubstitution(unittest.TestCase): """Standalone tests of the EntitySubstitution class.""" def setUp(self): self.sub = EntitySubstitution def test_simple_html_substitution(self): # Unicode characters corresponding to named HTML entites # are substituted, and no others. s = u"foo\u2200\N{SNOWMAN}\u00f5bar" self.assertEqual(self.sub.substitute_html(s), u"foo&forall;\N{SNOWMAN}&otilde;bar") def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # give them a special test. quotes = b"\x91\x92foo\x93\x94" dammit = UnicodeDammit(quotes) self.assertEqual(self.sub.substitute_html(dammit.markup), "&lsquo;&rsquo;foo&ldquo;&rdquo;") def test_xml_converstion_includes_no_quotes_if_make_quoted_attribute_is_false(self): s = 'Welcome to "my bar"' self.assertEqual(self.sub.substitute_xml(s, False), s) def test_xml_attribute_quoting_normally_uses_double_quotes(self): self.assertEqual(self.sub.substitute_xml("Welcome", True), '"Welcome"') self.assertEqual(self.sub.substitute_xml("Bob's Bar", True), '"Bob\'s Bar"') def test_xml_attribute_quoting_uses_single_quotes_when_value_contains_double_quotes(self): s = 'Welcome to "my bar"' self.assertEqual(self.sub.substitute_xml(s, True), "'Welcome to \"my bar\"'") def test_xml_attribute_quoting_escapes_single_quotes_when_value_contains_both_single_and_double_quotes(self): s = 'Welcome to "Bob\'s Bar"' self.assertEqual( self.sub.substitute_xml(s, True), '"Welcome to &quot;Bob\'s Bar&quot;"') def test_xml_quotes_arent_escaped_when_value_is_not_being_quoted(self): quoted = 'Welcome to "Bob\'s Bar"' self.assertEqual(self.sub.substitute_xml(quoted), quoted) def test_xml_quoting_handles_angle_brackets(self): self.assertEqual( self.sub.substitute_xml("foo<bar>"), "foo&lt;bar&gt;") def test_xml_quoting_handles_ampersands(self): self.assertEqual(self.sub.substitute_xml("AT&T"), "AT&amp;T") def test_xml_quoting_including_ampersands_when_they_are_part_of_an_entity(self): self.assertEqual( self.sub.substitute_xml("&Aacute;T&T"), "&amp;Aacute;T&amp;T") def test_xml_quoting_ignoring_ampersands_when_they_are_part_of_an_entity(self): self.assertEqual( self.sub.substitute_xml_containing_entities("&Aacute;T&T"), "&Aacute;T&amp;T") def test_quotes_not_html_substituted(self): """There's no need to do this except inside attribute values.""" text = 'Bob\'s "bar"' self.assertEqual(self.sub.substitute_html(text), text) class TestEncodingConversion(SoupTest): # Test Beautiful Soup's ability to decode and encode from various # encodings. def setUp(self): super(TestEncodingConversion, self).setUp() self.unicode_data = u'<html><head><meta charset="utf-8"/></head><body><foo>Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!</foo></body></html>' self.utf8_data = self.unicode_data.encode("utf-8") # Just so you know what it looks like. self.assertEqual( self.utf8_data, b'<html><head><meta charset="utf-8"/></head><body><foo>Sacr\xc3\xa9 bleu!</foo></body></html>') def test_ascii_in_unicode_out(self): # ASCII input is converted to Unicode. The original_encoding # attribute is set to 'utf-8', a superset of ASCII. chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None # Disable chardet, which will realize that the ASCII is ASCII. bs4.dammit.chardet_dammit = noop ascii = b"<foo>a</foo>" soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() self.assertTrue(isinstance(unicode_output, unicode)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet def test_unicode_in_unicode_out(self): # Unicode input is left alone. The original_encoding attribute # is not set. soup_from_unicode = self.soup(self.unicode_data) self.assertEqual(soup_from_unicode.decode(), self.unicode_data) self.assertEqual(soup_from_unicode.foo.string, u'Sacr\xe9 bleu!') self.assertEqual(soup_from_unicode.original_encoding, None) def test_utf8_in_unicode_out(self): # UTF-8 input is converted to Unicode. The original_encoding # attribute is set. soup_from_utf8 = self.soup(self.utf8_data) self.assertEqual(soup_from_utf8.decode(), self.unicode_data) self.assertEqual(soup_from_utf8.foo.string, u'Sacr\xe9 bleu!') def test_utf8_out(self): # The internal data structures can be encoded as UTF-8. soup_from_unicode = self.soup(self.unicode_data) self.assertEqual(soup_from_unicode.encode('utf-8'), self.utf8_data) @skipIf( PYTHON_2_PRE_2_7 or PYTHON_3_PRE_3_2, "Bad HTMLParser detected; skipping test of non-ASCII characters in attribute name.") def test_attribute_name_containing_unicode_characters(self): markup = u'<div><a \N{SNOWMAN}="snowman"></a></div>' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8")) class TestUnicodeDammit(unittest.TestCase): """Standalone tests of UnicodeDammit.""" def test_unicode_input(self): markup = u"I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup) def test_smart_quotes_to_unicode(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup) self.assertEqual( dammit.unicode_markup, u"<foo>\u2018\u2019\u201c\u201d</foo>") def test_smart_quotes_to_xml_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="xml") self.assertEqual( dammit.unicode_markup, "<foo>&#x2018;&#x2019;&#x201C;&#x201D;</foo>") def test_smart_quotes_to_html_entities(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="html") self.assertEqual( dammit.unicode_markup, "<foo>&lsquo;&rsquo;&ldquo;&rdquo;</foo>") def test_smart_quotes_to_ascii(self): markup = b"<foo>\x91\x92\x93\x94</foo>" dammit = UnicodeDammit(markup, smart_quotes_to="ascii") self.assertEqual( dammit.unicode_markup, """<foo>''""</foo>""") def test_detect_utf8(self): utf8 = b"\xc3\xa9" dammit = UnicodeDammit(utf8) self.assertEqual(dammit.unicode_markup, u'\xe9') self.assertEqual(dammit.original_encoding.lower(), 'utf-8') def test_convert_hebrew(self): hebrew = b"\xed\xe5\xec\xf9" dammit = UnicodeDammit(hebrew, ["iso-8859-8"]) self.assertEqual(dammit.original_encoding.lower(), 'iso-8859-8') self.assertEqual(dammit.unicode_markup, u'\u05dd\u05d5\u05dc\u05e9') def test_dont_see_smart_quotes_where_there_are_none(self): utf_8 = b"\343\202\261\343\203\274\343\202\277\343\202\244 Watch" dammit = UnicodeDammit(utf_8) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') self.assertEqual(dammit.unicode_markup.encode("utf-8"), utf_8) def test_ignore_inappropriate_codecs(self): utf8_data = u"Räksmörgås".encode("utf-8") dammit = UnicodeDammit(utf8_data, ["iso-8859-8"]) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') def test_ignore_invalid_codecs(self): utf8_data = u"Räksmörgås".encode("utf-8") for bad_encoding in ['.utf8', '...', 'utF---16.!']: dammit = UnicodeDammit(utf8_data, [bad_encoding]) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') def test_detect_html5_style_meta_tag(self): for data in ( b'<html><meta charset="euc-jp" /></html>', b"<html><meta charset='euc-jp' /></html>", b"<html><meta charset=euc-jp /></html>", b"<html><meta charset=euc-jp/></html>"): dammit = UnicodeDammit(data, is_html=True) self.assertEqual( "euc-jp", dammit.original_encoding) def test_last_ditch_entity_replacement(self): # This is a UTF-8 document that contains bytestrings # completely incompatible with UTF-8 (ie. encoded with some other # encoding). # # Since there is no consistent encoding for the document, # Unicode, Dammit will eventually encode the document as UTF-8 # and encode the incompatible characters as REPLACEMENT # CHARACTER. # # If chardet is installed, it will detect that the document # can be converted into ISO-8859-1 without errors. This happens # to be the wrong encoding, but it is a consistent encoding, so the # code we're testing here won't run. # # So we temporarily disable chardet if it's present. doc = b"""\357\273\277<?xml version="1.0" encoding="UTF-8"?> <html><b>\330\250\330\252\330\261</b> <i>\310\322\321\220\312\321\355\344</i></html>""" chardet = bs4.dammit.chardet_dammit logging.disable(logging.WARNING) try: def noop(str): return None bs4.dammit.chardet_dammit = noop dammit = UnicodeDammit(doc) self.assertEqual(True, dammit.contains_replacement_characters) self.assertTrue(u"\ufffd" in dammit.unicode_markup) soup = BeautifulSoup(doc, "html.parser") self.assertTrue(soup.contains_replacement_characters) finally: logging.disable(logging.NOTSET) bs4.dammit.chardet_dammit = chardet def test_byte_order_mark_removed(self): # A document written in UTF-16LE will have its byte order marker stripped. data = b'\xff\xfe<\x00a\x00>\x00\xe1\x00\xe9\x00<\x00/\x00a\x00>\x00' dammit = UnicodeDammit(data) self.assertEqual(u"<a>áé</a>", dammit.unicode_markup) self.assertEqual("utf-16le", dammit.original_encoding) def test_detwingle(self): # Here's a UTF8 document. utf8 = (u"\N{SNOWMAN}" * 3).encode("utf8") # Here's a Windows-1252 document. windows_1252 = ( u"\N{LEFT DOUBLE QUOTATION MARK}Hi, I like Windows!" u"\N{RIGHT DOUBLE QUOTATION MARK}").encode("windows_1252") # Through some unholy alchemy, they've been stuck together. doc = utf8 + windows_1252 + utf8 # The document can't be turned into UTF-8: self.assertRaises(UnicodeDecodeError, doc.decode, "utf8") # Unicode, Dammit thinks the whole document is Windows-1252, # and decodes it into "☃☃☃“Hi, I like Windows!”☃☃☃" # But if we run it through fix_embedded_windows_1252, it's fixed: fixed = UnicodeDammit.detwingle(doc) self.assertEqual( u"☃☃☃“Hi, I like Windows!”☃☃☃", fixed.decode("utf8")) def test_detwingle_ignores_multibyte_characters(self): # Each of these characters has a UTF-8 representation ending # in \x93. \x93 is a smart quote if interpreted as # Windows-1252. But our code knows to skip over multibyte # UTF-8 characters, so they'll survive the process unscathed. for tricky_unicode_char in ( u"\N{LATIN SMALL LIGATURE OE}", # 2-byte char '\xc5\x93' u"\N{LATIN SUBSCRIPT SMALL LETTER X}", # 3-byte char '\xe2\x82\x93' u"\xf0\x90\x90\x93", # This is a CJK character, not sure which one. ): input = tricky_unicode_char.encode("utf8") self.assertTrue(input.endswith(b'\x93')) output = UnicodeDammit.detwingle(input) self.assertEqual(output, input) class TestNamedspacedAttribute(SoupTest): def test_name_may_be_none(self): a = NamespacedAttribute("xmlns", None) self.assertEqual(a, "xmlns") def test_attribute_is_equivalent_to_colon_separated_string(self): a = NamespacedAttribute("a", "b") self.assertEqual("a:b", a) def test_attributes_are_equivalent_if_prefix_and_name_identical(self): a = NamespacedAttribute("a", "b", "c") b = NamespacedAttribute("a", "b", "c") self.assertEqual(a, b) # The actual namespace is not considered. c = NamespacedAttribute("a", "b", None) self.assertEqual(a, c) # But name and prefix are important. d = NamespacedAttribute("a", "z", "c") self.assertNotEqual(a, d) e = NamespacedAttribute("z", "b", "c") self.assertNotEqual(a, e) class TestAttributeValueWithCharsetSubstitution(unittest.TestCase): def test_content_meta_attribute_value(self): value = CharsetMetaAttributeValue("euc-jp") self.assertEqual("euc-jp", value) self.assertEqual("euc-jp", value.original_value) self.assertEqual("utf8", value.encode("utf8")) def test_content_meta_attribute_value(self): value = ContentMetaAttributeValue("text/html; charset=euc-jp") self.assertEqual("text/html; charset=euc-jp", value) self.assertEqual("text/html; charset=euc-jp", value.original_value) self.assertEqual("text/html; charset=utf8", value.encode("utf8"))
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2925, 402, 14562, 28028, 465, 282, 8852, 1041, 199, 199, 646, 2050, 199, 646, 2882, 199, 646, 984, 199, 646, 5549, 199, 199, 504, 9922, 20, 492, 334, 272, 17132, 12, 272, 14562, 933, 368, 12341, 12, 199, 9, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 29392, 3396, 4016, 12, 272, 6646, 3396, 4016, 12, 272, 28028, 933, 6322, 281, 12, 272, 19317, 68, 1646, 12, 272, 776, 199, 646, 9922, 20, 14, 68, 28980, 199, 504, 9922, 20, 14, 68, 28980, 492, 334, 272, 17680, 2610, 26575, 12, 272, 6140, 36, 28980, 12, 199, 9, 199, 504, 9922, 20, 14, 4776, 492, 334, 272, 28028, 774, 12, 272, 3372, 3917, 12, 199, 9, 199, 646, 3598, 199, 199, 893, 26, 272, 687, 9922, 20, 14, 5649, 492, 491, 4317, 20437, 12, 491, 4317, 20437, 1858, 4317, 272, 491, 4317, 63, 19743, 275, 715, 199, 2590, 3545, 12, 325, 26, 272, 491, 4317, 63, 19743, 275, 756, 199, 199, 11720, 63, 18, 63, 4225, 63, 18, 63, 23, 275, 334, 1274, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 430, 199, 11720, 63, 19, 63, 4225, 63, 19, 63, 18, 275, 334, 1274, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 436, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 18, 430, 199, 199, 533, 1379, 11447, 8, 12341, 774, 304, 339, 347, 511, 63, 3612, 63, 2975, 63, 1210, 8, 277, 304, 267, 666, 275, 399, 17030, 72, 17, 30, 5741, 5741, 1108, 72, 17, 4335, 267, 9108, 275, 291, 14, 9317, 8, 576, 9, 267, 291, 14, 629, 8, 85, 2, 5741, 5741, 401, 9108, 14, 72, 17, 14, 875, 9, 339, 347, 511, 63, 18757, 63, 2307, 8, 277, 304, 267, 666, 275, 399, 17030, 72, 17, 30, 1421, 60, 16, 1700, 1108, 72, 17, 4335, 267, 9108, 275, 291, 14, 9317, 8, 576, 9, 267, 291, 14, 629, 8, 85, 2, 1421, 60, 16, 1700, 401, 9108, 14, 72, 17, 14, 875, 9, 421, 199, 533, 1379, 19727, 11447, 14517, 8, 12341, 774, 304, 339, 347, 511, 63, 1122, 5903, 20676, 63, 29401, 63, 475, 63, 1122, 63, 2118, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 6757, 65, 2535, 66, 2957, 66, 2957, 65, 7166, 2198, 5903, 20676, 29, 12341, 933, 6322, 281, 480, 66, 2237, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 1122, 5903, 20676, 2, 315, 1499, 9, 267, 291, 14, 1815, 480, 1122, 63, 2118, 2, 315, 1499, 9, 267, 291, 14, 629, 8, 66, 17030, 66, 2957, 66, 7166, 9108, 14, 2143, 1012, 339, 347, 511, 63, 504, 7630, 63, 29401, 63, 475, 63, 504, 63, 2991, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 2774, 24, 275, 330, 3212, 1812, 19, 60, 1800, 25, 2, 288, 9108, 275, 291, 14, 9317, 8, 1624, 24, 12, 687, 7630, 628, 1624, 24, 531, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 504, 7630, 2, 315, 1499, 9, 267, 291, 14, 1815, 480, 504, 63, 2991, 2, 315, 1499, 9, 267, 291, 14, 629, 480, 1624, 24, 401, 9108, 14, 5043, 63, 2991, 9, 339, 347, 511, 63, 324, 13221, 63, 6691, 63, 2094, 8, 277, 304, 267, 291, 14, 1855, 8, 288, 3146, 12, 291, 14, 9317, 12, 3886, 65, 7166, 949, 63, 10180, 63, 2094, 29, 549, 9, 199, 199, 533, 1379, 15921, 8, 12341, 774, 304, 339, 347, 511, 63, 4032, 63, 493, 63, 3764, 8, 277, 304, 267, 570, 2479, 275, 5549, 14, 19320, 342, 267, 1788, 275, 570, 2479, 14, 354, 267, 862, 26, 288, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 355, 9108, 275, 291, 14, 9317, 8, 1501, 9, 288, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 288, 291, 14, 1815, 480, 11660, 83, 2839, 282, 1788, 2, 315, 1499, 9, 267, 3753, 26, 288, 570, 2479, 14, 1600, 342, 398, 327, 710, 570, 949, 8088, 3495, 12, 880, 14562, 28028, 911, 949, 8088, 4976, 314, 5721, 14, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 8, 1501, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 87, 430, 339, 347, 511, 63, 633, 63, 3764, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 480, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 13589, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 11660, 83, 2839, 282, 2851, 2, 315, 1499, 9, 398, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 480, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 365, 27254, 531, 267, 291, 14, 629, 8, 16, 12, 822, 8, 87, 430, 199, 199, 533, 1379, 1513, 25982, 17412, 8, 12341, 774, 304, 339, 347, 511, 63, 1122, 63, 1045, 63, 9317, 270, 6322, 281, 8, 277, 304, 267, 9189, 275, 298, 1944, 28, 66, 30, 12555, 1108, 66, 2535, 65, 30, 1944, 28, 66, 30, 12555, 665, 67, 30, 12555, 1108, 67, 2957, 66, 4335, 267, 410, 6322, 281, 275, 28028, 933, 6322, 281, 480, 66, 531, 267, 9108, 275, 291, 14, 9317, 8, 10131, 12, 2198, 63, 2118, 29, 270, 6322, 281, 9, 267, 291, 14, 629, 8, 9317, 14, 2143, 1062, 330, 17030, 66, 30, 12555, 1108, 66, 2535, 66, 30, 12555, 665, 67, 30, 12555, 1108, 67, 2957, 66, 9579, 421, 199, 533, 1379, 7302, 2610, 26575, 8, 2796, 14, 1746, 304, 272, 408, 18736, 10636, 2295, 402, 314, 17680, 2610, 26575, 1021, 1041, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 954, 275, 17680, 2610, 26575, 339, 347, 511, 63, 4129, 63, 1360 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 2925, 402, 14562, 28028, 465, 282, 8852, 1041, 199, 199, 646, 2050, 199, 646, 2882, 199, 646, 984, 199, 646, 5549, 199, 199, 504, 9922, 20, 492, 334, 272, 17132, 12, 272, 14562, 933, 368, 12341, 12, 199, 9, 199, 504, 9922, 20, 14, 2108, 492, 334, 272, 29392, 3396, 4016, 12, 272, 6646, 3396, 4016, 12, 272, 28028, 933, 6322, 281, 12, 272, 19317, 68, 1646, 12, 272, 776, 199, 646, 9922, 20, 14, 68, 28980, 199, 504, 9922, 20, 14, 68, 28980, 492, 334, 272, 17680, 2610, 26575, 12, 272, 6140, 36, 28980, 12, 199, 9, 199, 504, 9922, 20, 14, 4776, 492, 334, 272, 28028, 774, 12, 272, 3372, 3917, 12, 199, 9, 199, 646, 3598, 199, 199, 893, 26, 272, 687, 9922, 20, 14, 5649, 492, 491, 4317, 20437, 12, 491, 4317, 20437, 1858, 4317, 272, 491, 4317, 63, 19743, 275, 715, 199, 2590, 3545, 12, 325, 26, 272, 491, 4317, 63, 19743, 275, 756, 199, 199, 11720, 63, 18, 63, 4225, 63, 18, 63, 23, 275, 334, 1274, 14, 1023, 63, 815, 665, 334, 18, 12, 23, 430, 199, 11720, 63, 19, 63, 4225, 63, 19, 63, 18, 275, 334, 1274, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 436, 984, 14, 1023, 63, 815, 665, 334, 19, 12, 18, 430, 199, 199, 533, 1379, 11447, 8, 12341, 774, 304, 339, 347, 511, 63, 3612, 63, 2975, 63, 1210, 8, 277, 304, 267, 666, 275, 399, 17030, 72, 17, 30, 5741, 5741, 1108, 72, 17, 4335, 267, 9108, 275, 291, 14, 9317, 8, 576, 9, 267, 291, 14, 629, 8, 85, 2, 5741, 5741, 401, 9108, 14, 72, 17, 14, 875, 9, 339, 347, 511, 63, 18757, 63, 2307, 8, 277, 304, 267, 666, 275, 399, 17030, 72, 17, 30, 1421, 60, 16, 1700, 1108, 72, 17, 4335, 267, 9108, 275, 291, 14, 9317, 8, 576, 9, 267, 291, 14, 629, 8, 85, 2, 1421, 60, 16, 1700, 401, 9108, 14, 72, 17, 14, 875, 9, 421, 199, 533, 1379, 19727, 11447, 14517, 8, 12341, 774, 304, 339, 347, 511, 63, 1122, 5903, 20676, 63, 29401, 63, 475, 63, 1122, 63, 2118, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 6757, 65, 2535, 66, 2957, 66, 2957, 65, 7166, 2198, 5903, 20676, 29, 12341, 933, 6322, 281, 480, 66, 2237, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 1122, 5903, 20676, 2, 315, 1499, 9, 267, 291, 14, 1815, 480, 1122, 63, 2118, 2, 315, 1499, 9, 267, 291, 14, 629, 8, 66, 17030, 66, 2957, 66, 7166, 9108, 14, 2143, 1012, 339, 347, 511, 63, 504, 7630, 63, 29401, 63, 475, 63, 504, 63, 2991, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 2774, 24, 275, 330, 3212, 1812, 19, 60, 1800, 25, 2, 288, 9108, 275, 291, 14, 9317, 8, 1624, 24, 12, 687, 7630, 628, 1624, 24, 531, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 504, 7630, 2, 315, 1499, 9, 267, 291, 14, 1815, 480, 504, 63, 2991, 2, 315, 1499, 9, 267, 291, 14, 629, 480, 1624, 24, 401, 9108, 14, 5043, 63, 2991, 9, 339, 347, 511, 63, 324, 13221, 63, 6691, 63, 2094, 8, 277, 304, 267, 291, 14, 1855, 8, 288, 3146, 12, 291, 14, 9317, 12, 3886, 65, 7166, 949, 63, 10180, 63, 2094, 29, 549, 9, 199, 199, 533, 1379, 15921, 8, 12341, 774, 304, 339, 347, 511, 63, 4032, 63, 493, 63, 3764, 8, 277, 304, 267, 570, 2479, 275, 5549, 14, 19320, 342, 267, 1788, 275, 570, 2479, 14, 354, 267, 862, 26, 288, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 355, 9108, 275, 291, 14, 9317, 8, 1501, 9, 288, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 288, 291, 14, 1815, 480, 11660, 83, 2839, 282, 1788, 2, 315, 1499, 9, 267, 3753, 26, 288, 570, 2479, 14, 1600, 342, 398, 327, 710, 570, 949, 8088, 3495, 12, 880, 14562, 28028, 911, 949, 8088, 4976, 314, 5721, 14, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 8, 1501, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 87, 430, 339, 347, 511, 63, 633, 63, 3764, 8, 277, 304, 267, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 480, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 13589, 267, 1499, 275, 620, 8, 87, 59, 16, 1055, 1188, 9, 267, 291, 14, 1815, 480, 11660, 83, 2839, 282, 2851, 2, 315, 1499, 9, 398, 543, 3598, 14, 9341, 63, 5451, 8, 3059, 29, 549, 9, 465, 336, 26, 288, 9108, 275, 291, 14, 9317, 480, 1014, 921, 1544, 14, 1556, 3323, 14, 957, 15, 365, 27254, 531, 267, 291, 14, 629, 8, 16, 12, 822, 8, 87, 430, 199, 199, 533, 1379, 1513, 25982, 17412, 8, 12341, 774, 304, 339, 347, 511, 63, 1122, 63, 1045, 63, 9317, 270, 6322, 281, 8, 277, 304, 267, 9189, 275, 298, 1944, 28, 66, 30, 12555, 1108, 66, 2535, 65, 30, 1944, 28, 66, 30, 12555, 665, 67, 30, 12555, 1108, 67, 2957, 66, 4335, 267, 410, 6322, 281, 275, 28028, 933, 6322, 281, 480, 66, 531, 267, 9108, 275, 291, 14, 9317, 8, 10131, 12, 2198, 63, 2118, 29, 270, 6322, 281, 9, 267, 291, 14, 629, 8, 9317, 14, 2143, 1062, 330, 17030, 66, 30, 12555, 1108, 66, 2535, 66, 30, 12555, 665, 67, 30, 12555, 1108, 67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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
zestedesavoir/Python-ZMarkdown
setup.py
1
2587
#!/usr/bin/env python from __future__ import with_statement import os from distutils.core import setup import imp def get_version(): " Get version & version_info without importing markdown.__init__ " path = os.path.join(os.path.dirname(__file__), 'zmarkdown') fp, pathname, desc = imp.find_module('__version__', [path]) try: v = imp.load_module('__version__', fp, pathname, desc) return v.version, v.version_info finally: fp.close() version, version_info = get_version() # Get development Status for classifiers dev_status_map = { 'alpha': '3 - Alpha', 'beta': '4 - Beta', 'rc': '4 - Beta', 'final': '5 - Production/Stable', } if version_info[3] == 'alpha' and version_info[4] == 0: DEVSTATUS = '2 - Pre-Alpha' else: DEVSTATUS = dev_status_map[version_info[3]] long_description = ''' Small fork of Python-Markdown suitable for zestedesavoir.com needs ''' setup(name='Markdown', version=version, url='https://github.com/zestedesavoir/Python-ZMarkdown', description='Python implementation of Markdown.', long_description=long_description, author='Manfred Stienstra, Yuri takhteyev, Waylan limberg and zeste de savoir members', author_email='christophe.gabard [at] gmail.com', maintainer='Christophe Gabard', maintainer_email='christophe.gabard [at] gmail.com', license='BSD License', packages=['zmarkdown', 'zmarkdown.extensions'], classifiers=['Development Status :: %s' % DEVSTATUS, 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', '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', 'Topic :: Communications :: Email :: Filters', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries', 'Topic :: Internet :: WWW/HTTP :: Site Management', 'Topic :: Software Development :: Documentation', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Text Processing :: Filters', 'Topic :: Text Processing :: Markup :: HTML' ] )
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 646, 747, 199, 504, 7065, 14, 1018, 492, 3272, 199, 646, 1742, 421, 199, 318, 664, 63, 1023, 837, 272, 298, 2372, 1015, 1253, 1015, 63, 815, 1928, 16306, 18502, 855, 826, 363, 298, 272, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 90, 15653, 358, 272, 4090, 12, 11776, 12, 4328, 275, 1742, 14, 1623, 63, 578, 10714, 1023, 7500, 359, 515, 566, 272, 862, 26, 267, 373, 275, 1742, 14, 912, 63, 578, 10714, 1023, 7500, 4090, 12, 11776, 12, 4328, 9, 267, 372, 373, 14, 1023, 12, 373, 14, 1023, 63, 815, 272, 3753, 26, 267, 4090, 14, 1600, 342, 421, 199, 1023, 12, 1015, 63, 815, 275, 664, 63, 1023, 342, 199, 199, 3, 2372, 16367, 9795, 367, 19137, 199, 2374, 63, 1205, 63, 1130, 275, 469, 272, 283, 4468, 356, 283, 19, 446, 32657, 297, 272, 283, 5683, 356, 283, 20, 446, 29521, 297, 272, 283, 1195, 356, 283, 20, 446, 29521, 297, 272, 283, 5094, 356, 283, 21, 446, 24114, 15, 933, 461, 297, 199, 93, 199, 199, 692, 1015, 63, 815, 59, 19, 61, 508, 283, 4468, 7, 436, 1015, 63, 815, 59, 20, 61, 508, 378, 26, 272, 3265, 54, 6305, 275, 283, 18, 446, 5543, 13, 16192, 7, 199, 2836, 26, 272, 3265, 54, 6305, 275, 4866, 63, 1205, 63, 1130, 59, 1023, 63, 815, 59, 19, 2677, 199, 199, 2809, 63, 1802, 275, 1449, 199, 10712, 14926, 402, 2018, 13, 30916, 11233, 367, 1315, 397, 266, 3424, 1214, 19142, 14, 957, 4839, 199, 2344, 199, 199, 2758, 8, 354, 534, 30916, 297, 489, 1015, 29, 1023, 12, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 90, 397, 266, 3424, 1214, 19142, 15, 4718, 13, 58, 30916, 297, 489, 1369, 534, 4718, 4514, 402, 24537, 3130, 489, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 489, 4132, 534, 2395, 22980, 428, 280, 287, 14183, 12, 1488, 2302, 307, 1151, 72, 266, 89, 6857, 12, 644, 1187, 1502, 1212, 976, 71, 436, 1315, 397, 266, 477, 308, 1214, 19142, 7556, 297, 489, 4132, 63, 2123, 534, 335, 322, 2379, 426, 14, 71, 371, 1005, 359, 292, 61, 29712, 14, 957, 297, 489, 11075, 281, 534, 1049, 322, 2379, 426, 598, 371, 1005, 297, 489, 11075, 281, 63, 2123, 534, 335, 322, 2379, 426, 14, 71, 371, 1005, 359, 292, 61, 29712, 14, 957, 297, 489, 4190, 534, 15400, 844, 297, 489, 6117, 2968, 90, 15653, 297, 283, 90, 15653, 14, 5359, 995, 489, 19137, 2968, 23753, 9795, 3800, 450, 83, 7, 450, 3265, 54, 6305, 12, 673, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 673, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 673, 283, 11411, 8466, 3800, 2018, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 18, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 673, 283, 12157, 3800, 18686, 3800, 11426, 3800, 21240, 297, 673, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 21907, 6646, 3800, 28716, 23228, 15, 23624, 297, 673, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 11666, 8259, 297, 673, 283, 12157, 3800, 2290, 15290, 3800, 15249, 297, 673, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 673, 283, 12157, 3800, 4516, 20157, 3800, 21240, 297, 673, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4163, 7, 673, 1622, 489, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 504, 636, 2443, 363, 492, 543, 63, 6242, 199, 646, 747, 199, 504, 7065, 14, 1018, 492, 3272, 199, 646, 1742, 421, 199, 318, 664, 63, 1023, 837, 272, 298, 2372, 1015, 1253, 1015, 63, 815, 1928, 16306, 18502, 855, 826, 363, 298, 272, 931, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 3460, 493, 10139, 283, 90, 15653, 358, 272, 4090, 12, 11776, 12, 4328, 275, 1742, 14, 1623, 63, 578, 10714, 1023, 7500, 359, 515, 566, 272, 862, 26, 267, 373, 275, 1742, 14, 912, 63, 578, 10714, 1023, 7500, 4090, 12, 11776, 12, 4328, 9, 267, 372, 373, 14, 1023, 12, 373, 14, 1023, 63, 815, 272, 3753, 26, 267, 4090, 14, 1600, 342, 421, 199, 1023, 12, 1015, 63, 815, 275, 664, 63, 1023, 342, 199, 199, 3, 2372, 16367, 9795, 367, 19137, 199, 2374, 63, 1205, 63, 1130, 275, 469, 272, 283, 4468, 356, 283, 19, 446, 32657, 297, 272, 283, 5683, 356, 283, 20, 446, 29521, 297, 272, 283, 1195, 356, 283, 20, 446, 29521, 297, 272, 283, 5094, 356, 283, 21, 446, 24114, 15, 933, 461, 297, 199, 93, 199, 199, 692, 1015, 63, 815, 59, 19, 61, 508, 283, 4468, 7, 436, 1015, 63, 815, 59, 20, 61, 508, 378, 26, 272, 3265, 54, 6305, 275, 283, 18, 446, 5543, 13, 16192, 7, 199, 2836, 26, 272, 3265, 54, 6305, 275, 4866, 63, 1205, 63, 1130, 59, 1023, 63, 815, 59, 19, 2677, 199, 199, 2809, 63, 1802, 275, 1449, 199, 10712, 14926, 402, 2018, 13, 30916, 11233, 367, 1315, 397, 266, 3424, 1214, 19142, 14, 957, 4839, 199, 2344, 199, 199, 2758, 8, 354, 534, 30916, 297, 489, 1015, 29, 1023, 12, 489, 1166, 534, 2859, 921, 5031, 14, 957, 15, 90, 397, 266, 3424, 1214, 19142, 15, 4718, 13, 58, 30916, 297, 489, 1369, 534, 4718, 4514, 402, 24537, 3130, 489, 1846, 63, 1802, 29, 2809, 63, 1802, 12, 489, 4132, 534, 2395, 22980, 428, 280, 287, 14183, 12, 1488, 2302, 307, 1151, 72, 266, 89, 6857, 12, 644, 1187, 1502, 1212, 976, 71, 436, 1315, 397, 266, 477, 308, 1214, 19142, 7556, 297, 489, 4132, 63, 2123, 534, 335, 322, 2379, 426, 14, 71, 371, 1005, 359, 292, 61, 29712, 14, 957, 297, 489, 11075, 281, 534, 1049, 322, 2379, 426, 598, 371, 1005, 297, 489, 11075, 281, 63, 2123, 534, 335, 322, 2379, 426, 14, 71, 371, 1005, 359, 292, 61, 29712, 14, 957, 297, 489, 4190, 534, 15400, 844, 297, 489, 6117, 2968, 90, 15653, 297, 283, 90, 15653, 14, 5359, 995, 489, 19137, 2968, 23753, 9795, 3800, 450, 83, 7, 450, 3265, 54, 6305, 12, 673, 283, 3761, 3800, 25718, 26330, 3800, 6289, 844, 297, 673, 283, 23699, 6187, 3800, 4403, 1010, 7106, 297, 673, 283, 11411, 8466, 3800, 2018, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 499, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 499, 14, 23, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 18, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 19, 297, 673, 283, 11411, 8466, 3800, 2018, 3800, 650, 14, 20, 297, 673, 283, 12157, 3800, 18686, 3800, 11426, 3800, 21240, 297, 673, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 21907, 6646, 3800, 28716, 23228, 15, 23624, 297, 673, 283, 12157, 3800, 22026, 3800, 644, 11178, 15, 2856, 3800, 11666, 8259, 297, 673, 283, 12157, 3800, 2290, 15290, 3800, 15249, 297, 673, 283, 12157, 3800, 2290, 15290, 3800, 31454, 3800, 2018, 18167, 297, 673, 283, 12157, 3800, 4516, 20157, 3800, 21240, 297, 673, 283, 12157, 3800, 4516, 20157, 3800, 17504, 3800, 4163, 7, 673, 1622, 489, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kumarkrishna/sympy
sympy/matrices/expressions/inverse.py
84
2258
from __future__ import print_function, division from sympy.core.sympify import _sympify from sympy.core import S, Basic from sympy.matrices.expressions.matexpr import ShapeError from sympy.matrices.expressions.matpow import MatPow class Inverse(MatPow): """ The multiplicative inverse of a matrix expression This is a symbolic object that simply stores its argument without evaluating it. To actually compute the inverse, use the ``.inverse()`` method of matrices. Examples ======== >>> from sympy import MatrixSymbol, Inverse >>> A = MatrixSymbol('A', 3, 3) >>> B = MatrixSymbol('B', 3, 3) >>> Inverse(A) A^-1 >>> A.inverse() == Inverse(A) True >>> (A*B).inverse() B^-1*A^-1 >>> Inverse(A*B) (A*B)^-1 """ is_Inverse = True exp = S(-1) def __new__(cls, mat): mat = _sympify(mat) if not mat.is_Matrix: raise TypeError("mat should be a matrix") if not mat.is_square: raise ShapeError("Inverse of non-square matrix %s" % mat) return Basic.__new__(cls, mat) @property def arg(self): return self.args[0] @property def shape(self): return self.arg.shape def _eval_inverse(self): return self.arg def _eval_determinant(self): from sympy.matrices.expressions.determinant import det return 1/det(self.arg) def doit(self, **hints): if hints.get('deep', True): return self.arg.doit(**hints).inverse() else: return self.arg.inverse() from sympy.assumptions.ask import ask, Q from sympy.assumptions.refine import handlers_dict def refine_Inverse(expr, assumptions): """ >>> from sympy import MatrixSymbol, Q, assuming, refine >>> X = MatrixSymbol('X', 2, 2) >>> X.I X^-1 >>> with assuming(Q.orthogonal(X)): ... print(refine(X.I)) X' """ if ask(Q.orthogonal(expr), assumptions): return expr.arg.T elif ask(Q.unitary(expr), assumptions): return expr.arg.conjugate() elif ask(Q.singular(expr), assumptions): raise ValueError("Inverse of singular matrix %s" % expr.arg) return expr handlers_dict['Inverse'] = refine_Inverse
bsd-3-clause
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 14, 1786, 18456, 492, 485, 1786, 18456, 199, 504, 5840, 14, 1018, 492, 428, 12, 10082, 199, 199, 504, 5840, 14, 19032, 14, 15264, 14, 17684, 31149, 492, 16528, 547, 199, 504, 5840, 14, 19032, 14, 15264, 14, 569, 8278, 492, 18619, 23432, 421, 199, 533, 1010, 2077, 8, 14817, 23432, 304, 272, 408, 272, 710, 8897, 606, 1905, 11484, 402, 282, 3634, 3965, 339, 961, 365, 282, 13673, 909, 626, 9329, 14086, 2399, 1423, 1928, 272, 27083, 652, 14, 4005, 5965, 4526, 314, 11484, 12, 675, 314, 21502, 11668, 8497, 272, 1083, 402, 12627, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 8449, 8169, 12, 1010, 2077, 272, 1306, 437, 275, 8449, 8169, 360, 33, 297, 650, 12, 650, 9, 272, 1306, 699, 275, 8449, 8169, 360, 34, 297, 650, 12, 650, 9, 272, 1306, 1010, 2077, 8, 33, 9, 272, 437, 26185, 17, 272, 1306, 437, 14, 11668, 342, 508, 1010, 2077, 8, 33, 9, 272, 715, 272, 1306, 334, 33, 10, 34, 680, 11668, 342, 272, 699, 26185, 17, 10, 33, 26185, 17, 272, 1306, 1010, 2077, 8, 33, 10, 34, 9, 272, 334, 33, 10, 34, 18979, 13, 17, 339, 408, 272, 365, 63, 28274, 275, 715, 272, 1437, 275, 428, 2801, 17, 9, 339, 347, 636, 1222, 721, 1886, 12, 2530, 304, 267, 2530, 275, 485, 1786, 18456, 8, 569, 9, 267, 340, 440, 2530, 14, 374, 63, 6443, 26, 288, 746, 3146, 480, 569, 1077, 506, 282, 3634, 531, 267, 340, 440, 2530, 14, 374, 63, 9646, 26, 288, 746, 16528, 547, 480, 28274, 402, 2222, 13, 9646, 3634, 450, 83, 2, 450, 2530, 9, 267, 372, 10082, 855, 1222, 721, 1886, 12, 2530, 9, 339, 768, 1829, 272, 347, 1680, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 768, 1829, 272, 347, 2215, 8, 277, 304, 267, 372, 291, 14, 1273, 14, 1392, 339, 347, 485, 2579, 63, 11668, 8, 277, 304, 267, 372, 291, 14, 1273, 339, 347, 485, 2579, 63, 17061, 867, 8, 277, 304, 267, 687, 5840, 14, 19032, 14, 15264, 14, 17061, 867, 492, 20894, 267, 372, 413, 15, 9886, 8, 277, 14, 1273, 9, 339, 347, 886, 390, 8, 277, 12, 1011, 12354, 304, 267, 340, 18069, 14, 362, 360, 16131, 297, 715, 304, 288, 372, 291, 14, 1273, 14, 19014, 3682, 12354, 680, 11668, 342, 267, 587, 26, 288, 372, 291, 14, 1273, 14, 11668, 342, 421, 199, 504, 5840, 14, 405, 18064, 14, 813, 492, 7198, 12, 1413, 199, 504, 5840, 14, 405, 18064, 14, 1121, 1132, 492, 8297, 63, 807, 421, 199, 318, 2984, 1132, 63, 28274, 8, 3684, 12, 21546, 304, 272, 408, 272, 1306, 687, 5840, 492, 8449, 8169, 12, 1413, 12, 18002, 12, 2984, 1132, 272, 1306, 1323, 275, 8449, 8169, 360, 56, 297, 499, 12, 499, 9, 272, 1306, 1323, 14, 41, 272, 1323, 26185, 17, 272, 1306, 543, 18002, 8, 49, 14, 11297, 19133, 8, 56, 2298, 272, 2263, 258, 870, 8, 1121, 1132, 8, 56, 14, 41, 430, 272, 1323, 7, 272, 408, 272, 340, 7198, 8, 49, 14, 11297, 19133, 8, 3684, 395, 21546, 304, 267, 372, 5348, 14, 1273, 14, 52, 272, 916, 7198, 8, 49, 14, 3248, 695, 8, 3684, 395, 21546, 304, 267, 372, 5348, 14, 1273, 14, 26000, 342, 272, 916, 7198, 8, 49, 14, 17045, 8, 3684, 395, 21546, 304, 267, 746, 1722, 480, 28274, 402, 15823, 3634, 450, 83, 2, 450, 5348, 14, 1273, 9, 339, 372, 5348, 199, 199, 5586, 63, 807, 459, 28274, 418, 275, 2984, 1132, 63, 28274, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 12, 4629, 199, 199, 504, 5840, 14, 1018, 14, 1786, 18456, 492, 485, 1786, 18456, 199, 504, 5840, 14, 1018, 492, 428, 12, 10082, 199, 199, 504, 5840, 14, 19032, 14, 15264, 14, 17684, 31149, 492, 16528, 547, 199, 504, 5840, 14, 19032, 14, 15264, 14, 569, 8278, 492, 18619, 23432, 421, 199, 533, 1010, 2077, 8, 14817, 23432, 304, 272, 408, 272, 710, 8897, 606, 1905, 11484, 402, 282, 3634, 3965, 339, 961, 365, 282, 13673, 909, 626, 9329, 14086, 2399, 1423, 1928, 272, 27083, 652, 14, 4005, 5965, 4526, 314, 11484, 12, 675, 314, 21502, 11668, 8497, 272, 1083, 402, 12627, 14, 339, 6058, 272, 12655, 339, 1306, 687, 5840, 492, 8449, 8169, 12, 1010, 2077, 272, 1306, 437, 275, 8449, 8169, 360, 33, 297, 650, 12, 650, 9, 272, 1306, 699, 275, 8449, 8169, 360, 34, 297, 650, 12, 650, 9, 272, 1306, 1010, 2077, 8, 33, 9, 272, 437, 26185, 17, 272, 1306, 437, 14, 11668, 342, 508, 1010, 2077, 8, 33, 9, 272, 715, 272, 1306, 334, 33, 10, 34, 680, 11668, 342, 272, 699, 26185, 17, 10, 33, 26185, 17, 272, 1306, 1010, 2077, 8, 33, 10, 34, 9, 272, 334, 33, 10, 34, 18979, 13, 17, 339, 408, 272, 365, 63, 28274, 275, 715, 272, 1437, 275, 428, 2801, 17, 9, 339, 347, 636, 1222, 721, 1886, 12, 2530, 304, 267, 2530, 275, 485, 1786, 18456, 8, 569, 9, 267, 340, 440, 2530, 14, 374, 63, 6443, 26, 288, 746, 3146, 480, 569, 1077, 506, 282, 3634, 531, 267, 340, 440, 2530, 14, 374, 63, 9646, 26, 288, 746, 16528, 547, 480, 28274, 402, 2222, 13, 9646, 3634, 450, 83, 2, 450, 2530, 9, 267, 372, 10082, 855, 1222, 721, 1886, 12, 2530, 9, 339, 768, 1829, 272, 347, 1680, 8, 277, 304, 267, 372, 291, 14, 589, 59, 16, 61, 339, 768, 1829, 272, 347, 2215, 8, 277, 304, 267, 372, 291, 14, 1273, 14, 1392, 339, 347, 485, 2579, 63, 11668, 8, 277, 304, 267, 372, 291, 14, 1273, 339, 347, 485, 2579, 63, 17061, 867, 8, 277, 304, 267, 687, 5840, 14, 19032, 14, 15264, 14, 17061, 867, 492, 20894, 267, 372, 413, 15, 9886, 8, 277, 14, 1273, 9, 339, 347, 886, 390, 8, 277, 12, 1011, 12354, 304, 267, 340, 18069, 14, 362, 360, 16131, 297, 715, 304, 288, 372, 291, 14, 1273, 14, 19014, 3682, 12354, 680, 11668, 342, 267, 587, 26, 288, 372, 291, 14, 1273, 14, 11668, 342, 421, 199, 504, 5840, 14, 405, 18064, 14, 813, 492, 7198, 12, 1413, 199, 504, 5840, 14, 405, 18064, 14, 1121, 1132, 492, 8297, 63, 807, 421, 199, 318, 2984, 1132, 63, 28274, 8, 3684, 12, 21546, 304, 272, 408, 272, 1306, 687, 5840, 492, 8449, 8169, 12, 1413, 12, 18002, 12, 2984, 1132, 272, 1306, 1323, 275, 8449, 8169, 360, 56, 297, 499, 12, 499, 9, 272, 1306, 1323, 14, 41, 272, 1323, 26185, 17, 272, 1306, 543, 18002, 8, 49, 14, 11297, 19133, 8, 56, 2298, 272, 2263, 258, 870, 8, 1121, 1132, 8, 56, 14, 41, 430, 272, 1323, 7, 272, 408, 272, 340, 7198, 8, 49, 14, 11297, 19133, 8, 3684, 395, 21546, 304, 267, 372, 5348, 14, 1273, 14, 52, 272, 916, 7198, 8, 49, 14, 3248, 695, 8, 3684, 395, 21546, 304, 267, 372, 5348, 14, 1273, 14, 26000, 342, 272, 916, 7198, 8, 49, 14, 17045, 8, 3684, 395, 21546, 304, 267, 746, 1722, 480, 28274, 402, 15823, 3634, 450, 83, 2, 450, 5348, 14, 1273, 9, 339, 372, 5348, 199, 199, 5586, 63, 807, 459, 28274, 418, 275, 2984, 1132, 63, 28274, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
Eric89GXL/scipy
scipy/special/tests/test_nan_inputs.py
11
1775
"""Test how the ufuncs in special handle nan inputs. """ from __future__ import division, print_function, absolute_import import numpy as np from numpy.testing import assert_array_equal, assert_ import pytest import scipy.special as sc from scipy._lib._numpy_compat import suppress_warnings KNOWNFAILURES = {} POSTPROCESSING = {} def _get_ufuncs(): ufuncs = [] ufunc_names = [] for name in sorted(sc.__dict__): obj = sc.__dict__[name] if not isinstance(obj, np.ufunc): continue msg = KNOWNFAILURES.get(obj) if msg is None: ufuncs.append(obj) ufunc_names.append(name) else: fail = pytest.mark.xfail(run=False, reason=msg) ufuncs.append(pytest.param(obj, marks=fail)) ufunc_names.append(name) return ufuncs, ufunc_names UFUNCS, UFUNC_NAMES = _get_ufuncs() @pytest.mark.parametrize("func", UFUNCS, ids=UFUNC_NAMES) def test_nan_inputs(func): args = (np.nan,)*func.nin with suppress_warnings() as sup: # Ignore warnings about unsafe casts from legacy wrappers sup.filter(RuntimeWarning, "floating point number truncated to an integer") try: res = func(*args) except TypeError: # One of the arguments doesn't take real inputs return if func in POSTPROCESSING: res = POSTPROCESSING[func](*res) msg = "got {} instead of nan".format(res) assert_array_equal(np.isnan(res), True, err_msg=msg) def test_legacy_cast(): with suppress_warnings() as sup: sup.filter(RuntimeWarning, "floating point number truncated to an integer") res = sc.bdtrc(np.nan, 1, 0.5) assert_(np.isnan(res))
bsd-3-clause
[ 624, 774, 4212, 314, 399, 9204, 315, 4539, 2429, 12055, 4153, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 1452, 12, 702, 63, 199, 646, 4613, 199, 199, 646, 7026, 14, 6664, 465, 4061, 199, 504, 7026, 423, 773, 423, 4714, 63, 5819, 492, 15678, 63, 5451, 421, 199, 20004, 8784, 10799, 275, 1052, 199, 199, 4030, 10494, 1206, 275, 1052, 421, 199, 318, 485, 362, 63, 18810, 83, 837, 272, 399, 9204, 275, 942, 272, 30149, 63, 1247, 275, 942, 272, 367, 536, 315, 3355, 8, 551, 855, 807, 18580, 267, 1559, 275, 4061, 855, 807, 12298, 354, 61, 267, 340, 440, 1228, 8, 1113, 12, 980, 14, 18810, 304, 288, 1980, 267, 1499, 275, 1804, 9165, 8784, 10799, 14, 362, 8, 1113, 9, 267, 340, 1499, 365, 488, 26, 288, 399, 9204, 14, 740, 8, 1113, 9, 288, 30149, 63, 1247, 14, 740, 8, 354, 9, 267, 587, 26, 288, 2449, 275, 4613, 14, 1657, 14, 22557, 8, 1065, 29, 797, 12, 4499, 29, 1328, 9, 288, 399, 9204, 14, 740, 8, 4462, 14, 635, 8, 1113, 12, 17370, 29, 1633, 430, 288, 30149, 63, 1247, 14, 740, 8, 354, 9, 272, 372, 399, 9204, 12, 30149, 63, 1247, 421, 199, 53, 9309, 3298, 12, 738, 19587, 63, 14546, 275, 485, 362, 63, 18810, 83, 342, 421, 199, 32, 4462, 14, 1657, 14, 10396, 480, 1532, 401, 738, 9309, 3298, 12, 2762, 29, 53, 19587, 63, 14546, 9, 199, 318, 511, 63, 4304, 63, 3711, 8, 1532, 304, 272, 1249, 275, 334, 1590, 14, 4304, 12, 3342, 1532, 14, 28693, 272, 543, 15678, 63, 5451, 342, 465, 1029, 26, 267, 327, 14092, 3598, 3595, 19293, 9106, 83, 687, 12139, 17995, 267, 1029, 14, 1541, 8, 14357, 3849, 12, 673, 298, 7774, 2376, 1329, 17661, 370, 376, 3000, 531, 267, 862, 26, 288, 522, 275, 2562, 2031, 589, 9, 267, 871, 3146, 26, 288, 327, 7309, 402, 314, 2368, 3181, 1133, 5452, 3363, 4153, 288, 372, 272, 340, 2562, 315, 8761, 10494, 1206, 26, 267, 522, 275, 8761, 10494, 1206, 59, 1532, 61, 2031, 470, 9, 339, 1499, 275, 298, 7808, 1052, 3140, 402, 12055, 1674, 908, 8, 470, 9, 272, 702, 63, 1144, 63, 1452, 8, 1590, 14, 12936, 8, 470, 395, 715, 12, 2329, 63, 1328, 29, 1328, 9, 421, 199, 318, 511, 63, 10000, 63, 2931, 837, 272, 543, 15678, 63, 5451, 342, 465, 1029, 26, 267, 1029, 14, 1541, 8, 14357, 3849, 12, 673, 298, 7774, 2376, 1329, 17661, 370, 376, 3000, 531, 267, 522, 275, 4061, 14, 3691, 454, 67, 8, 1590, 14, 4304, 12, 413, 12, 378, 14, 21, 9, 267, 702, 2531, 1590, 14, 12936, 8, 470, 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 ]
[ 774, 4212, 314, 399, 9204, 315, 4539, 2429, 12055, 4153, 14, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 12, 3679, 63, 646, 199, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 1144, 63, 1452, 12, 702, 63, 199, 646, 4613, 199, 199, 646, 7026, 14, 6664, 465, 4061, 199, 504, 7026, 423, 773, 423, 4714, 63, 5819, 492, 15678, 63, 5451, 421, 199, 20004, 8784, 10799, 275, 1052, 199, 199, 4030, 10494, 1206, 275, 1052, 421, 199, 318, 485, 362, 63, 18810, 83, 837, 272, 399, 9204, 275, 942, 272, 30149, 63, 1247, 275, 942, 272, 367, 536, 315, 3355, 8, 551, 855, 807, 18580, 267, 1559, 275, 4061, 855, 807, 12298, 354, 61, 267, 340, 440, 1228, 8, 1113, 12, 980, 14, 18810, 304, 288, 1980, 267, 1499, 275, 1804, 9165, 8784, 10799, 14, 362, 8, 1113, 9, 267, 340, 1499, 365, 488, 26, 288, 399, 9204, 14, 740, 8, 1113, 9, 288, 30149, 63, 1247, 14, 740, 8, 354, 9, 267, 587, 26, 288, 2449, 275, 4613, 14, 1657, 14, 22557, 8, 1065, 29, 797, 12, 4499, 29, 1328, 9, 288, 399, 9204, 14, 740, 8, 4462, 14, 635, 8, 1113, 12, 17370, 29, 1633, 430, 288, 30149, 63, 1247, 14, 740, 8, 354, 9, 272, 372, 399, 9204, 12, 30149, 63, 1247, 421, 199, 53, 9309, 3298, 12, 738, 19587, 63, 14546, 275, 485, 362, 63, 18810, 83, 342, 421, 199, 32, 4462, 14, 1657, 14, 10396, 480, 1532, 401, 738, 9309, 3298, 12, 2762, 29, 53, 19587, 63, 14546, 9, 199, 318, 511, 63, 4304, 63, 3711, 8, 1532, 304, 272, 1249, 275, 334, 1590, 14, 4304, 12, 3342, 1532, 14, 28693, 272, 543, 15678, 63, 5451, 342, 465, 1029, 26, 267, 327, 14092, 3598, 3595, 19293, 9106, 83, 687, 12139, 17995, 267, 1029, 14, 1541, 8, 14357, 3849, 12, 673, 298, 7774, 2376, 1329, 17661, 370, 376, 3000, 531, 267, 862, 26, 288, 522, 275, 2562, 2031, 589, 9, 267, 871, 3146, 26, 288, 327, 7309, 402, 314, 2368, 3181, 1133, 5452, 3363, 4153, 288, 372, 272, 340, 2562, 315, 8761, 10494, 1206, 26, 267, 522, 275, 8761, 10494, 1206, 59, 1532, 61, 2031, 470, 9, 339, 1499, 275, 298, 7808, 1052, 3140, 402, 12055, 1674, 908, 8, 470, 9, 272, 702, 63, 1144, 63, 1452, 8, 1590, 14, 12936, 8, 470, 395, 715, 12, 2329, 63, 1328, 29, 1328, 9, 421, 199, 318, 511, 63, 10000, 63, 2931, 837, 272, 543, 15678, 63, 5451, 342, 465, 1029, 26, 267, 1029, 14, 1541, 8, 14357, 3849, 12, 673, 298, 7774, 2376, 1329, 17661, 370, 376, 3000, 531, 267, 522, 275, 4061, 14, 3691, 454, 67, 8, 1590, 14, 4304, 12, 413, 12, 378, 14, 21, 9, 267, 702, 2531, 1590, 14, 12936, 8, 470, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
gregdek/ansible
test/legacy/cleanup_rax.py
160
6547
#!/usr/bin/env python import os import re import yaml import argparse try: import pyrax HAS_PYRAX = True except ImportError: HAS_PYRAX = False from ansible.module_utils.six.moves import input def rax_list_iterator(svc, *args, **kwargs): method = kwargs.pop('method', 'list') items = getattr(svc, method)(*args, **kwargs) while items: retrieved = getattr(svc, method)(*args, marker=items[-1].id, **kwargs) if items and retrieved and items[-1].id == retrieved[0].id: del items[-1] items.extend(retrieved) if len(retrieved) < 2: break return items def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-y', '--yes', action='store_true', dest='assumeyes', default=False, help="Don't prompt for confirmation") parser.add_argument('--match', dest='match_re', default='^ansible-testing', help='Regular expression used to find resources ' '(default: %(default)s)') return parser.parse_args() def authenticate(): try: with open(os.path.realpath('./credentials.yml')) as f: credentials = yaml.load(f) except Exception as e: raise SystemExit(e) try: pyrax.set_credentials(credentials.get('rackspace_username'), credentials.get('rackspace_api_key')) except Exception as e: raise SystemExit(e) def prompt_and_delete(item, prompt, assumeyes): if not assumeyes: assumeyes = input(prompt).lower() == 'y' assert hasattr(item, 'delete') or hasattr(item, 'terminate'), \ "Class <%s> has no delete or terminate attribute" % item.__class__ if assumeyes: if hasattr(item, 'delete'): item.delete() print("Deleted %s" % item) if hasattr(item, 'terminate'): item.terminate() print("Terminated %s" % item) def delete_rax(args): """Function for deleting CloudServers""" print("--- Cleaning CloudServers matching '%s'" % args.match_re) search_opts = dict(name='^%s' % args.match_re) for region in pyrax.identity.services.compute.regions: cs = pyrax.connect_to_cloudservers(region=region) servers = rax_list_iterator(cs.servers, search_opts=search_opts) for server in servers: prompt_and_delete(server, 'Delete matching %s? [y/n]: ' % server, args.assumeyes) def delete_rax_clb(args): """Function for deleting Cloud Load Balancers""" print("--- Cleaning Cloud Load Balancers matching '%s'" % args.match_re) for region in pyrax.identity.services.load_balancer.regions: clb = pyrax.connect_to_cloud_loadbalancers(region=region) for lb in rax_list_iterator(clb): if re.search(args.match_re, lb.name): prompt_and_delete(lb, 'Delete matching %s? [y/n]: ' % lb, args.assumeyes) def delete_rax_keypair(args): """Function for deleting Rackspace Key pairs""" print("--- Cleaning Key Pairs matching '%s'" % args.match_re) for region in pyrax.identity.services.compute.regions: cs = pyrax.connect_to_cloudservers(region=region) for keypair in cs.keypairs.list(): if re.search(args.match_re, keypair.name): prompt_and_delete(keypair, 'Delete matching %s? [y/n]: ' % keypair, args.assumeyes) def delete_rax_network(args): """Function for deleting Cloud Networks""" print("--- Cleaning Cloud Networks matching '%s'" % args.match_re) for region in pyrax.identity.services.network.regions: cnw = pyrax.connect_to_cloud_networks(region=region) for network in cnw.list(): if re.search(args.match_re, network.name): prompt_and_delete(network, 'Delete matching %s? [y/n]: ' % network, args.assumeyes) def delete_rax_cbs(args): """Function for deleting Cloud Networks""" print("--- Cleaning Cloud Block Storage matching '%s'" % args.match_re) for region in pyrax.identity.services.network.regions: cbs = pyrax.connect_to_cloud_blockstorage(region=region) for volume in cbs.list(): if re.search(args.match_re, volume.name): prompt_and_delete(volume, 'Delete matching %s? [y/n]: ' % volume, args.assumeyes) def delete_rax_cdb(args): """Function for deleting Cloud Databases""" print("--- Cleaning Cloud Databases matching '%s'" % args.match_re) for region in pyrax.identity.services.database.regions: cdb = pyrax.connect_to_cloud_databases(region=region) for db in rax_list_iterator(cdb): if re.search(args.match_re, db.name): prompt_and_delete(db, 'Delete matching %s? [y/n]: ' % db, args.assumeyes) def _force_delete_rax_scaling_group(manager): def wrapped(uri): manager.api.method_delete('%s?force=true' % uri) return wrapped def delete_rax_scaling_group(args): """Function for deleting Autoscale Groups""" print("--- Cleaning Autoscale Groups matching '%s'" % args.match_re) for region in pyrax.identity.services.autoscale.regions: asg = pyrax.connect_to_autoscale(region=region) for group in rax_list_iterator(asg): if re.search(args.match_re, group.name): group.manager._delete = \ _force_delete_rax_scaling_group(group.manager) prompt_and_delete(group, 'Delete matching %s? [y/n]: ' % group, args.assumeyes) def main(): if not HAS_PYRAX: raise SystemExit('The pyrax python module is required for this script') args = parse_args() authenticate() funcs = [f for n, f in globals().items() if n.startswith('delete_rax')] for func in sorted(funcs, key=lambda f: f.__name__): try: func(args) except Exception as e: print("---- %s failed (%s)" % (func.__name__, e.message)) if __name__ == '__main__': try: main() except KeyboardInterrupt: print('\nExiting...')
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 295, 199, 646, 8864, 199, 646, 7534, 199, 199, 893, 26, 272, 492, 23944, 272, 7509, 63, 4521, 2847, 56, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 2847, 56, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 1324, 421, 199, 318, 16937, 63, 513, 63, 5778, 8, 10599, 12, 627, 589, 12, 1011, 958, 304, 272, 1083, 275, 2074, 14, 1935, 360, 765, 297, 283, 513, 358, 272, 2974, 275, 2519, 8, 10599, 12, 1083, 25967, 589, 12, 1011, 958, 9, 272, 1830, 2974, 26, 267, 12396, 275, 2519, 8, 10599, 12, 1083, 25967, 589, 12, 3608, 29, 1744, 1988, 17, 1055, 344, 12, 1011, 958, 9, 267, 340, 2974, 436, 12396, 436, 2974, 1988, 17, 1055, 344, 508, 12396, 59, 16, 1055, 344, 26, 288, 2150, 2974, 1988, 17, 61, 267, 2974, 14, 2880, 8, 11235, 27986, 9, 267, 340, 822, 8, 11235, 27986, 9, 665, 499, 26, 288, 2059, 272, 372, 2974, 421, 199, 318, 2198, 63, 589, 837, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 3654, 89, 297, 2850, 5066, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 21946, 5066, 297, 717, 849, 29, 797, 12, 1720, 628, 16932, 1133, 8457, 367, 18791, 531, 272, 1798, 14, 525, 63, 2094, 4517, 1431, 297, 2053, 534, 1431, 63, 264, 297, 717, 849, 534, 62, 4853, 13, 4776, 297, 717, 1720, 534, 16038, 3965, 1202, 370, 2342, 5944, 283, 2490, 8189, 885, 26, 2818, 885, 9, 83, 5942, 339, 372, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 12895, 837, 272, 862, 26, 267, 543, 1551, 8, 736, 14, 515, 14, 11091, 17371, 6942, 14, 11714, 1333, 465, 289, 26, 288, 6235, 275, 8864, 14, 912, 8, 70, 9, 272, 871, 2186, 465, 325, 26, 267, 746, 14838, 8, 69, 9, 339, 862, 26, 267, 23944, 14, 409, 63, 6942, 8, 6942, 14, 362, 360, 8085, 2638, 63, 2473, 659, 2892, 6235, 14, 362, 360, 8085, 2638, 63, 1246, 63, 498, 1333, 272, 871, 2186, 465, 325, 26, 267, 746, 14838, 8, 69, 9, 421, 199, 318, 8457, 63, 460, 63, 1807, 8, 1053, 12, 8457, 12, 5534, 5066, 304, 272, 340, 440, 5534, 5066, 26, 267, 5534, 5066, 275, 1324, 8, 7650, 680, 2325, 342, 508, 283, 89, 7, 272, 702, 2688, 8, 1053, 12, 283, 1807, 358, 503, 2688, 8, 1053, 12, 283, 14478, 659, 971, 267, 298, 2543, 21808, 83, 30, 965, 949, 3145, 503, 15095, 2225, 2, 450, 1242, 855, 533, 363, 272, 340, 5534, 5066, 26, 267, 340, 2688, 8, 1053, 12, 283, 1807, 735, 288, 1242, 14, 1807, 342, 288, 870, 480, 17735, 450, 83, 2, 450, 1242, 9, 267, 340, 2688, 8, 1053, 12, 283, 14478, 735, 288, 1242, 14, 14478, 342, 288, 870, 480, 12154, 972, 450, 83, 2, 450, 1242, 9, 421, 199, 318, 3145, 63, 14495, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 23637, 624, 272, 870, 480, 2595, 12762, 316, 8142, 23637, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 2754, 63, 3291, 275, 1211, 8, 354, 534, 62, 5, 83, 7, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 3357, 14, 11963, 26, 267, 7117, 275, 23944, 14, 2242, 63, 475, 63, 4091, 5871, 8, 4551, 29, 4551, 9, 267, 8037, 275, 16937, 63, 513, 63, 5778, 8, 1259, 14, 5871, 12, 2754, 63, 3291, 29, 1733, 63, 3291, 9, 267, 367, 1654, 315, 8037, 26, 288, 8457, 63, 460, 63, 1807, 8, 1000, 12, 2892, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 1654, 12, 2892, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 429, 66, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 7190, 23928, 23102, 624, 272, 870, 480, 2595, 12762, 316, 8142, 7190, 23928, 23102, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 912, 63, 11841, 14, 11963, 26, 267, 824, 66, 275, 23944, 14, 2242, 63, 475, 63, 4091, 63, 912, 29674, 8, 4551, 29, 4551, 9, 267, 367, 11104, 315, 16937, 63, 513, 63, 5778, 8, 429, 66, 304, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 11104, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 6374, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 11104, 12, 3303, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 19263, 8, 589, 304, 272, 408, 3481, 367, 13794, 32679, 2606, 6342, 624, 272, 870, 480, 2595, 12762, 316, 2606, 510, 8387, 83, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 3357, 14, 11963, 26, 267, 7117, 275, 23944, 14, 2242, 63, 475, 63, 4091, 5871, 8, 4551, 29, 4551, 9, 267, 367, 23911, 315, 7117, 14, 30825, 14, 513, 837, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 23911, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 19263, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 23911, 12, 3303, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 1200, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 17138, 624, 272, 870, 480, 2595, 12762, 316, 8142, 17138, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 1200, 14, 11963, 26, 267, 286, 13100, 275, 23944, 14, 2242, 63, 475, 63, 4091, 63, 7642, 8, 4551, 29, 4551, 9, 267, 367, 2784, 315, 286, 13100, 14, 513, 837, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 2784, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 1200, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 2784, 12, 3303, 1249 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 747, 199, 646, 295, 199, 646, 8864, 199, 646, 7534, 199, 199, 893, 26, 272, 492, 23944, 272, 7509, 63, 4521, 2847, 56, 275, 715, 199, 2590, 3545, 26, 272, 7509, 63, 4521, 2847, 56, 275, 756, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 14, 4912, 492, 1324, 421, 199, 318, 16937, 63, 513, 63, 5778, 8, 10599, 12, 627, 589, 12, 1011, 958, 304, 272, 1083, 275, 2074, 14, 1935, 360, 765, 297, 283, 513, 358, 272, 2974, 275, 2519, 8, 10599, 12, 1083, 25967, 589, 12, 1011, 958, 9, 272, 1830, 2974, 26, 267, 12396, 275, 2519, 8, 10599, 12, 1083, 25967, 589, 12, 3608, 29, 1744, 1988, 17, 1055, 344, 12, 1011, 958, 9, 267, 340, 2974, 436, 12396, 436, 2974, 1988, 17, 1055, 344, 508, 12396, 59, 16, 1055, 344, 26, 288, 2150, 2974, 1988, 17, 61, 267, 2974, 14, 2880, 8, 11235, 27986, 9, 267, 340, 822, 8, 11235, 27986, 9, 665, 499, 26, 288, 2059, 272, 372, 2974, 421, 199, 318, 2198, 63, 589, 837, 272, 1798, 275, 7534, 14, 10730, 342, 272, 1798, 14, 525, 63, 2094, 3654, 89, 297, 2850, 5066, 297, 1595, 534, 1617, 63, 2052, 297, 2053, 534, 21946, 5066, 297, 717, 849, 29, 797, 12, 1720, 628, 16932, 1133, 8457, 367, 18791, 531, 272, 1798, 14, 525, 63, 2094, 4517, 1431, 297, 2053, 534, 1431, 63, 264, 297, 717, 849, 534, 62, 4853, 13, 4776, 297, 717, 1720, 534, 16038, 3965, 1202, 370, 2342, 5944, 283, 2490, 8189, 885, 26, 2818, 885, 9, 83, 5942, 339, 372, 1798, 14, 1122, 63, 589, 342, 421, 199, 318, 12895, 837, 272, 862, 26, 267, 543, 1551, 8, 736, 14, 515, 14, 11091, 17371, 6942, 14, 11714, 1333, 465, 289, 26, 288, 6235, 275, 8864, 14, 912, 8, 70, 9, 272, 871, 2186, 465, 325, 26, 267, 746, 14838, 8, 69, 9, 339, 862, 26, 267, 23944, 14, 409, 63, 6942, 8, 6942, 14, 362, 360, 8085, 2638, 63, 2473, 659, 2892, 6235, 14, 362, 360, 8085, 2638, 63, 1246, 63, 498, 1333, 272, 871, 2186, 465, 325, 26, 267, 746, 14838, 8, 69, 9, 421, 199, 318, 8457, 63, 460, 63, 1807, 8, 1053, 12, 8457, 12, 5534, 5066, 304, 272, 340, 440, 5534, 5066, 26, 267, 5534, 5066, 275, 1324, 8, 7650, 680, 2325, 342, 508, 283, 89, 7, 272, 702, 2688, 8, 1053, 12, 283, 1807, 358, 503, 2688, 8, 1053, 12, 283, 14478, 659, 971, 267, 298, 2543, 21808, 83, 30, 965, 949, 3145, 503, 15095, 2225, 2, 450, 1242, 855, 533, 363, 272, 340, 5534, 5066, 26, 267, 340, 2688, 8, 1053, 12, 283, 1807, 735, 288, 1242, 14, 1807, 342, 288, 870, 480, 17735, 450, 83, 2, 450, 1242, 9, 267, 340, 2688, 8, 1053, 12, 283, 14478, 735, 288, 1242, 14, 14478, 342, 288, 870, 480, 12154, 972, 450, 83, 2, 450, 1242, 9, 421, 199, 318, 3145, 63, 14495, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 23637, 624, 272, 870, 480, 2595, 12762, 316, 8142, 23637, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 2754, 63, 3291, 275, 1211, 8, 354, 534, 62, 5, 83, 7, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 3357, 14, 11963, 26, 267, 7117, 275, 23944, 14, 2242, 63, 475, 63, 4091, 5871, 8, 4551, 29, 4551, 9, 267, 8037, 275, 16937, 63, 513, 63, 5778, 8, 1259, 14, 5871, 12, 2754, 63, 3291, 29, 1733, 63, 3291, 9, 267, 367, 1654, 315, 8037, 26, 288, 8457, 63, 460, 63, 1807, 8, 1000, 12, 2892, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 1654, 12, 2892, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 429, 66, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 7190, 23928, 23102, 624, 272, 870, 480, 2595, 12762, 316, 8142, 7190, 23928, 23102, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 912, 63, 11841, 14, 11963, 26, 267, 824, 66, 275, 23944, 14, 2242, 63, 475, 63, 4091, 63, 912, 29674, 8, 4551, 29, 4551, 9, 267, 367, 11104, 315, 16937, 63, 513, 63, 5778, 8, 429, 66, 304, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 11104, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 6374, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 11104, 12, 3303, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 19263, 8, 589, 304, 272, 408, 3481, 367, 13794, 32679, 2606, 6342, 624, 272, 870, 480, 2595, 12762, 316, 2606, 510, 8387, 83, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 3357, 14, 11963, 26, 267, 7117, 275, 23944, 14, 2242, 63, 475, 63, 4091, 5871, 8, 4551, 29, 4551, 9, 267, 367, 23911, 315, 7117, 14, 30825, 14, 513, 837, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 23911, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 19263, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 23911, 12, 3303, 1249, 14, 21946, 5066, 9, 421, 199, 318, 3145, 63, 14495, 63, 1200, 8, 589, 304, 272, 408, 3481, 367, 13794, 8142, 17138, 624, 272, 870, 480, 2595, 12762, 316, 8142, 17138, 4877, 1543, 83, 4065, 450, 1249, 14, 1431, 63, 264, 9, 272, 367, 4897, 315, 23944, 14, 5582, 14, 5950, 14, 1200, 14, 11963, 26, 267, 286, 13100, 275, 23944, 14, 2242, 63, 475, 63, 4091, 63, 7642, 8, 4551, 29, 4551, 9, 267, 367, 2784, 315, 286, 13100, 14, 513, 837, 288, 340, 295, 14, 1733, 8, 589, 14, 1431, 63, 264, 12, 2784, 14, 354, 304, 355, 8457, 63, 460, 63, 1807, 8, 1200, 12, 3303, 283, 5392, 4877, 450, 83, 31, 359, 89, 15, 78, 2189, 283, 450, 2784, 12, 3303, 1249, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Zac-HD/home-assistant
tests/components/test_sun.py
12
3962
"""The tests for the Sun component.""" # pylint: disable=protected-access import unittest from unittest.mock import patch from datetime import timedelta, datetime from homeassistant.bootstrap import setup_component import homeassistant.core as ha import homeassistant.util.dt as dt_util import homeassistant.components.sun as sun from tests.common import get_test_home_assistant # pylint: disable=invalid-name class TestSun(unittest.TestCase): """Test the sun module.""" def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() def tearDown(self): """Stop everything that was started.""" self.hass.stop() def test_is_on(self): """Test is_on method.""" self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON) self.assertTrue(sun.is_on(self.hass)) self.hass.states.set(sun.ENTITY_ID, sun.STATE_BELOW_HORIZON) self.assertFalse(sun.is_on(self.hass)) def test_setting_rising(self): """Test retrieving sun setting and rising.""" setup_component(self.hass, sun.DOMAIN, { sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) from astral import Astral astral = Astral() utc_now = dt_util.utcnow() latitude = self.hass.config.latitude longitude = self.hass.config.longitude mod = -1 while True: next_rising = (astral.sunrise_utc(utc_now + timedelta(days=mod), latitude, longitude)) if next_rising > utc_now: break mod += 1 mod = -1 while True: next_setting = (astral.sunset_utc(utc_now + timedelta(days=mod), latitude, longitude)) if next_setting > utc_now: break mod += 1 self.assertEqual(next_rising, sun.next_rising_utc(self.hass)) self.assertEqual(next_setting, sun.next_setting_utc(self.hass)) # Point it at a state without the proper attributes self.hass.states.set(sun.ENTITY_ID, sun.STATE_ABOVE_HORIZON) self.assertIsNone(sun.next_rising(self.hass)) self.assertIsNone(sun.next_setting(self.hass)) # Point it at a non-existing state self.assertIsNone(sun.next_rising(self.hass, 'non.existing')) self.assertIsNone(sun.next_setting(self.hass, 'non.existing')) def test_state_change(self): """Test if the state changes at next setting/rising.""" setup_component(self.hass, sun.DOMAIN, { sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) if sun.is_on(self.hass): test_state = sun.STATE_BELOW_HORIZON test_time = sun.next_setting(self.hass) else: test_state = sun.STATE_ABOVE_HORIZON test_time = sun.next_rising(self.hass) self.assertIsNotNone(test_time) self.hass.bus.fire(ha.EVENT_TIME_CHANGED, {ha.ATTR_NOW: test_time + timedelta(seconds=5)}) self.hass.block_till_done() self.assertEqual(test_state, self.hass.states.get(sun.ENTITY_ID).state) def test_norway_in_june(self): """Test location in Norway where the sun doesn't set in summer.""" self.hass.config.latitude = 69.6 self.hass.config.longitude = 18.8 june = datetime(2016, 6, 1, tzinfo=dt_util.UTC) with patch('homeassistant.helpers.condition.dt_util.utcnow', return_value=june): assert setup_component(self.hass, sun.DOMAIN, { sun.DOMAIN: {sun.CONF_ELEVATION: 0}}) state = self.hass.states.get(sun.ENTITY_ID) assert state is not None assert sun.next_rising_utc(self.hass) == \ datetime(2016, 7, 25, 23, 38, 21, tzinfo=dt_util.UTC) assert sun.next_setting_utc(self.hass) == \ datetime(2016, 7, 26, 22, 4, 18, tzinfo=dt_util.UTC)
apache-2.0
[ 624, 1918, 2295, 367, 314, 25625, 3931, 1041, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 646, 2882, 199, 504, 2882, 14, 1805, 492, 3371, 199, 504, 2197, 492, 6871, 12, 2197, 199, 199, 504, 8846, 14, 11146, 492, 3272, 63, 3173, 199, 646, 8846, 14, 1018, 465, 18251, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 646, 8846, 14, 4608, 14, 11846, 465, 26668, 199, 199, 504, 2295, 14, 2330, 492, 664, 63, 396, 63, 4219, 63, 7310, 421, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 533, 1379, 22546, 8, 2796, 14, 1746, 304, 272, 408, 774, 314, 26668, 859, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 8555, 7645, 370, 506, 1255, 1380, 2295, 787, 8239, 1041, 267, 291, 14, 5387, 275, 664, 63, 396, 63, 4219, 63, 7310, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 6293, 8137, 626, 1990, 8239, 1041, 267, 291, 14, 5387, 14, 2379, 342, 339, 347, 511, 63, 374, 63, 265, 8, 277, 304, 267, 408, 774, 365, 63, 265, 1083, 1041, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 9, 267, 291, 14, 1815, 8, 11846, 14, 374, 63, 265, 8, 277, 14, 5387, 430, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 6773, 5896, 63, 40, 7123, 615, 9, 267, 291, 14, 3334, 8, 11846, 14, 374, 63, 265, 8, 277, 14, 5387, 430, 339, 347, 511, 63, 6031, 63, 322, 1044, 8, 277, 304, 267, 408, 774, 23812, 26668, 4260, 436, 8012, 1044, 1041, 267, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 288, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 687, 282, 31943, 492, 437, 31943, 398, 282, 31943, 275, 437, 31943, 342, 267, 19314, 63, 2131, 275, 4487, 63, 1974, 14, 10779, 342, 398, 18896, 275, 291, 14, 5387, 14, 888, 14, 13331, 267, 18154, 275, 291, 14, 5387, 14, 888, 14, 13803, 398, 3413, 275, 446, 17, 267, 1830, 715, 26, 288, 2163, 63, 322, 1044, 275, 334, 65, 31943, 14, 11846, 28479, 63, 5834, 8, 5834, 63, 2131, 435, 2574, 6871, 8, 4899, 29, 1494, 395, 18896, 12, 18154, 430, 288, 340, 2163, 63, 322, 1044, 690, 19314, 63, 2131, 26, 355, 2059, 288, 3413, 847, 413, 398, 3413, 275, 446, 17, 267, 1830, 715, 26, 288, 2163, 63, 6031, 275, 334, 65, 31943, 14, 11846, 409, 63, 5834, 8, 5834, 63, 2131, 435, 1169, 6871, 8, 4899, 29, 1494, 395, 18896, 12, 18154, 430, 288, 340, 2163, 63, 6031, 690, 19314, 63, 2131, 26, 355, 2059, 288, 3413, 847, 413, 398, 291, 14, 629, 8, 2184, 63, 322, 1044, 12, 26668, 14, 2184, 63, 322, 1044, 63, 5834, 8, 277, 14, 5387, 430, 267, 291, 14, 629, 8, 2184, 63, 6031, 12, 26668, 14, 2184, 63, 6031, 63, 5834, 8, 277, 14, 5387, 430, 398, 327, 7584, 652, 737, 282, 1174, 1928, 314, 5576, 3004, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 9, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 430, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 6031, 8, 277, 14, 5387, 430, 398, 327, 7584, 652, 737, 282, 2222, 13, 5952, 1174, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 12, 283, 2865, 14, 5952, 1333, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 6031, 8, 277, 14, 5387, 12, 283, 2865, 14, 5952, 1333, 339, 347, 511, 63, 929, 63, 1461, 8, 277, 304, 267, 408, 774, 340, 314, 1174, 4493, 737, 2163, 4260, 15, 322, 1044, 1041, 267, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 288, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 340, 26668, 14, 374, 63, 265, 8, 277, 14, 5387, 304, 288, 511, 63, 929, 275, 26668, 14, 6689, 63, 6773, 5896, 63, 40, 7123, 615, 288, 511, 63, 521, 275, 26668, 14, 2184, 63, 6031, 8, 277, 14, 5387, 9, 267, 587, 26, 288, 511, 63, 929, 275, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 288, 511, 63, 521, 275, 26668, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 9, 398, 291, 14, 10389, 8, 396, 63, 521, 9, 398, 291, 14, 5387, 14, 5610, 14, 8935, 8, 2411, 14, 8193, 63, 4961, 63, 21488, 12, 2574, 469, 2411, 14, 5280, 63, 14283, 26, 511, 63, 521, 435, 6871, 8, 4515, 29, 21, 11466, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 291, 14, 629, 8, 396, 63, 929, 12, 291, 14, 5387, 14, 4981, 14, 362, 8, 11846, 14, 13630, 63, 998, 680, 929, 9, 339, 347, 511, 63, 6505, 3316, 63, 262, 63, 74, 11474, 8, 277, 304, 267, 408, 774, 2909, 315, 653, 269, 3316, 2382, 314, 26668, 3181, 1133, 663, 315, 3089, 2626, 1041, 267, 291, 14, 5387, 14, 888, 14, 13331, 275, 14610, 14, 22, 267, 291, 14, 5387, 14, 888, 14, 13803, 275, 6155, 14, 24, 398, 1335, 11474, 275, 2197, 8, 9261, 12, 1227, 12, 413, 12, 10313, 29, 3583, 63, 1974, 14, 11288, 9, 398, 543, 3371, 360, 22799, 14, 7546, 14, 5394, 14, 3583, 63, 1974, 14, 10779, 297, 673, 372, 63, 585, 29, 74, 11474, 304, 288, 702, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 355, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 1174, 275, 291, 14, 5387, 14, 4981, 14, 362, 8, 11846, 14, 13630, 63, 998, 9, 398, 702, 1174, 365, 440, 488, 267, 702, 26668, 14, 2184, 63, 322, 1044, 63, 5834, 8, 277, 14, 5387, 9, 508, 971, 288, 2197, 8, 9261, 12 ]
[ 1918, 2295, 367, 314, 25625, 3931, 1041, 199, 3, 4287, 26, 3507, 29, 6798, 13, 2732, 199, 646, 2882, 199, 504, 2882, 14, 1805, 492, 3371, 199, 504, 2197, 492, 6871, 12, 2197, 199, 199, 504, 8846, 14, 11146, 492, 3272, 63, 3173, 199, 646, 8846, 14, 1018, 465, 18251, 199, 646, 8846, 14, 1974, 14, 3583, 465, 4487, 63, 1974, 199, 646, 8846, 14, 4608, 14, 11846, 465, 26668, 199, 199, 504, 2295, 14, 2330, 492, 664, 63, 396, 63, 4219, 63, 7310, 421, 199, 3, 4287, 26, 3507, 29, 3197, 13, 354, 199, 533, 1379, 22546, 8, 2796, 14, 1746, 304, 272, 408, 774, 314, 26668, 859, 1041, 339, 347, 3613, 8, 277, 304, 267, 408, 8555, 7645, 370, 506, 1255, 1380, 2295, 787, 8239, 1041, 267, 291, 14, 5387, 275, 664, 63, 396, 63, 4219, 63, 7310, 342, 339, 347, 6766, 8, 277, 304, 267, 408, 6293, 8137, 626, 1990, 8239, 1041, 267, 291, 14, 5387, 14, 2379, 342, 339, 347, 511, 63, 374, 63, 265, 8, 277, 304, 267, 408, 774, 365, 63, 265, 1083, 1041, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 9, 267, 291, 14, 1815, 8, 11846, 14, 374, 63, 265, 8, 277, 14, 5387, 430, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 6773, 5896, 63, 40, 7123, 615, 9, 267, 291, 14, 3334, 8, 11846, 14, 374, 63, 265, 8, 277, 14, 5387, 430, 339, 347, 511, 63, 6031, 63, 322, 1044, 8, 277, 304, 267, 408, 774, 23812, 26668, 4260, 436, 8012, 1044, 1041, 267, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 288, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 687, 282, 31943, 492, 437, 31943, 398, 282, 31943, 275, 437, 31943, 342, 267, 19314, 63, 2131, 275, 4487, 63, 1974, 14, 10779, 342, 398, 18896, 275, 291, 14, 5387, 14, 888, 14, 13331, 267, 18154, 275, 291, 14, 5387, 14, 888, 14, 13803, 398, 3413, 275, 446, 17, 267, 1830, 715, 26, 288, 2163, 63, 322, 1044, 275, 334, 65, 31943, 14, 11846, 28479, 63, 5834, 8, 5834, 63, 2131, 435, 2574, 6871, 8, 4899, 29, 1494, 395, 18896, 12, 18154, 430, 288, 340, 2163, 63, 322, 1044, 690, 19314, 63, 2131, 26, 355, 2059, 288, 3413, 847, 413, 398, 3413, 275, 446, 17, 267, 1830, 715, 26, 288, 2163, 63, 6031, 275, 334, 65, 31943, 14, 11846, 409, 63, 5834, 8, 5834, 63, 2131, 435, 1169, 6871, 8, 4899, 29, 1494, 395, 18896, 12, 18154, 430, 288, 340, 2163, 63, 6031, 690, 19314, 63, 2131, 26, 355, 2059, 288, 3413, 847, 413, 398, 291, 14, 629, 8, 2184, 63, 322, 1044, 12, 26668, 14, 2184, 63, 322, 1044, 63, 5834, 8, 277, 14, 5387, 430, 267, 291, 14, 629, 8, 2184, 63, 6031, 12, 26668, 14, 2184, 63, 6031, 63, 5834, 8, 277, 14, 5387, 430, 398, 327, 7584, 652, 737, 282, 1174, 1928, 314, 5576, 3004, 267, 291, 14, 5387, 14, 4981, 14, 409, 8, 11846, 14, 13630, 63, 998, 12, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 9, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 430, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 6031, 8, 277, 14, 5387, 430, 398, 327, 7584, 652, 737, 282, 2222, 13, 5952, 1174, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 12, 283, 2865, 14, 5952, 1333, 267, 291, 14, 7702, 8, 11846, 14, 2184, 63, 6031, 8, 277, 14, 5387, 12, 283, 2865, 14, 5952, 1333, 339, 347, 511, 63, 929, 63, 1461, 8, 277, 304, 267, 408, 774, 340, 314, 1174, 4493, 737, 2163, 4260, 15, 322, 1044, 1041, 267, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 288, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 340, 26668, 14, 374, 63, 265, 8, 277, 14, 5387, 304, 288, 511, 63, 929, 275, 26668, 14, 6689, 63, 6773, 5896, 63, 40, 7123, 615, 288, 511, 63, 521, 275, 26668, 14, 2184, 63, 6031, 8, 277, 14, 5387, 9, 267, 587, 26, 288, 511, 63, 929, 275, 26668, 14, 6689, 63, 1217, 47, 2524, 63, 40, 7123, 615, 288, 511, 63, 521, 275, 26668, 14, 2184, 63, 322, 1044, 8, 277, 14, 5387, 9, 398, 291, 14, 10389, 8, 396, 63, 521, 9, 398, 291, 14, 5387, 14, 5610, 14, 8935, 8, 2411, 14, 8193, 63, 4961, 63, 21488, 12, 2574, 469, 2411, 14, 5280, 63, 14283, 26, 511, 63, 521, 435, 6871, 8, 4515, 29, 21, 11466, 398, 291, 14, 5387, 14, 1457, 63, 12587, 63, 4456, 342, 398, 291, 14, 629, 8, 396, 63, 929, 12, 291, 14, 5387, 14, 4981, 14, 362, 8, 11846, 14, 13630, 63, 998, 680, 929, 9, 339, 347, 511, 63, 6505, 3316, 63, 262, 63, 74, 11474, 8, 277, 304, 267, 408, 774, 2909, 315, 653, 269, 3316, 2382, 314, 26668, 3181, 1133, 663, 315, 3089, 2626, 1041, 267, 291, 14, 5387, 14, 888, 14, 13331, 275, 14610, 14, 22, 267, 291, 14, 5387, 14, 888, 14, 13803, 275, 6155, 14, 24, 398, 1335, 11474, 275, 2197, 8, 9261, 12, 1227, 12, 413, 12, 10313, 29, 3583, 63, 1974, 14, 11288, 9, 398, 543, 3371, 360, 22799, 14, 7546, 14, 5394, 14, 3583, 63, 1974, 14, 10779, 297, 673, 372, 63, 585, 29, 74, 11474, 304, 288, 702, 3272, 63, 3173, 8, 277, 14, 5387, 12, 26668, 14, 7378, 12, 469, 355, 26668, 14, 7378, 26, 469, 11846, 14, 3103, 63, 37, 906, 54, 2594, 26, 378, 19575, 398, 1174, 275, 291, 14, 5387, 14, 4981, 14, 362, 8, 11846, 14, 13630, 63, 998, 9, 398, 702, 1174, 365, 440, 488, 267, 702, 26668, 14, 2184, 63, 322, 1044, 63, 5834, 8, 277, 14, 5387, 9, 508, 971, 288, 2197, 8, 9261, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
qwertyjune/BethSaidaBible
venv/lib/python2.7/site-packages/django/db/migrations/operations/special.py
44
5088
from __future__ import unicode_literals from .base import Operation class SeparateDatabaseAndState(Operation): """ Takes two lists of operations - ones that will be used for the database, and ones that will be used for the state change. This allows operations that don't support state change to have it applied, or have operations that affect the state or not the database, or so on. """ def __init__(self, database_operations=None, state_operations=None): self.database_operations = database_operations or [] self.state_operations = state_operations or [] def state_forwards(self, app_label, state): for state_operation in self.state_operations: state_operation.state_forwards(app_label, state) def database_forwards(self, app_label, schema_editor, from_state, to_state): # We calculate state separately in here since our state functions aren't useful for database_operation in self.database_operations: to_state = from_state.clone() database_operation.state_forwards(app_label, to_state) database_operation.database_forwards(app_label, schema_editor, from_state, to_state) from_state = to_state def database_backwards(self, app_label, schema_editor, from_state, to_state): # We calculate state separately in here since our state functions aren't useful base_state = to_state for pos, database_operation in enumerate(reversed(self.database_operations)): to_state = base_state.clone() for dbop in self.database_operations[:-(pos + 1)]: dbop.state_forwards(app_label, to_state) from_state = base_state.clone() database_operation.state_forwards(app_label, from_state) database_operation.database_backwards(app_label, schema_editor, from_state, to_state) def describe(self): return "Custom state/database change combination" class RunSQL(Operation): """ Runs some raw SQL. A reverse SQL statement may be provided. Also accepts a list of operations that represent the state change effected by this SQL change, in case it's custom column/table creation/deletion. """ def __init__(self, sql, reverse_sql=None, state_operations=None): self.sql = sql self.reverse_sql = reverse_sql self.state_operations = state_operations or [] @property def reversible(self): return self.reverse_sql is not None def state_forwards(self, app_label, state): for state_operation in self.state_operations: state_operation.state_forwards(app_label, state) def database_forwards(self, app_label, schema_editor, from_state, to_state): statements = schema_editor.connection.ops.prepare_sql_script(self.sql) for statement in statements: schema_editor.execute(statement, params=None) def database_backwards(self, app_label, schema_editor, from_state, to_state): if self.reverse_sql is None: raise NotImplementedError("You cannot reverse this operation") statements = schema_editor.connection.ops.prepare_sql_script(self.reverse_sql) for statement in statements: schema_editor.execute(statement, params=None) def describe(self): return "Raw SQL operation" class RunPython(Operation): """ Runs Python code in a context suitable for doing versioned ORM operations. """ reduces_to_sql = False def __init__(self, code, reverse_code=None, atomic=True): self.atomic = atomic # Forwards code if not callable(code): raise ValueError("RunPython must be supplied with a callable") self.code = code # Reverse code if reverse_code is None: self.reverse_code = None else: if not callable(reverse_code): raise ValueError("RunPython must be supplied with callable arguments") self.reverse_code = reverse_code @property def reversible(self): return self.reverse_code is not None def state_forwards(self, app_label, state): # RunPython objects have no state effect. To add some, combine this # with SeparateDatabaseAndState. pass def database_forwards(self, app_label, schema_editor, from_state, to_state): # We now execute the Python code in a context that contains a 'models' # object, representing the versioned models as an app registry. # We could try to override the global cache, but then people will still # use direct imports, so we go with a documentation approach instead. self.code(from_state.render(), schema_editor) def database_backwards(self, app_label, schema_editor, from_state, to_state): if self.reverse_code is None: raise NotImplementedError("You cannot reverse this operation") self.reverse_code(from_state.render(), schema_editor) def describe(self): return "Raw Python operation"
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1095, 492, 17954, 421, 199, 533, 27504, 323, 7243, 3325, 2223, 8, 6044, 304, 272, 408, 272, 17415, 2877, 5548, 402, 5331, 446, 7869, 626, 911, 506, 1202, 367, 314, 3050, 12, 272, 436, 7869, 626, 911, 506, 1202, 367, 314, 1174, 1570, 14, 961, 6127, 5331, 272, 626, 2793, 1133, 2291, 1174, 1570, 370, 1172, 652, 6781, 12, 503, 1172, 5331, 272, 626, 12787, 314, 1174, 503, 440, 314, 3050, 12, 503, 880, 641, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3050, 63, 8170, 29, 403, 12, 1174, 63, 8170, 29, 403, 304, 267, 291, 14, 4659, 63, 8170, 275, 3050, 63, 8170, 503, 942, 267, 291, 14, 929, 63, 8170, 275, 1174, 63, 8170, 503, 942, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 367, 1174, 63, 5735, 315, 291, 14, 929, 63, 8170, 26, 288, 1174, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 1174, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 327, 2136, 8671, 1174, 18159, 315, 2348, 3967, 4154, 1174, 3423, 10621, 1133, 2997, 267, 367, 3050, 63, 5735, 315, 291, 14, 4659, 63, 8170, 26, 288, 370, 63, 929, 275, 687, 63, 929, 14, 6311, 342, 288, 3050, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 370, 63, 929, 9, 288, 3050, 63, 5735, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 288, 687, 63, 929, 275, 370, 63, 929, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 327, 2136, 8671, 1174, 18159, 315, 2348, 3967, 4154, 1174, 3423, 10621, 1133, 2997, 267, 1300, 63, 929, 275, 370, 63, 929, 267, 367, 2086, 12, 3050, 63, 5735, 315, 3874, 8, 13501, 8, 277, 14, 4659, 63, 8170, 2298, 288, 370, 63, 929, 275, 1300, 63, 929, 14, 6311, 342, 288, 367, 1592, 411, 315, 291, 14, 4659, 63, 8170, 4439, 8, 1712, 435, 413, 19532, 355, 1592, 411, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 370, 63, 929, 9, 288, 687, 63, 929, 275, 1300, 63, 929, 14, 6311, 342, 288, 3050, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 687, 63, 929, 9, 288, 3050, 63, 5735, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 7223, 1174, 15, 4659, 1570, 14665, 2, 421, 199, 533, 3378, 4657, 8, 6044, 304, 272, 408, 272, 23773, 2005, 3066, 5385, 14, 437, 3837, 5385, 5164, 1443, 506, 2741, 14, 339, 6121, 11479, 282, 769, 402, 5331, 626, 2954, 314, 1174, 1570, 10783, 6201, 272, 701, 642, 5385, 1570, 12, 315, 1930, 652, 1159, 3537, 2763, 15, 1224, 7143, 15, 14281, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3875, 12, 3837, 63, 3009, 29, 403, 12, 1174, 63, 8170, 29, 403, 304, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 4471, 63, 3009, 275, 3837, 63, 3009, 267, 291, 14, 929, 63, 8170, 275, 1174, 63, 8170, 503, 942, 339, 768, 1829, 272, 347, 29465, 1164, 8, 277, 304, 267, 372, 291, 14, 4471, 63, 3009, 365, 440, 488, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 367, 1174, 63, 5735, 315, 291, 14, 929, 63, 8170, 26, 288, 1174, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 1174, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 9834, 275, 4177, 63, 7515, 14, 2105, 14, 1483, 14, 6726, 63, 3009, 63, 1579, 8, 277, 14, 3009, 9, 267, 367, 5164, 315, 9834, 26, 288, 4177, 63, 7515, 14, 2526, 8, 6242, 12, 1862, 29, 403, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 340, 291, 14, 4471, 63, 3009, 365, 488, 26, 288, 746, 4279, 480, 5556, 3913, 3837, 642, 3439, 531, 267, 9834, 275, 4177, 63, 7515, 14, 2105, 14, 1483, 14, 6726, 63, 3009, 63, 1579, 8, 277, 14, 4471, 63, 3009, 9, 267, 367, 5164, 315, 9834, 26, 288, 4177, 63, 7515, 14, 2526, 8, 6242, 12, 1862, 29, 403, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 7963, 5385, 3439, 2, 421, 199, 533, 3378, 4718, 8, 6044, 304, 272, 408, 272, 23773, 2018, 1233, 315, 282, 1067, 11233, 367, 9689, 31792, 23383, 5331, 14, 272, 408, 339, 295, 10569, 63, 475, 63, 3009, 275, 756, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 3837, 63, 600, 29, 403, 12, 15374, 29, 549, 304, 267, 291, 14, 10910, 275, 15374, 267, 327, 2104, 4751, 1233, 267, 340, 440, 4550, 8, 600, 304, 288, 746, 1722, 480, 2540, 4718, 1471, 506, 6841, 543, 282, 4550, 531, 267, 291, 14, 600, 275, 1233, 267, 327, 22734, 1233, 267, 340, 3837, 63, 600, 365, 488, 26, 288, 291, 14, 4471, 63, 600, 275, 488, 267, 587, 26, 288, 340, 440, 4550, 8, 4471, 63, 600, 304, 355, 746, 1722, 480, 2540, 4718, 1471, 506, 6841, 543, 4550, 2368, 531, 288, 291, 14, 4471, 63, 600, 275, 3837, 63, 600, 339, 768, 1829, 272, 347, 29465, 1164, 8, 277, 304, 267, 372, 291, 14, 4471, 63, 600, 365, 440, 488, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 327, 3378, 4718, 2251, 1172, 949, 1174, 7763, 14, 4005, 1050, 2005, 12, 13323, 642, 267, 327, 543, 27504, 323, 7243, 3325, 2223, 14, 267, 986, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1275, 1095, 492, 17954, 421, 199, 533, 27504, 323, 7243, 3325, 2223, 8, 6044, 304, 272, 408, 272, 17415, 2877, 5548, 402, 5331, 446, 7869, 626, 911, 506, 1202, 367, 314, 3050, 12, 272, 436, 7869, 626, 911, 506, 1202, 367, 314, 1174, 1570, 14, 961, 6127, 5331, 272, 626, 2793, 1133, 2291, 1174, 1570, 370, 1172, 652, 6781, 12, 503, 1172, 5331, 272, 626, 12787, 314, 1174, 503, 440, 314, 3050, 12, 503, 880, 641, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3050, 63, 8170, 29, 403, 12, 1174, 63, 8170, 29, 403, 304, 267, 291, 14, 4659, 63, 8170, 275, 3050, 63, 8170, 503, 942, 267, 291, 14, 929, 63, 8170, 275, 1174, 63, 8170, 503, 942, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 367, 1174, 63, 5735, 315, 291, 14, 929, 63, 8170, 26, 288, 1174, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 1174, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 327, 2136, 8671, 1174, 18159, 315, 2348, 3967, 4154, 1174, 3423, 10621, 1133, 2997, 267, 367, 3050, 63, 5735, 315, 291, 14, 4659, 63, 8170, 26, 288, 370, 63, 929, 275, 687, 63, 929, 14, 6311, 342, 288, 3050, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 370, 63, 929, 9, 288, 3050, 63, 5735, 14, 4659, 63, 19159, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 288, 687, 63, 929, 275, 370, 63, 929, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 327, 2136, 8671, 1174, 18159, 315, 2348, 3967, 4154, 1174, 3423, 10621, 1133, 2997, 267, 1300, 63, 929, 275, 370, 63, 929, 267, 367, 2086, 12, 3050, 63, 5735, 315, 3874, 8, 13501, 8, 277, 14, 4659, 63, 8170, 2298, 288, 370, 63, 929, 275, 1300, 63, 929, 14, 6311, 342, 288, 367, 1592, 411, 315, 291, 14, 4659, 63, 8170, 4439, 8, 1712, 435, 413, 19532, 355, 1592, 411, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 370, 63, 929, 9, 288, 687, 63, 929, 275, 1300, 63, 929, 14, 6311, 342, 288, 3050, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 687, 63, 929, 9, 288, 3050, 63, 5735, 14, 4659, 63, 22269, 8, 571, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 7223, 1174, 15, 4659, 1570, 14665, 2, 421, 199, 533, 3378, 4657, 8, 6044, 304, 272, 408, 272, 23773, 2005, 3066, 5385, 14, 437, 3837, 5385, 5164, 1443, 506, 2741, 14, 339, 6121, 11479, 282, 769, 402, 5331, 626, 2954, 314, 1174, 1570, 10783, 6201, 272, 701, 642, 5385, 1570, 12, 315, 1930, 652, 1159, 3537, 2763, 15, 1224, 7143, 15, 14281, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 3875, 12, 3837, 63, 3009, 29, 403, 12, 1174, 63, 8170, 29, 403, 304, 267, 291, 14, 3009, 275, 3875, 267, 291, 14, 4471, 63, 3009, 275, 3837, 63, 3009, 267, 291, 14, 929, 63, 8170, 275, 1174, 63, 8170, 503, 942, 339, 768, 1829, 272, 347, 29465, 1164, 8, 277, 304, 267, 372, 291, 14, 4471, 63, 3009, 365, 440, 488, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 367, 1174, 63, 5735, 315, 291, 14, 929, 63, 8170, 26, 288, 1174, 63, 5735, 14, 929, 63, 19159, 8, 571, 63, 1302, 12, 1174, 9, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 9834, 275, 4177, 63, 7515, 14, 2105, 14, 1483, 14, 6726, 63, 3009, 63, 1579, 8, 277, 14, 3009, 9, 267, 367, 5164, 315, 9834, 26, 288, 4177, 63, 7515, 14, 2526, 8, 6242, 12, 1862, 29, 403, 9, 339, 347, 3050, 63, 22269, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 304, 267, 340, 291, 14, 4471, 63, 3009, 365, 488, 26, 288, 746, 4279, 480, 5556, 3913, 3837, 642, 3439, 531, 267, 9834, 275, 4177, 63, 7515, 14, 2105, 14, 1483, 14, 6726, 63, 3009, 63, 1579, 8, 277, 14, 4471, 63, 3009, 9, 267, 367, 5164, 315, 9834, 26, 288, 4177, 63, 7515, 14, 2526, 8, 6242, 12, 1862, 29, 403, 9, 339, 347, 13743, 8, 277, 304, 267, 372, 298, 7963, 5385, 3439, 2, 421, 199, 533, 3378, 4718, 8, 6044, 304, 272, 408, 272, 23773, 2018, 1233, 315, 282, 1067, 11233, 367, 9689, 31792, 23383, 5331, 14, 272, 408, 339, 295, 10569, 63, 475, 63, 3009, 275, 756, 339, 347, 636, 826, 721, 277, 12, 1233, 12, 3837, 63, 600, 29, 403, 12, 15374, 29, 549, 304, 267, 291, 14, 10910, 275, 15374, 267, 327, 2104, 4751, 1233, 267, 340, 440, 4550, 8, 600, 304, 288, 746, 1722, 480, 2540, 4718, 1471, 506, 6841, 543, 282, 4550, 531, 267, 291, 14, 600, 275, 1233, 267, 327, 22734, 1233, 267, 340, 3837, 63, 600, 365, 488, 26, 288, 291, 14, 4471, 63, 600, 275, 488, 267, 587, 26, 288, 340, 440, 4550, 8, 4471, 63, 600, 304, 355, 746, 1722, 480, 2540, 4718, 1471, 506, 6841, 543, 4550, 2368, 531, 288, 291, 14, 4471, 63, 600, 275, 3837, 63, 600, 339, 768, 1829, 272, 347, 29465, 1164, 8, 277, 304, 267, 372, 291, 14, 4471, 63, 600, 365, 440, 488, 339, 347, 1174, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 1174, 304, 267, 327, 3378, 4718, 2251, 1172, 949, 1174, 7763, 14, 4005, 1050, 2005, 12, 13323, 642, 267, 327, 543, 27504, 323, 7243, 3325, 2223, 14, 267, 986, 339, 347, 3050, 63, 19159, 8, 277, 12, 1145, 63, 1302, 12, 4177, 63, 7515, 12, 687, 63, 929, 12, 370, 63, 929, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
tedi3231/openerp
openerp/addons/account_check_writing/wizard/account_check_batch_printing.py
54
3821
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.tools.translate import _ from openerp.osv import fields, osv class account_check_write(osv.osv_memory): _name = 'account.check.write' _description = 'Prin Check in Batch' _columns = { 'check_number': fields.integer('Next Check Number', required=True, help="The number of the next check number to be printed."), } def _get_next_number(self, cr, uid, context=None): dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number') return self.pool.get('ir.sequence').read(cr, uid, sequence_id, ['number_next'])['number_next'] _defaults = { 'check_number': _get_next_number, } def print_check_write(self, cr, uid, ids, context=None): if context is None: context = {} voucher_obj = self.pool.get('account.voucher') ir_sequence_obj = self.pool.get('ir.sequence') #update the sequence to number the checks from the value encoded in the wizard dummy, sequence_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_check_writing', 'sequence_check_number') increment = ir_sequence_obj.read(cr, uid, sequence_id, ['number_increment'])['number_increment'] new_value = self.browse(cr, uid, ids[0], context=context).check_number ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value}) #validate the checks so that they get a number voucher_ids = context.get('active_ids', []) for check in voucher_obj.browse(cr, uid, voucher_ids, context=context): new_value += increment if check.number: raise osv.except_osv(_('Error!'),_("One of the printed check already got a number.")) voucher_obj.proforma_voucher(cr, uid, voucher_ids, context=context) #update the sequence again (because the assignation using next_val was made during the same transaction of #the first update of sequence) ir_sequence_obj.write(cr, uid, sequence_id, {'number_next': new_value}) #print the checks check_layout_report = { 'top' : 'account.print.check.top', 'middle' : 'account.print.check.middle', 'bottom' : 'account.print.check.bottom', } check_layout = voucher_obj.browse(cr, uid, voucher_ids[0], context=context).company_id.check_layout if not check_layout: check_layout = 'top' return { 'type': 'ir.actions.report.xml', 'report_name':check_layout_report[check_layout], 'datas': { 'model':'account.voucher', 'ids': voucher_ids, 'report_type': 'pdf' }, 'nodestroy': True } account_check_write()
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 1074, 63, 952, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 2048, 14, 1074, 14, 952, 7, 272, 485, 1802, 275, 283, 9779, 262, 2670, 315, 17206, 7, 339, 485, 3406, 275, 469, 267, 283, 1074, 63, 1955, 356, 1504, 14, 4115, 360, 5765, 2670, 4860, 297, 1415, 29, 549, 12, 1720, 628, 1918, 1329, 402, 314, 2163, 1104, 1329, 370, 506, 12487, 7651, 272, 789, 339, 347, 485, 362, 63, 2184, 63, 1955, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 7283, 12, 3414, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 1074, 63, 14827, 297, 283, 4041, 63, 1074, 63, 1955, 358, 267, 372, 291, 14, 2293, 14, 362, 360, 723, 14, 4041, 1959, 739, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 788, 1955, 63, 2184, 1105, 459, 1955, 63, 2184, 418, 339, 485, 4322, 275, 469, 267, 283, 1074, 63, 1955, 356, 485, 362, 63, 2184, 63, 1955, 12, 2043, 789, 339, 347, 870, 63, 1074, 63, 952, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 17866, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 16637, 358, 267, 8190, 63, 4041, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 4041, 358, 398, 327, 873, 314, 3414, 370, 1329, 314, 5920, 687, 314, 574, 5737, 315, 314, 12262, 267, 7283, 12, 3414, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 1074, 63, 14827, 297, 283, 4041, 63, 1074, 63, 1955, 358, 267, 11609, 275, 8190, 63, 4041, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 788, 1955, 63, 9728, 1105, 459, 1955, 63, 9728, 418, 267, 892, 63, 585, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 680, 1074, 63, 1955, 267, 8190, 63, 4041, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 791, 1955, 63, 2184, 356, 892, 63, 585, 1552, 398, 327, 3502, 314, 5920, 880, 626, 2985, 664, 282, 1329, 267, 17866, 63, 1580, 275, 1067, 14, 362, 360, 2682, 63, 1580, 297, 3073, 267, 367, 1104, 315, 17866, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 12, 1067, 29, 1100, 304, 288, 892, 63, 585, 847, 11609, 288, 340, 1104, 14, 1955, 26, 355, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 14332, 4395, 402, 314, 12487, 1104, 2575, 4788, 282, 1329, 13853, 267, 17866, 63, 1113, 14, 496, 10928, 63, 16637, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 12, 1067, 29, 1100, 9, 398, 327, 873, 314, 3414, 4020, 334, 20684, 314, 5090, 425, 1808, 2163, 63, 637, 1990, 6326, 5309, 314, 2011, 6008, 402, 267, 327, 1589, 1642, 1678, 402, 3414, 9, 267, 8190, 63, 4041, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 791, 1955, 63, 2184, 356, 892, 63, 585, 1552, 398, 327, 1361, 314, 5920, 267, 1104, 63, 4209, 63, 3070, 275, 469, 288, 283, 2119, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 2119, 297, 288, 283, 14885, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 14885, 297, 288, 283, 8305, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 8305, 297, 267, 789, 267, 1104, 63, 4209, 275, 17866, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 59, 16, 467, 1067, 29, 1100, 680, 4627, 63, 344, 14, 1074, 63, 4209, 267, 340, 440, 1104, 63, 4209, 26, 288, 1104, 63, 4209, 275, 283, 2119, 7, 267, 372, 469, 288, 283, 466, 356, 283, 723, 14, 3723, 14, 3070, 14, 1652, 297, 7205, 283, 3070, 63, 354, 356, 1074, 63, 4209, 63, 3070, 59, 1074, 63, 4209, 467, 288, 283, 11563, 356, 469, 355, 283, 1238, 5242, 2048, 14, 16637, 297, 355, 283, 1580, 356, 17866, 63, 1580, 12, 355, 283, 3070, 63, 466, 356, 283, 5607, 7, 355, 1660, 288, 283, 932, 270, 4813, 356, 715, 288, 789, 199, 199, 2048, 63, 1074, 63, 952, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 199, 533, 2933, 63, 1074, 63, 952, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 2048, 14, 1074, 14, 952, 7, 272, 485, 1802, 275, 283, 9779, 262, 2670, 315, 17206, 7, 339, 485, 3406, 275, 469, 267, 283, 1074, 63, 1955, 356, 1504, 14, 4115, 360, 5765, 2670, 4860, 297, 1415, 29, 549, 12, 1720, 628, 1918, 1329, 402, 314, 2163, 1104, 1329, 370, 506, 12487, 7651, 272, 789, 339, 347, 485, 362, 63, 2184, 63, 1955, 8, 277, 12, 2467, 12, 1747, 12, 1067, 29, 403, 304, 267, 7283, 12, 3414, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 1074, 63, 14827, 297, 283, 4041, 63, 1074, 63, 1955, 358, 267, 372, 291, 14, 2293, 14, 362, 360, 723, 14, 4041, 1959, 739, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 788, 1955, 63, 2184, 1105, 459, 1955, 63, 2184, 418, 339, 485, 4322, 275, 469, 267, 283, 1074, 63, 1955, 356, 485, 362, 63, 2184, 63, 1955, 12, 2043, 789, 339, 347, 870, 63, 1074, 63, 952, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 267, 17866, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 16637, 358, 267, 8190, 63, 4041, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 4041, 358, 398, 327, 873, 314, 3414, 370, 1329, 314, 5920, 687, 314, 574, 5737, 315, 314, 12262, 267, 7283, 12, 3414, 63, 344, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 1959, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 63, 1074, 63, 14827, 297, 283, 4041, 63, 1074, 63, 1955, 358, 267, 11609, 275, 8190, 63, 4041, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 788, 1955, 63, 9728, 1105, 459, 1955, 63, 9728, 418, 267, 892, 63, 585, 275, 291, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 59, 16, 467, 1067, 29, 1100, 680, 1074, 63, 1955, 267, 8190, 63, 4041, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 791, 1955, 63, 2184, 356, 892, 63, 585, 1552, 398, 327, 3502, 314, 5920, 880, 626, 2985, 664, 282, 1329, 267, 17866, 63, 1580, 275, 1067, 14, 362, 360, 2682, 63, 1580, 297, 3073, 267, 367, 1104, 315, 17866, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 12, 1067, 29, 1100, 304, 288, 892, 63, 585, 847, 11609, 288, 340, 1104, 14, 1955, 26, 355, 746, 9506, 14, 2590, 63, 4795, 6723, 547, 15659, 14332, 4395, 402, 314, 12487, 1104, 2575, 4788, 282, 1329, 13853, 267, 17866, 63, 1113, 14, 496, 10928, 63, 16637, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 12, 1067, 29, 1100, 9, 398, 327, 873, 314, 3414, 4020, 334, 20684, 314, 5090, 425, 1808, 2163, 63, 637, 1990, 6326, 5309, 314, 2011, 6008, 402, 267, 327, 1589, 1642, 1678, 402, 3414, 9, 267, 8190, 63, 4041, 63, 1113, 14, 952, 8, 1556, 12, 1747, 12, 3414, 63, 344, 12, 791, 1955, 63, 2184, 356, 892, 63, 585, 1552, 398, 327, 1361, 314, 5920, 267, 1104, 63, 4209, 63, 3070, 275, 469, 288, 283, 2119, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 2119, 297, 288, 283, 14885, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 14885, 297, 288, 283, 8305, 7, 520, 283, 2048, 14, 1361, 14, 1074, 14, 8305, 297, 267, 789, 267, 1104, 63, 4209, 275, 17866, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 17866, 63, 1580, 59, 16, 467, 1067, 29, 1100, 680, 4627, 63, 344, 14, 1074, 63, 4209, 267, 340, 440, 1104, 63, 4209, 26, 288, 1104, 63, 4209, 275, 283, 2119, 7, 267, 372, 469, 288, 283, 466, 356, 283, 723, 14, 3723, 14, 3070, 14, 1652, 297, 7205, 283, 3070, 63, 354, 356, 1074, 63, 4209, 63, 3070, 59, 1074, 63, 4209, 467, 288, 283, 11563, 356, 469, 355, 283, 1238, 5242, 2048, 14, 16637, 297, 355, 283, 1580, 356, 17866, 63, 1580, 12, 355, 283, 3070, 63, 466, 356, 283, 5607, 7, 355, 1660, 288, 283, 932, 270, 4813, 356, 715, 288, 789, 199, 199, 2048, 63, 1074, 63, 952, 342, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
zorroz/microblog
flask/lib/python2.7/site-packages/setuptools/tests/test_resources.py
345
23973
#!/usr/bin/python # -*- coding: utf-8 -*- # NOTE: the shebang and encoding lines are for ScriptHeaderTests do not remove import os import sys import tempfile import shutil from unittest import TestCase import pkg_resources from pkg_resources import (parse_requirements, VersionConflict, parse_version, Distribution, EntryPoint, Requirement, safe_version, safe_name, WorkingSet) from setuptools.command.easy_install import (get_script_header, is_sh, nt_quote_arg) from setuptools.compat import StringIO, iteritems try: frozenset except NameError: from sets import ImmutableSet as frozenset def safe_repr(obj, short=False): """ copied from Python2.7""" try: result = repr(obj) except Exception: result = object.__repr__(obj) if not short or len(result) < pkg_resources._MAX_LENGTH: return result return result[:pkg_resources._MAX_LENGTH] + ' [truncated]...' class Metadata(pkg_resources.EmptyProvider): """Mock object to return metadata as if from an on-disk distribution""" def __init__(self,*pairs): self.metadata = dict(pairs) def has_metadata(self,name): return name in self.metadata def get_metadata(self,name): return self.metadata[name] def get_metadata_lines(self,name): return pkg_resources.yield_lines(self.get_metadata(name)) dist_from_fn = pkg_resources.Distribution.from_filename class DistroTests(TestCase): def testCollection(self): # empty path should produce no distributions ad = pkg_resources.Environment([], platform=None, python=None) self.assertEqual(list(ad), []) self.assertEqual(ad['FooPkg'],[]) ad.add(dist_from_fn("FooPkg-1.3_1.egg")) ad.add(dist_from_fn("FooPkg-1.4-py2.4-win32.egg")) ad.add(dist_from_fn("FooPkg-1.2-py2.4.egg")) # Name is in there now self.assertTrue(ad['FooPkg']) # But only 1 package self.assertEqual(list(ad), ['foopkg']) # Distributions sort by version self.assertEqual( [dist.version for dist in ad['FooPkg']], ['1.4','1.3-1','1.2'] ) # Removing a distribution leaves sequence alone ad.remove(ad['FooPkg'][1]) self.assertEqual( [dist.version for dist in ad['FooPkg']], ['1.4','1.2'] ) # And inserting adds them in order ad.add(dist_from_fn("FooPkg-1.9.egg")) self.assertEqual( [dist.version for dist in ad['FooPkg']], ['1.9','1.4','1.2'] ) ws = WorkingSet([]) foo12 = dist_from_fn("FooPkg-1.2-py2.4.egg") foo14 = dist_from_fn("FooPkg-1.4-py2.4-win32.egg") req, = parse_requirements("FooPkg>=1.3") # Nominal case: no distros on path, should yield all applicable self.assertEqual(ad.best_match(req,ws).version, '1.9') # If a matching distro is already installed, should return only that ws.add(foo14) self.assertEqual(ad.best_match(req,ws).version, '1.4') # If the first matching distro is unsuitable, it's a version conflict ws = WorkingSet([]) ws.add(foo12) ws.add(foo14) self.assertRaises(VersionConflict, ad.best_match, req, ws) # If more than one match on the path, the first one takes precedence ws = WorkingSet([]) ws.add(foo14) ws.add(foo12) ws.add(foo14) self.assertEqual(ad.best_match(req,ws).version, '1.4') def checkFooPkg(self,d): self.assertEqual(d.project_name, "FooPkg") self.assertEqual(d.key, "foopkg") self.assertEqual(d.version, "1.3-1") self.assertEqual(d.py_version, "2.4") self.assertEqual(d.platform, "win32") self.assertEqual(d.parsed_version, parse_version("1.3-1")) def testDistroBasics(self): d = Distribution( "/some/path", project_name="FooPkg",version="1.3-1",py_version="2.4",platform="win32" ) self.checkFooPkg(d) d = Distribution("/some/path") self.assertEqual(d.py_version, sys.version[:3]) self.assertEqual(d.platform, None) def testDistroParse(self): d = dist_from_fn("FooPkg-1.3_1-py2.4-win32.egg") self.checkFooPkg(d) d = dist_from_fn("FooPkg-1.3_1-py2.4-win32.egg-info") self.checkFooPkg(d) def testDistroMetadata(self): d = Distribution( "/some/path", project_name="FooPkg", py_version="2.4", platform="win32", metadata = Metadata( ('PKG-INFO',"Metadata-Version: 1.0\nVersion: 1.3-1\n") ) ) self.checkFooPkg(d) def distRequires(self, txt): return Distribution("/foo", metadata=Metadata(('depends.txt', txt))) def checkRequires(self, dist, txt, extras=()): self.assertEqual( list(dist.requires(extras)), list(parse_requirements(txt)) ) def testDistroDependsSimple(self): for v in "Twisted>=1.5", "Twisted>=1.5\nZConfig>=2.0": self.checkRequires(self.distRequires(v), v) def testResolve(self): ad = pkg_resources.Environment([]) ws = WorkingSet([]) # Resolving no requirements -> nothing to install self.assertEqual(list(ws.resolve([],ad)), []) # Request something not in the collection -> DistributionNotFound self.assertRaises( pkg_resources.DistributionNotFound, ws.resolve, parse_requirements("Foo"), ad ) Foo = Distribution.from_filename( "/foo_dir/Foo-1.2.egg", metadata=Metadata(('depends.txt', "[bar]\nBaz>=2.0")) ) ad.add(Foo) ad.add(Distribution.from_filename("Foo-0.9.egg")) # Request thing(s) that are available -> list to activate for i in range(3): targets = list(ws.resolve(parse_requirements("Foo"), ad)) self.assertEqual(targets, [Foo]) list(map(ws.add,targets)) self.assertRaises(VersionConflict, ws.resolve, parse_requirements("Foo==0.9"), ad) ws = WorkingSet([]) # reset # Request an extra that causes an unresolved dependency for "Baz" self.assertRaises( pkg_resources.DistributionNotFound, ws.resolve,parse_requirements("Foo[bar]"), ad ) Baz = Distribution.from_filename( "/foo_dir/Baz-2.1.egg", metadata=Metadata(('depends.txt', "Foo")) ) ad.add(Baz) # Activation list now includes resolved dependency self.assertEqual( list(ws.resolve(parse_requirements("Foo[bar]"), ad)), [Foo,Baz] ) # Requests for conflicting versions produce VersionConflict self.assertRaises(VersionConflict, ws.resolve, parse_requirements("Foo==1.2\nFoo!=1.2"), ad) def testDistroDependsOptions(self): d = self.distRequires(""" Twisted>=1.5 [docgen] ZConfig>=2.0 docutils>=0.3 [fastcgi] fcgiapp>=0.1""") self.checkRequires(d,"Twisted>=1.5") self.checkRequires( d,"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3".split(), ["docgen"] ) self.checkRequires( d,"Twisted>=1.5 fcgiapp>=0.1".split(), ["fastcgi"] ) self.checkRequires( d,"Twisted>=1.5 ZConfig>=2.0 docutils>=0.3 fcgiapp>=0.1".split(), ["docgen","fastcgi"] ) self.checkRequires( d,"Twisted>=1.5 fcgiapp>=0.1 ZConfig>=2.0 docutils>=0.3".split(), ["fastcgi", "docgen"] ) self.assertRaises(pkg_resources.UnknownExtra, d.requires, ["foo"]) class EntryPointTests(TestCase): def assertfields(self, ep): self.assertEqual(ep.name,"foo") self.assertEqual(ep.module_name,"setuptools.tests.test_resources") self.assertEqual(ep.attrs, ("EntryPointTests",)) self.assertEqual(ep.extras, ("x",)) self.assertTrue(ep.load() is EntryPointTests) self.assertEqual( str(ep), "foo = setuptools.tests.test_resources:EntryPointTests [x]" ) def setUp(self): self.dist = Distribution.from_filename( "FooPkg-1.2-py2.4.egg", metadata=Metadata(('requires.txt','[x]'))) def testBasics(self): ep = EntryPoint( "foo", "setuptools.tests.test_resources", ["EntryPointTests"], ["x"], self.dist ) self.assertfields(ep) def testParse(self): s = "foo = setuptools.tests.test_resources:EntryPointTests [x]" ep = EntryPoint.parse(s, self.dist) self.assertfields(ep) ep = EntryPoint.parse("bar baz= spammity[PING]") self.assertEqual(ep.name,"bar baz") self.assertEqual(ep.module_name,"spammity") self.assertEqual(ep.attrs, ()) self.assertEqual(ep.extras, ("ping",)) ep = EntryPoint.parse(" fizzly = wocka:foo") self.assertEqual(ep.name,"fizzly") self.assertEqual(ep.module_name,"wocka") self.assertEqual(ep.attrs, ("foo",)) self.assertEqual(ep.extras, ()) def testRejects(self): for ep in [ "foo", "x=1=2", "x=a:b:c", "q=x/na", "fez=pish:tush-z", "x=f[a]>2", ]: try: EntryPoint.parse(ep) except ValueError: pass else: raise AssertionError("Should've been bad", ep) def checkSubMap(self, m): self.assertEqual(len(m), len(self.submap_expect)) for key, ep in iteritems(self.submap_expect): self.assertEqual(repr(m.get(key)), repr(ep)) submap_expect = dict( feature1=EntryPoint('feature1', 'somemodule', ['somefunction']), feature2=EntryPoint('feature2', 'another.module', ['SomeClass'], ['extra1','extra2']), feature3=EntryPoint('feature3', 'this.module', extras=['something']) ) submap_str = """ # define features for blah blah feature1 = somemodule:somefunction feature2 = another.module:SomeClass [extra1,extra2] feature3 = this.module [something] """ def testParseList(self): self.checkSubMap(EntryPoint.parse_group("xyz", self.submap_str)) self.assertRaises(ValueError, EntryPoint.parse_group, "x a", "foo=bar") self.assertRaises(ValueError, EntryPoint.parse_group, "x", ["foo=baz", "foo=bar"]) def testParseMap(self): m = EntryPoint.parse_map({'xyz':self.submap_str}) self.checkSubMap(m['xyz']) self.assertEqual(list(m.keys()),['xyz']) m = EntryPoint.parse_map("[xyz]\n"+self.submap_str) self.checkSubMap(m['xyz']) self.assertEqual(list(m.keys()),['xyz']) self.assertRaises(ValueError, EntryPoint.parse_map, ["[xyz]", "[xyz]"]) self.assertRaises(ValueError, EntryPoint.parse_map, self.submap_str) class RequirementsTests(TestCase): def testBasics(self): r = Requirement.parse("Twisted>=1.2") self.assertEqual(str(r),"Twisted>=1.2") self.assertEqual(repr(r),"Requirement.parse('Twisted>=1.2')") self.assertEqual(r, Requirement("Twisted", [('>=','1.2')], ())) self.assertEqual(r, Requirement("twisTed", [('>=','1.2')], ())) self.assertNotEqual(r, Requirement("Twisted", [('>=','2.0')], ())) self.assertNotEqual(r, Requirement("Zope", [('>=','1.2')], ())) self.assertNotEqual(r, Requirement("Zope", [('>=','3.0')], ())) self.assertNotEqual(r, Requirement.parse("Twisted[extras]>=1.2")) def testOrdering(self): r1 = Requirement("Twisted", [('==','1.2c1'),('>=','1.2')], ()) r2 = Requirement("Twisted", [('>=','1.2'),('==','1.2c1')], ()) self.assertEqual(r1,r2) self.assertEqual(str(r1),str(r2)) self.assertEqual(str(r2),"Twisted==1.2c1,>=1.2") def testBasicContains(self): r = Requirement("Twisted", [('>=','1.2')], ()) foo_dist = Distribution.from_filename("FooPkg-1.3_1.egg") twist11 = Distribution.from_filename("Twisted-1.1.egg") twist12 = Distribution.from_filename("Twisted-1.2.egg") self.assertTrue(parse_version('1.2') in r) self.assertTrue(parse_version('1.1') not in r) self.assertTrue('1.2' in r) self.assertTrue('1.1' not in r) self.assertTrue(foo_dist not in r) self.assertTrue(twist11 not in r) self.assertTrue(twist12 in r) def testAdvancedContains(self): r, = parse_requirements("Foo>=1.2,<=1.3,==1.9,>2.0,!=2.5,<3.0,==4.5") for v in ('1.2','1.2.2','1.3','1.9','2.0.1','2.3','2.6','3.0c1','4.5'): self.assertTrue(v in r, (v,r)) for v in ('1.2c1','1.3.1','1.5','1.9.1','2.0','2.5','3.0','4.0'): self.assertTrue(v not in r, (v,r)) def testOptionsAndHashing(self): r1 = Requirement.parse("Twisted[foo,bar]>=1.2") r2 = Requirement.parse("Twisted[bar,FOO]>=1.2") r3 = Requirement.parse("Twisted[BAR,FOO]>=1.2.0") self.assertEqual(r1,r2) self.assertEqual(r1,r3) self.assertEqual(r1.extras, ("foo","bar")) self.assertEqual(r2.extras, ("bar","foo")) # extras are normalized self.assertEqual(hash(r1), hash(r2)) self.assertEqual( hash(r1), hash(("twisted", ((">=",parse_version("1.2")),), frozenset(["foo","bar"]))) ) def testVersionEquality(self): r1 = Requirement.parse("foo==0.3a2") r2 = Requirement.parse("foo!=0.3a4") d = Distribution.from_filename self.assertTrue(d("foo-0.3a4.egg") not in r1) self.assertTrue(d("foo-0.3a1.egg") not in r1) self.assertTrue(d("foo-0.3a4.egg") not in r2) self.assertTrue(d("foo-0.3a2.egg") in r1) self.assertTrue(d("foo-0.3a2.egg") in r2) self.assertTrue(d("foo-0.3a3.egg") in r2) self.assertTrue(d("foo-0.3a5.egg") in r2) def testSetuptoolsProjectName(self): """ The setuptools project should implement the setuptools package. """ self.assertEqual( Requirement.parse('setuptools').project_name, 'setuptools') # setuptools 0.7 and higher means setuptools. self.assertEqual( Requirement.parse('setuptools == 0.7').project_name, 'setuptools') self.assertEqual( Requirement.parse('setuptools == 0.7a1').project_name, 'setuptools') self.assertEqual( Requirement.parse('setuptools >= 0.7').project_name, 'setuptools') class ParseTests(TestCase): def testEmptyParse(self): self.assertEqual(list(parse_requirements('')), []) def testYielding(self): for inp,out in [ ([], []), ('x',['x']), ([[]],[]), (' x\n y', ['x','y']), (['x\n\n','y'], ['x','y']), ]: self.assertEqual(list(pkg_resources.yield_lines(inp)),out) def testSplitting(self): sample = """ x [Y] z a [b ] # foo c [ d] [q] v """ self.assertEqual(list(pkg_resources.split_sections(sample)), [(None,["x"]), ("Y",["z","a"]), ("b",["c"]), ("d",[]), ("q",["v"])] ) self.assertRaises(ValueError,list,pkg_resources.split_sections("[foo")) def testSafeName(self): self.assertEqual(safe_name("adns-python"), "adns-python") self.assertEqual(safe_name("WSGI Utils"), "WSGI-Utils") self.assertEqual(safe_name("WSGI Utils"), "WSGI-Utils") self.assertEqual(safe_name("Money$$$Maker"), "Money-Maker") self.assertNotEqual(safe_name("peak.web"), "peak-web") def testSafeVersion(self): self.assertEqual(safe_version("1.2-1"), "1.2-1") self.assertEqual(safe_version("1.2 alpha"), "1.2.alpha") self.assertEqual(safe_version("2.3.4 20050521"), "2.3.4.20050521") self.assertEqual(safe_version("Money$$$Maker"), "Money-Maker") self.assertEqual(safe_version("peak.web"), "peak.web") def testSimpleRequirements(self): self.assertEqual( list(parse_requirements('Twis-Ted>=1.2-1')), [Requirement('Twis-Ted',[('>=','1.2-1')], ())] ) self.assertEqual( list(parse_requirements('Twisted >=1.2, \ # more\n<2.0')), [Requirement('Twisted',[('>=','1.2'),('<','2.0')], ())] ) self.assertEqual( Requirement.parse("FooBar==1.99a3"), Requirement("FooBar", [('==','1.99a3')], ()) ) self.assertRaises(ValueError,Requirement.parse,">=2.3") self.assertRaises(ValueError,Requirement.parse,"x\\") self.assertRaises(ValueError,Requirement.parse,"x==2 q") self.assertRaises(ValueError,Requirement.parse,"X==1\nY==2") self.assertRaises(ValueError,Requirement.parse,"#") def testVersionEquality(self): def c(s1,s2): p1, p2 = parse_version(s1),parse_version(s2) self.assertEqual(p1,p2, (s1,s2,p1,p2)) c('1.2-rc1', '1.2rc1') c('0.4', '0.4.0') c('0.4.0.0', '0.4.0') c('0.4.0-0', '0.4-0') c('0pl1', '0.0pl1') c('0pre1', '0.0c1') c('0.0.0preview1', '0c1') c('0.0c1', '0-rc1') c('1.2a1', '1.2.a.1') c('1.2...a', '1.2a') def testVersionOrdering(self): def c(s1,s2): p1, p2 = parse_version(s1),parse_version(s2) self.assertTrue(p1<p2, (s1,s2,p1,p2)) c('2.1','2.1.1') c('2a1','2b0') c('2a1','2.1') c('2.3a1', '2.3') c('2.1-1', '2.1-2') c('2.1-1', '2.1.1') c('2.1', '2.1pl4') c('2.1a0-20040501', '2.1') c('1.1', '02.1') c('A56','B27') c('3.2', '3.2.pl0') c('3.2-1', '3.2pl1') c('3.2pl1', '3.2pl1-1') c('0.4', '4.0') c('0.0.4', '0.4.0') c('0pl1', '0.4pl1') c('2.1.0-rc1','2.1.0') c('2.1dev','2.1a0') torture =""" 0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1 0.79.9999+0.80.0pre2-3 0.79.9999+0.80.0pre2-2 0.77.2-1 0.77.1-1 0.77.0-1 """.split() for p,v1 in enumerate(torture): for v2 in torture[p+1:]: c(v2,v1) class ScriptHeaderTests(TestCase): non_ascii_exe = '/Users/José/bin/python' exe_with_spaces = r'C:\Program Files\Python33\python.exe' def test_get_script_header(self): if not sys.platform.startswith('java') or not is_sh(sys.executable): # This test is for non-Jython platforms expected = '#!%s\n' % nt_quote_arg(os.path.normpath(sys.executable)) self.assertEqual(get_script_header('#!/usr/local/bin/python'), expected) expected = '#!%s -x\n' % nt_quote_arg(os.path.normpath(sys.executable)) self.assertEqual(get_script_header('#!/usr/bin/python -x'), expected) self.assertEqual(get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe), '#!%s -x\n' % self.non_ascii_exe) candidate = get_script_header('#!/usr/bin/python', executable=self.exe_with_spaces) self.assertEqual(candidate, '#!"%s"\n' % self.exe_with_spaces) def test_get_script_header_jython_workaround(self): # This test doesn't work with Python 3 in some locales if (sys.version_info >= (3,) and os.environ.get("LC_CTYPE") in (None, "C", "POSIX")): return class java: class lang: class System: @staticmethod def getProperty(property): return "" sys.modules["java"] = java platform = sys.platform sys.platform = 'java1.5.0_13' stdout, stderr = sys.stdout, sys.stderr try: # A mock sys.executable that uses a shebang line (this file) exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py') self.assertEqual( get_script_header('#!/usr/local/bin/python', executable=exe), '#!/usr/bin/env %s\n' % exe) # Ensure we generate what is basically a broken shebang line # when there's options, with a warning emitted sys.stdout = sys.stderr = StringIO() self.assertEqual(get_script_header('#!/usr/bin/python -x', executable=exe), '#!%s -x\n' % exe) self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue()) sys.stdout = sys.stderr = StringIO() self.assertEqual(get_script_header('#!/usr/bin/python', executable=self.non_ascii_exe), '#!%s -x\n' % self.non_ascii_exe) self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue()) finally: del sys.modules["java"] sys.platform = platform sys.stdout, sys.stderr = stdout, stderr class NamespaceTests(TestCase): def setUp(self): self._ns_pkgs = pkg_resources._namespace_packages.copy() self._tmpdir = tempfile.mkdtemp(prefix="tests-setuptools-") os.makedirs(os.path.join(self._tmpdir, "site-pkgs")) self._prev_sys_path = sys.path[:] sys.path.append(os.path.join(self._tmpdir, "site-pkgs")) def tearDown(self): shutil.rmtree(self._tmpdir) pkg_resources._namespace_packages = self._ns_pkgs.copy() sys.path = self._prev_sys_path[:] def _assertIn(self, member, container): """ assertIn and assertTrue does not exist in Python2.3""" if member not in container: standardMsg = '%s not found in %s' % (safe_repr(member), safe_repr(container)) self.fail(self._formatMessage(msg, standardMsg)) def test_two_levels_deep(self): """ Test nested namespace packages Create namespace packages in the following tree : site-packages-1/pkg1/pkg2 site-packages-2/pkg1/pkg2 Check both are in the _namespace_packages dict and that their __path__ is correct """ sys.path.append(os.path.join(self._tmpdir, "site-pkgs2")) os.makedirs(os.path.join(self._tmpdir, "site-pkgs", "pkg1", "pkg2")) os.makedirs(os.path.join(self._tmpdir, "site-pkgs2", "pkg1", "pkg2")) ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" for site in ["site-pkgs", "site-pkgs2"]: pkg1_init = open(os.path.join(self._tmpdir, site, "pkg1", "__init__.py"), "w") pkg1_init.write(ns_str) pkg1_init.close() pkg2_init = open(os.path.join(self._tmpdir, site, "pkg1", "pkg2", "__init__.py"), "w") pkg2_init.write(ns_str) pkg2_init.close() import pkg1 self._assertIn("pkg1", pkg_resources._namespace_packages.keys()) try: import pkg1.pkg2 except ImportError: self.fail("Setuptools tried to import the parent namespace package") # check the _namespace_packages dict self._assertIn("pkg1.pkg2", pkg_resources._namespace_packages.keys()) self.assertEqual(pkg_resources._namespace_packages["pkg1"], ["pkg1.pkg2"]) # check the __path__ attribute contains both paths self.assertEqual(pkg1.pkg2.__path__, [ os.path.join(self._tmpdir, "site-pkgs", "pkg1", "pkg2"), os.path.join(self._tmpdir, "site-pkgs2", "pkg1", "pkg2")])
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6944, 26, 314, 25591, 436, 2644, 2385, 787, 367, 14914, 2567, 2925, 886, 440, 2813, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5549, 199, 646, 5145, 199, 504, 2882, 492, 7640, 199, 199, 646, 5496, 63, 4435, 199, 504, 5496, 63, 4435, 492, 334, 1122, 63, 7538, 12, 3394, 15919, 12, 2198, 63, 1023, 12, 272, 11839, 12, 11855, 3428, 12, 25013, 12, 5048, 63, 1023, 12, 5048, 63, 354, 12, 272, 9361, 316, 1084, 9, 199, 199, 504, 9116, 14, 1531, 14, 13581, 63, 3174, 492, 334, 362, 63, 1579, 63, 1291, 12, 365, 63, 609, 12, 272, 13377, 63, 3513, 63, 1273, 9, 199, 504, 9116, 14, 5819, 492, 5228, 12, 10849, 199, 199, 893, 26, 272, 9522, 199, 2590, 12746, 26, 272, 687, 5951, 492, 25609, 1084, 465, 9522, 199, 199, 318, 5048, 63, 2722, 8, 1113, 12, 3974, 29, 797, 304, 272, 408, 8876, 687, 2018, 18, 14, 23, 624, 272, 862, 26, 267, 754, 275, 4700, 8, 1113, 9, 272, 871, 2186, 26, 267, 754, 275, 909, 855, 2722, 721, 1113, 9, 272, 340, 440, 3974, 503, 822, 8, 1099, 9, 665, 5496, 63, 4435, 423, 4283, 63, 9127, 26, 267, 372, 754, 272, 372, 754, 1491, 4600, 63, 4435, 423, 4283, 63, 9127, 61, 435, 283, 359, 19347, 61, 13698, 199, 199, 533, 16160, 8, 4600, 63, 4435, 14, 4699, 6663, 304, 272, 408, 3346, 909, 370, 372, 3341, 465, 340, 687, 376, 641, 13, 4032, 4084, 624, 339, 347, 636, 826, 721, 277, 19166, 7322, 304, 267, 291, 14, 2343, 275, 1211, 8, 7322, 9, 339, 347, 965, 63, 2343, 8, 277, 12, 354, 304, 267, 372, 536, 315, 291, 14, 2343, 339, 347, 664, 63, 2343, 8, 277, 12, 354, 304, 267, 372, 291, 14, 2343, 59, 354, 61, 339, 347, 664, 63, 2343, 63, 1278, 8, 277, 12, 354, 304, 267, 372, 5496, 63, 4435, 14, 11481, 63, 1278, 8, 277, 14, 362, 63, 2343, 8, 354, 430, 199, 199, 2686, 63, 504, 63, 2324, 275, 5496, 63, 4435, 14, 8580, 14, 504, 63, 1501, 199, 199, 533, 10113, 293, 2925, 8, 1746, 304, 339, 347, 511, 7768, 8, 277, 304, 267, 327, 2701, 931, 1077, 7389, 949, 10208, 267, 1503, 275, 5496, 63, 4435, 14, 8263, 8798, 4298, 29, 403, 12, 2366, 29, 403, 9, 267, 291, 14, 629, 8, 513, 8, 350, 395, 3073, 267, 291, 14, 629, 8, 350, 459, 5686, 26878, 995, 59, 566, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 19, 63, 17, 14, 5799, 2237, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 20, 13, 647, 18, 14, 20, 13, 2676, 708, 14, 5799, 2237, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 18, 13, 647, 18, 14, 20, 14, 5799, 2237, 398, 327, 2812, 365, 315, 2337, 3063, 267, 291, 14, 1815, 8, 350, 459, 5686, 26878, 1105, 267, 327, 11017, 1454, 413, 2559, 267, 291, 14, 629, 8, 513, 8, 350, 395, 788, 545, 411, 9761, 1105, 398, 327, 577, 5414, 852, 4069, 701, 1015, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 20, 1673, 17, 14, 19, 13, 17, 1673, 17, 14, 18, 418, 267, 776, 267, 327, 29343, 282, 4084, 16733, 3414, 23016, 267, 1503, 14, 2168, 8, 350, 459, 5686, 26878, 3488, 17, 566, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 20, 1673, 17, 14, 18, 418, 267, 776, 267, 327, 6061, 28498, 9584, 3062, 315, 1865, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 25, 14, 5799, 2237, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 25, 1673, 17, 14, 20, 1673, 17, 14, 18, 418, 267, 776, 398, 10900, 275, 9361, 316, 1084, 4157, 267, 3925, 713, 275, 2917, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 18, 13, 647, 18, 14, 20, 14, 5799, 531, 267, 3925, 1079, 275, 2917, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 20, 13, 647, 18, 14, 20, 13, 2676, 708, 14, 5799, 531, 267, 2648, 12, 275, 2198, 63, 7538, 480, 5686, 26878, 8119, 17, 14, 19, 531, 398, 327, 653, 676, 1582, 1930, 26, 949, 2917, 4796, 641, 931, 12, 1077, 1995, 1006, 3964, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 25, 358, 267, 327, 982, 282, 4877, 20499, 365, 2575, 4903, 12, 1077, 372, 1454, 626, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 20, 358, 398, 327, 982, 314, 1642, 4877, 20499, 365, 625, 83, 10020, 12, 652, 1159, 282, 1015, 12395, 267, 10900, 275, 9361, 316, 1084, 4157, 267, 10900, 14, 525, 8, 1421, 713, 9, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 1855, 8, 3353, 15919, 12, 1503, 14, 7010, 63, 1431, 12, 2648, 12, 10900, 9, 398, 327, 982, 1655, 2419, 1373, 1336, 641, 314, 931, 12, 314, 1642, 1373, 6181, 13823, 267, 10900, 275, 9361, 316, 1084, 4157, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 10900, 14, 525, 8, 1421, 713, 9, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 20, 358, 339, 347, 1104, 5686, 26878, 8, 277, 12, 68, 304, 267, 291, 14, 629, 8, 68, 14, 1715, 63, 354, 12, 298, 5686, 26878, 531, 267, 291, 14, 629, 8, 68, 14, 498, 12, 298, 545, 411, 9761, 531, 267, 291, 14, 629, 8, 68, 14, 1023, 12, 298, 17 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 6944, 26, 314, 25591, 436, 2644, 2385, 787, 367, 14914, 2567, 2925, 886, 440, 2813, 199, 199, 646, 747, 199, 646, 984, 199, 646, 5549, 199, 646, 5145, 199, 504, 2882, 492, 7640, 199, 199, 646, 5496, 63, 4435, 199, 504, 5496, 63, 4435, 492, 334, 1122, 63, 7538, 12, 3394, 15919, 12, 2198, 63, 1023, 12, 272, 11839, 12, 11855, 3428, 12, 25013, 12, 5048, 63, 1023, 12, 5048, 63, 354, 12, 272, 9361, 316, 1084, 9, 199, 199, 504, 9116, 14, 1531, 14, 13581, 63, 3174, 492, 334, 362, 63, 1579, 63, 1291, 12, 365, 63, 609, 12, 272, 13377, 63, 3513, 63, 1273, 9, 199, 504, 9116, 14, 5819, 492, 5228, 12, 10849, 199, 199, 893, 26, 272, 9522, 199, 2590, 12746, 26, 272, 687, 5951, 492, 25609, 1084, 465, 9522, 199, 199, 318, 5048, 63, 2722, 8, 1113, 12, 3974, 29, 797, 304, 272, 408, 8876, 687, 2018, 18, 14, 23, 624, 272, 862, 26, 267, 754, 275, 4700, 8, 1113, 9, 272, 871, 2186, 26, 267, 754, 275, 909, 855, 2722, 721, 1113, 9, 272, 340, 440, 3974, 503, 822, 8, 1099, 9, 665, 5496, 63, 4435, 423, 4283, 63, 9127, 26, 267, 372, 754, 272, 372, 754, 1491, 4600, 63, 4435, 423, 4283, 63, 9127, 61, 435, 283, 359, 19347, 61, 13698, 199, 199, 533, 16160, 8, 4600, 63, 4435, 14, 4699, 6663, 304, 272, 408, 3346, 909, 370, 372, 3341, 465, 340, 687, 376, 641, 13, 4032, 4084, 624, 339, 347, 636, 826, 721, 277, 19166, 7322, 304, 267, 291, 14, 2343, 275, 1211, 8, 7322, 9, 339, 347, 965, 63, 2343, 8, 277, 12, 354, 304, 267, 372, 536, 315, 291, 14, 2343, 339, 347, 664, 63, 2343, 8, 277, 12, 354, 304, 267, 372, 291, 14, 2343, 59, 354, 61, 339, 347, 664, 63, 2343, 63, 1278, 8, 277, 12, 354, 304, 267, 372, 5496, 63, 4435, 14, 11481, 63, 1278, 8, 277, 14, 362, 63, 2343, 8, 354, 430, 199, 199, 2686, 63, 504, 63, 2324, 275, 5496, 63, 4435, 14, 8580, 14, 504, 63, 1501, 199, 199, 533, 10113, 293, 2925, 8, 1746, 304, 339, 347, 511, 7768, 8, 277, 304, 267, 327, 2701, 931, 1077, 7389, 949, 10208, 267, 1503, 275, 5496, 63, 4435, 14, 8263, 8798, 4298, 29, 403, 12, 2366, 29, 403, 9, 267, 291, 14, 629, 8, 513, 8, 350, 395, 3073, 267, 291, 14, 629, 8, 350, 459, 5686, 26878, 995, 59, 566, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 19, 63, 17, 14, 5799, 2237, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 20, 13, 647, 18, 14, 20, 13, 2676, 708, 14, 5799, 2237, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 18, 13, 647, 18, 14, 20, 14, 5799, 2237, 398, 327, 2812, 365, 315, 2337, 3063, 267, 291, 14, 1815, 8, 350, 459, 5686, 26878, 1105, 267, 327, 11017, 1454, 413, 2559, 267, 291, 14, 629, 8, 513, 8, 350, 395, 788, 545, 411, 9761, 1105, 398, 327, 577, 5414, 852, 4069, 701, 1015, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 20, 1673, 17, 14, 19, 13, 17, 1673, 17, 14, 18, 418, 267, 776, 267, 327, 29343, 282, 4084, 16733, 3414, 23016, 267, 1503, 14, 2168, 8, 350, 459, 5686, 26878, 3488, 17, 566, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 20, 1673, 17, 14, 18, 418, 267, 776, 267, 327, 6061, 28498, 9584, 3062, 315, 1865, 267, 1503, 14, 525, 8, 2686, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 25, 14, 5799, 2237, 267, 291, 14, 629, 8, 288, 359, 2686, 14, 1023, 367, 2917, 315, 1503, 459, 5686, 26878, 2157, 788, 17, 14, 25, 1673, 17, 14, 20, 1673, 17, 14, 18, 418, 267, 776, 398, 10900, 275, 9361, 316, 1084, 4157, 267, 3925, 713, 275, 2917, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 18, 13, 647, 18, 14, 20, 14, 5799, 531, 267, 3925, 1079, 275, 2917, 63, 504, 63, 2324, 480, 5686, 26878, 13, 17, 14, 20, 13, 647, 18, 14, 20, 13, 2676, 708, 14, 5799, 531, 267, 2648, 12, 275, 2198, 63, 7538, 480, 5686, 26878, 8119, 17, 14, 19, 531, 398, 327, 653, 676, 1582, 1930, 26, 949, 2917, 4796, 641, 931, 12, 1077, 1995, 1006, 3964, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 25, 358, 267, 327, 982, 282, 4877, 20499, 365, 2575, 4903, 12, 1077, 372, 1454, 626, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 20, 358, 398, 327, 982, 314, 1642, 4877, 20499, 365, 625, 83, 10020, 12, 652, 1159, 282, 1015, 12395, 267, 10900, 275, 9361, 316, 1084, 4157, 267, 10900, 14, 525, 8, 1421, 713, 9, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 1855, 8, 3353, 15919, 12, 1503, 14, 7010, 63, 1431, 12, 2648, 12, 10900, 9, 398, 327, 982, 1655, 2419, 1373, 1336, 641, 314, 931, 12, 314, 1642, 1373, 6181, 13823, 267, 10900, 275, 9361, 316, 1084, 4157, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 10900, 14, 525, 8, 1421, 713, 9, 267, 10900, 14, 525, 8, 1421, 1079, 9, 267, 291, 14, 629, 8, 350, 14, 7010, 63, 1431, 8, 2103, 12, 3569, 680, 1023, 12, 283, 17, 14, 20, 358, 339, 347, 1104, 5686, 26878, 8, 277, 12, 68, 304, 267, 291, 14, 629, 8, 68, 14, 1715, 63, 354, 12, 298, 5686, 26878, 531, 267, 291, 14, 629, 8, 68, 14, 498, 12, 298, 545, 411, 9761, 531, 267, 291, 14, 629, 8, 68, 14, 1023, 12, 298, 17, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jawatech/elisp4js
js/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py
1355
44604
# Copyright (c) 2013 Google Inc. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """cmake output module This module is under development and should be considered experimental. This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is created for each configuration. This module's original purpose was to support editing in IDEs like KDevelop which use CMake for project management. It is also possible to use CMake to generate projects for other IDEs such as eclipse cdt and code::blocks. QtCreator will convert the CMakeLists.txt to a code::blocks cbp for the editor to read, but build using CMake. As a result QtCreator editor is unaware of compiler defines. The generated CMakeLists.txt can also be used to build on Linux. There is currently no support for building on platforms other than Linux. The generated CMakeLists.txt should properly compile all projects. However, there is a mismatch between gyp and cmake with regard to linking. All attempts are made to work around this, but CMake sometimes sees -Wl,--start-group as a library and incorrectly repeats it. As a result the output of this generator should not be relied on for building. When using with kdevelop, use version 4.4+. Previous versions of kdevelop will not be able to find the header file directories described in the generated CMakeLists.txt file. """ import multiprocessing import os import signal import string import subprocess import gyp.common generator_default_variables = { 'EXECUTABLE_PREFIX': '', 'EXECUTABLE_SUFFIX': '', 'STATIC_LIB_PREFIX': 'lib', 'STATIC_LIB_SUFFIX': '.a', 'SHARED_LIB_PREFIX': 'lib', 'SHARED_LIB_SUFFIX': '.so', 'SHARED_LIB_DIR': '${builddir}/lib.${TOOLSET}', 'LIB_DIR': '${obj}.${TOOLSET}', 'INTERMEDIATE_DIR': '${obj}.${TOOLSET}/${TARGET}/geni', 'SHARED_INTERMEDIATE_DIR': '${obj}/gen', 'PRODUCT_DIR': '${builddir}', 'RULE_INPUT_PATH': '${RULE_INPUT_PATH}', 'RULE_INPUT_DIRNAME': '${RULE_INPUT_DIRNAME}', 'RULE_INPUT_NAME': '${RULE_INPUT_NAME}', 'RULE_INPUT_ROOT': '${RULE_INPUT_ROOT}', 'RULE_INPUT_EXT': '${RULE_INPUT_EXT}', 'CONFIGURATION_NAME': '${configuration}', } FULL_PATH_VARS = ('${CMAKE_CURRENT_LIST_DIR}', '${builddir}', '${obj}') generator_supports_multiple_toolsets = True generator_wants_static_library_dependencies_adjusted = True COMPILABLE_EXTENSIONS = { '.c': 'cc', '.cc': 'cxx', '.cpp': 'cxx', '.cxx': 'cxx', '.s': 's', # cc '.S': 's', # cc } def RemovePrefix(a, prefix): """Returns 'a' without 'prefix' if it starts with 'prefix'.""" return a[len(prefix):] if a.startswith(prefix) else a def CalculateVariables(default_variables, params): """Calculate additional variables for use in the build (called by gyp).""" default_variables.setdefault('OS', gyp.common.GetFlavor(params)) def Compilable(filename): """Return true if the file is compilable (should be in OBJS).""" return any(filename.endswith(e) for e in COMPILABLE_EXTENSIONS) def Linkable(filename): """Return true if the file is linkable (should be on the link line).""" return filename.endswith('.o') def NormjoinPathForceCMakeSource(base_path, rel_path): """Resolves rel_path against base_path and returns the result. If rel_path is an absolute path it is returned unchanged. Otherwise it is resolved against base_path and normalized. If the result is a relative path, it is forced to be relative to the CMakeLists.txt. """ if os.path.isabs(rel_path): return rel_path if any([rel_path.startswith(var) for var in FULL_PATH_VARS]): return rel_path # TODO: do we need to check base_path for absolute variables as well? return os.path.join('${CMAKE_CURRENT_LIST_DIR}', os.path.normpath(os.path.join(base_path, rel_path))) def NormjoinPath(base_path, rel_path): """Resolves rel_path against base_path and returns the result. TODO: what is this really used for? If rel_path begins with '$' it is returned unchanged. Otherwise it is resolved against base_path if relative, then normalized. """ if rel_path.startswith('$') and not rel_path.startswith('${configuration}'): return rel_path return os.path.normpath(os.path.join(base_path, rel_path)) def CMakeStringEscape(a): """Escapes the string 'a' for use inside a CMake string. This means escaping '\' otherwise it may be seen as modifying the next character '"' otherwise it will end the string ';' otherwise the string becomes a list The following do not need to be escaped '#' when the lexer is in string state, this does not start a comment The following are yet unknown '$' generator variables (like ${obj}) must not be escaped, but text $ should be escaped what is wanted is to know which $ come from generator variables """ return a.replace('\\', '\\\\').replace(';', '\\;').replace('"', '\\"') def SetFileProperty(output, source_name, property_name, values, sep): """Given a set of source file, sets the given property on them.""" output.write('set_source_files_properties(') output.write(source_name) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetFilesProperty(output, variable, property_name, values, sep): """Given a set of source files, sets the given property on them.""" output.write('set_source_files_properties(') WriteVariable(output, variable) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetTargetProperty(output, target_name, property_name, values, sep=''): """Given a target, sets the given property.""" output.write('set_target_properties(') output.write(target_name) output.write(' PROPERTIES ') output.write(property_name) output.write(' "') for value in values: output.write(CMakeStringEscape(value)) output.write(sep) output.write('")\n') def SetVariable(output, variable_name, value): """Sets a CMake variable.""" output.write('set(') output.write(variable_name) output.write(' "') output.write(CMakeStringEscape(value)) output.write('")\n') def SetVariableList(output, variable_name, values): """Sets a CMake variable to a list.""" if not values: return SetVariable(output, variable_name, "") if len(values) == 1: return SetVariable(output, variable_name, values[0]) output.write('list(APPEND ') output.write(variable_name) output.write('\n "') output.write('"\n "'.join([CMakeStringEscape(value) for value in values])) output.write('")\n') def UnsetVariable(output, variable_name): """Unsets a CMake variable.""" output.write('unset(') output.write(variable_name) output.write(')\n') def WriteVariable(output, variable_name, prepend=None): if prepend: output.write(prepend) output.write('${') output.write(variable_name) output.write('}') class CMakeTargetType(object): def __init__(self, command, modifier, property_modifier): self.command = command self.modifier = modifier self.property_modifier = property_modifier cmake_target_type_from_gyp_target_type = { 'executable': CMakeTargetType('add_executable', None, 'RUNTIME'), 'static_library': CMakeTargetType('add_library', 'STATIC', 'ARCHIVE'), 'shared_library': CMakeTargetType('add_library', 'SHARED', 'LIBRARY'), 'loadable_module': CMakeTargetType('add_library', 'MODULE', 'LIBRARY'), 'none': CMakeTargetType('add_custom_target', 'SOURCES', None), } def StringToCMakeTargetName(a): """Converts the given string 'a' to a valid CMake target name. All invalid characters are replaced by '_'. Invalid for cmake: ' ', '/', '(', ')', '"' Invalid for make: ':' Invalid for unknown reasons but cause failures: '.' """ return a.translate(string.maketrans(' /():."', '_______')) def WriteActions(target_name, actions, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'actions' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ for action in actions: action_name = StringToCMakeTargetName(action['action_name']) action_target_name = '%s__%s' % (target_name, action_name) inputs = action['inputs'] inputs_name = action_target_name + '__input' SetVariableList(output, inputs_name, [NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs]) outputs = action['outputs'] cmake_outputs = [NormjoinPathForceCMakeSource(path_to_gyp, out) for out in outputs] outputs_name = action_target_name + '__output' SetVariableList(output, outputs_name, cmake_outputs) # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir) if int(action.get('process_outputs_as_sources', False)): extra_sources.extend(zip(cmake_outputs, outputs)) # add_custom_command output.write('add_custom_command(OUTPUT ') WriteVariable(output, outputs_name) output.write('\n') if len(dirs) > 0: for directory in dirs: output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ') output.write(directory) output.write('\n') output.write(' COMMAND ') output.write(gyp.common.EncodePOSIXShellList(action['action'])) output.write('\n') output.write(' DEPENDS ') WriteVariable(output, inputs_name) output.write('\n') output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write(' COMMENT ') if 'message' in action: output.write(action['message']) else: output.write(action_target_name) output.write('\n') output.write(' VERBATIM\n') output.write(')\n') # add_custom_target output.write('add_custom_target(') output.write(action_target_name) output.write('\n DEPENDS ') WriteVariable(output, outputs_name) output.write('\n SOURCES ') WriteVariable(output, inputs_name) output.write('\n)\n') extra_deps.append(action_target_name) def NormjoinRulePathForceCMakeSource(base_path, rel_path, rule_source): if rel_path.startswith(("${RULE_INPUT_PATH}","${RULE_INPUT_DIRNAME}")): if any([rule_source.startswith(var) for var in FULL_PATH_VARS]): return rel_path return NormjoinPathForceCMakeSource(base_path, rel_path) def WriteRules(target_name, rules, extra_sources, extra_deps, path_to_gyp, output): """Write CMake for the 'rules' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_sources: [(<cmake_src>, <src>)] to append with generated source files. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ for rule in rules: rule_name = StringToCMakeTargetName(target_name + '__' + rule['rule_name']) inputs = rule.get('inputs', []) inputs_name = rule_name + '__input' SetVariableList(output, inputs_name, [NormjoinPathForceCMakeSource(path_to_gyp, dep) for dep in inputs]) outputs = rule['outputs'] var_outputs = [] for count, rule_source in enumerate(rule.get('rule_sources', [])): action_name = rule_name + '_' + str(count) rule_source_dirname, rule_source_basename = os.path.split(rule_source) rule_source_root, rule_source_ext = os.path.splitext(rule_source_basename) SetVariable(output, 'RULE_INPUT_PATH', rule_source) SetVariable(output, 'RULE_INPUT_DIRNAME', rule_source_dirname) SetVariable(output, 'RULE_INPUT_NAME', rule_source_basename) SetVariable(output, 'RULE_INPUT_ROOT', rule_source_root) SetVariable(output, 'RULE_INPUT_EXT', rule_source_ext) # Build up a list of outputs. # Collect the output dirs we'll need. dirs = set(dir for dir in (os.path.dirname(o) for o in outputs) if dir) # Create variables for the output, as 'local' variable will be unset. these_outputs = [] for output_index, out in enumerate(outputs): output_name = action_name + '_' + str(output_index) SetVariable(output, output_name, NormjoinRulePathForceCMakeSource(path_to_gyp, out, rule_source)) if int(rule.get('process_outputs_as_sources', False)): extra_sources.append(('${' + output_name + '}', out)) these_outputs.append('${' + output_name + '}') var_outputs.append('${' + output_name + '}') # add_custom_command output.write('add_custom_command(OUTPUT\n') for out in these_outputs: output.write(' ') output.write(out) output.write('\n') for directory in dirs: output.write(' COMMAND ${CMAKE_COMMAND} -E make_directory ') output.write(directory) output.write('\n') output.write(' COMMAND ') output.write(gyp.common.EncodePOSIXShellList(rule['action'])) output.write('\n') output.write(' DEPENDS ') WriteVariable(output, inputs_name) output.write(' ') output.write(NormjoinPath(path_to_gyp, rule_source)) output.write('\n') # CMAKE_CURRENT_LIST_DIR is where the CMakeLists.txt lives. # The cwd is the current build directory. output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write(' COMMENT ') if 'message' in rule: output.write(rule['message']) else: output.write(action_name) output.write('\n') output.write(' VERBATIM\n') output.write(')\n') UnsetVariable(output, 'RULE_INPUT_PATH') UnsetVariable(output, 'RULE_INPUT_DIRNAME') UnsetVariable(output, 'RULE_INPUT_NAME') UnsetVariable(output, 'RULE_INPUT_ROOT') UnsetVariable(output, 'RULE_INPUT_EXT') # add_custom_target output.write('add_custom_target(') output.write(rule_name) output.write(' DEPENDS\n') for out in var_outputs: output.write(' ') output.write(out) output.write('\n') output.write('SOURCES ') WriteVariable(output, inputs_name) output.write('\n') for rule_source in rule.get('rule_sources', []): output.write(' ') output.write(NormjoinPath(path_to_gyp, rule_source)) output.write('\n') output.write(')\n') extra_deps.append(rule_name) def WriteCopies(target_name, copies, extra_deps, path_to_gyp, output): """Write CMake for the 'copies' in the target. Args: target_name: the name of the CMake target being generated. actions: the Gyp 'actions' dict for this target. extra_deps: [<cmake_taget>] to append with generated targets. path_to_gyp: relative path from CMakeLists.txt being generated to the Gyp file in which the target being generated is defined. """ copy_name = target_name + '__copies' # CMake gets upset with custom targets with OUTPUT which specify no output. have_copies = any(copy['files'] for copy in copies) if not have_copies: output.write('add_custom_target(') output.write(copy_name) output.write(')\n') extra_deps.append(copy_name) return class Copy(object): def __init__(self, ext, command): self.cmake_inputs = [] self.cmake_outputs = [] self.gyp_inputs = [] self.gyp_outputs = [] self.ext = ext self.inputs_name = None self.outputs_name = None self.command = command file_copy = Copy('', 'copy') dir_copy = Copy('_dirs', 'copy_directory') for copy in copies: files = copy['files'] destination = copy['destination'] for src in files: path = os.path.normpath(src) basename = os.path.split(path)[1] dst = os.path.join(destination, basename) copy = file_copy if os.path.basename(src) else dir_copy copy.cmake_inputs.append(NormjoinPathForceCMakeSource(path_to_gyp, src)) copy.cmake_outputs.append(NormjoinPathForceCMakeSource(path_to_gyp, dst)) copy.gyp_inputs.append(src) copy.gyp_outputs.append(dst) for copy in (file_copy, dir_copy): if copy.cmake_inputs: copy.inputs_name = copy_name + '__input' + copy.ext SetVariableList(output, copy.inputs_name, copy.cmake_inputs) copy.outputs_name = copy_name + '__output' + copy.ext SetVariableList(output, copy.outputs_name, copy.cmake_outputs) # add_custom_command output.write('add_custom_command(\n') output.write('OUTPUT') for copy in (file_copy, dir_copy): if copy.outputs_name: WriteVariable(output, copy.outputs_name, ' ') output.write('\n') for copy in (file_copy, dir_copy): for src, dst in zip(copy.gyp_inputs, copy.gyp_outputs): # 'cmake -E copy src dst' will create the 'dst' directory if needed. output.write('COMMAND ${CMAKE_COMMAND} -E %s ' % copy.command) output.write(src) output.write(' ') output.write(dst) output.write("\n") output.write('DEPENDS') for copy in (file_copy, dir_copy): if copy.inputs_name: WriteVariable(output, copy.inputs_name, ' ') output.write('\n') output.write('WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/') output.write(path_to_gyp) output.write('\n') output.write('COMMENT Copying for ') output.write(target_name) output.write('\n') output.write('VERBATIM\n') output.write(')\n') # add_custom_target output.write('add_custom_target(') output.write(copy_name) output.write('\n DEPENDS') for copy in (file_copy, dir_copy): if copy.outputs_name: WriteVariable(output, copy.outputs_name, ' ') output.write('\n SOURCES') if file_copy.inputs_name: WriteVariable(output, file_copy.inputs_name, ' ') output.write('\n)\n') extra_deps.append(copy_name) def CreateCMakeTargetBaseName(qualified_target): """This is the name we would like the target to have.""" _, gyp_target_name, gyp_target_toolset = ( gyp.common.ParseQualifiedTarget(qualified_target)) cmake_target_base_name = gyp_target_name if gyp_target_toolset and gyp_target_toolset != 'target': cmake_target_base_name += '_' + gyp_target_toolset return StringToCMakeTargetName(cmake_target_base_name) def CreateCMakeTargetFullName(qualified_target): """An unambiguous name for the target.""" gyp_file, gyp_target_name, gyp_target_toolset = ( gyp.common.ParseQualifiedTarget(qualified_target)) cmake_target_full_name = gyp_file + ':' + gyp_target_name if gyp_target_toolset and gyp_target_toolset != 'target': cmake_target_full_name += '_' + gyp_target_toolset return StringToCMakeTargetName(cmake_target_full_name) class CMakeNamer(object): """Converts Gyp target names into CMake target names. CMake requires that target names be globally unique. One way to ensure this is to fully qualify the names of the targets. Unfortunatly, this ends up with all targets looking like "chrome_chrome_gyp_chrome" instead of just "chrome". If this generator were only interested in building, it would be possible to fully qualify all target names, then create unqualified target names which depend on all qualified targets which should have had that name. This is more or less what the 'make' generator does with aliases. However, one goal of this generator is to create CMake files for use with IDEs, and fully qualified names are not as user friendly. Since target name collision is rare, we do the above only when required. Toolset variants are always qualified from the base, as this is required for building. However, it also makes sense for an IDE, as it is possible for defines to be different. """ def __init__(self, target_list): self.cmake_target_base_names_conficting = set() cmake_target_base_names_seen = set() for qualified_target in target_list: cmake_target_base_name = CreateCMakeTargetBaseName(qualified_target) if cmake_target_base_name not in cmake_target_base_names_seen: cmake_target_base_names_seen.add(cmake_target_base_name) else: self.cmake_target_base_names_conficting.add(cmake_target_base_name) def CreateCMakeTargetName(self, qualified_target): base_name = CreateCMakeTargetBaseName(qualified_target) if base_name in self.cmake_target_base_names_conficting: return CreateCMakeTargetFullName(qualified_target) return base_name def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, options, generator_flags, all_qualified_targets, output): # The make generator does this always. # TODO: It would be nice to be able to tell CMake all dependencies. circular_libs = generator_flags.get('circular', True) if not generator_flags.get('standalone', False): output.write('\n#') output.write(qualified_target) output.write('\n') gyp_file, _, _ = gyp.common.ParseQualifiedTarget(qualified_target) rel_gyp_file = gyp.common.RelativePath(gyp_file, options.toplevel_dir) rel_gyp_dir = os.path.dirname(rel_gyp_file) # Relative path from build dir to top dir. build_to_top = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) # Relative path from build dir to gyp dir. build_to_gyp = os.path.join(build_to_top, rel_gyp_dir) path_from_cmakelists_to_gyp = build_to_gyp spec = target_dicts.get(qualified_target, {}) config = spec.get('configurations', {}).get(config_to_use, {}) target_name = spec.get('target_name', '<missing target name>') target_type = spec.get('type', '<missing target type>') target_toolset = spec.get('toolset') cmake_target_type = cmake_target_type_from_gyp_target_type.get(target_type) if cmake_target_type is None: print ('Target %s has unknown target type %s, skipping.' % ( target_name, target_type ) ) return SetVariable(output, 'TARGET', target_name) SetVariable(output, 'TOOLSET', target_toolset) cmake_target_name = namer.CreateCMakeTargetName(qualified_target) extra_sources = [] extra_deps = [] # Actions must come first, since they can generate more OBJs for use below. if 'actions' in spec: WriteActions(cmake_target_name, spec['actions'], extra_sources, extra_deps, path_from_cmakelists_to_gyp, output) # Rules must be early like actions. if 'rules' in spec: WriteRules(cmake_target_name, spec['rules'], extra_sources, extra_deps, path_from_cmakelists_to_gyp, output) # Copies if 'copies' in spec: WriteCopies(cmake_target_name, spec['copies'], extra_deps, path_from_cmakelists_to_gyp, output) # Target and sources srcs = spec.get('sources', []) # Gyp separates the sheep from the goats based on file extensions. # A full separation is done here because of flag handing (see below). s_sources = [] c_sources = [] cxx_sources = [] linkable_sources = [] other_sources = [] for src in srcs: _, ext = os.path.splitext(src) src_type = COMPILABLE_EXTENSIONS.get(ext, None) src_norm_path = NormjoinPath(path_from_cmakelists_to_gyp, src); if src_type == 's': s_sources.append(src_norm_path) elif src_type == 'cc': c_sources.append(src_norm_path) elif src_type == 'cxx': cxx_sources.append(src_norm_path) elif Linkable(ext): linkable_sources.append(src_norm_path) else: other_sources.append(src_norm_path) for extra_source in extra_sources: src, real_source = extra_source _, ext = os.path.splitext(real_source) src_type = COMPILABLE_EXTENSIONS.get(ext, None) if src_type == 's': s_sources.append(src) elif src_type == 'cc': c_sources.append(src) elif src_type == 'cxx': cxx_sources.append(src) elif Linkable(ext): linkable_sources.append(src) else: other_sources.append(src) s_sources_name = None if s_sources: s_sources_name = cmake_target_name + '__asm_srcs' SetVariableList(output, s_sources_name, s_sources) c_sources_name = None if c_sources: c_sources_name = cmake_target_name + '__c_srcs' SetVariableList(output, c_sources_name, c_sources) cxx_sources_name = None if cxx_sources: cxx_sources_name = cmake_target_name + '__cxx_srcs' SetVariableList(output, cxx_sources_name, cxx_sources) linkable_sources_name = None if linkable_sources: linkable_sources_name = cmake_target_name + '__linkable_srcs' SetVariableList(output, linkable_sources_name, linkable_sources) other_sources_name = None if other_sources: other_sources_name = cmake_target_name + '__other_srcs' SetVariableList(output, other_sources_name, other_sources) # CMake gets upset when executable targets provide no sources. # http://www.cmake.org/pipermail/cmake/2010-July/038461.html dummy_sources_name = None has_sources = (s_sources_name or c_sources_name or cxx_sources_name or linkable_sources_name or other_sources_name) if target_type == 'executable' and not has_sources: dummy_sources_name = cmake_target_name + '__dummy_srcs' SetVariable(output, dummy_sources_name, "${obj}.${TOOLSET}/${TARGET}/genc/dummy.c") output.write('if(NOT EXISTS "') WriteVariable(output, dummy_sources_name) output.write('")\n') output.write(' file(WRITE "') WriteVariable(output, dummy_sources_name) output.write('" "")\n') output.write("endif()\n") # CMake is opposed to setting linker directories and considers the practice # of setting linker directories dangerous. Instead, it favors the use of # find_library and passing absolute paths to target_link_libraries. # However, CMake does provide the command link_directories, which adds # link directories to targets defined after it is called. # As a result, link_directories must come before the target definition. # CMake unfortunately has no means of removing entries from LINK_DIRECTORIES. library_dirs = config.get('library_dirs') if library_dirs is not None: output.write('link_directories(') for library_dir in library_dirs: output.write(' ') output.write(NormjoinPath(path_from_cmakelists_to_gyp, library_dir)) output.write('\n') output.write(')\n') output.write(cmake_target_type.command) output.write('(') output.write(cmake_target_name) if cmake_target_type.modifier is not None: output.write(' ') output.write(cmake_target_type.modifier) if s_sources_name: WriteVariable(output, s_sources_name, ' ') if c_sources_name: WriteVariable(output, c_sources_name, ' ') if cxx_sources_name: WriteVariable(output, cxx_sources_name, ' ') if linkable_sources_name: WriteVariable(output, linkable_sources_name, ' ') if other_sources_name: WriteVariable(output, other_sources_name, ' ') if dummy_sources_name: WriteVariable(output, dummy_sources_name, ' ') output.write(')\n') # Let CMake know if the 'all' target should depend on this target. exclude_from_all = ('TRUE' if qualified_target not in all_qualified_targets else 'FALSE') SetTargetProperty(output, cmake_target_name, 'EXCLUDE_FROM_ALL', exclude_from_all) for extra_target_name in extra_deps: SetTargetProperty(output, extra_target_name, 'EXCLUDE_FROM_ALL', exclude_from_all) # Output name and location. if target_type != 'none': # Link as 'C' if there are no other files if not c_sources and not cxx_sources: SetTargetProperty(output, cmake_target_name, 'LINKER_LANGUAGE', ['C']) # Mark uncompiled sources as uncompiled. if other_sources_name: output.write('set_source_files_properties(') WriteVariable(output, other_sources_name, '') output.write(' PROPERTIES HEADER_FILE_ONLY "TRUE")\n') # Mark object sources as linkable. if linkable_sources_name: output.write('set_source_files_properties(') WriteVariable(output, other_sources_name, '') output.write(' PROPERTIES EXTERNAL_OBJECT "TRUE")\n') # Output directory target_output_directory = spec.get('product_dir') if target_output_directory is None: if target_type in ('executable', 'loadable_module'): target_output_directory = generator_default_variables['PRODUCT_DIR'] elif target_type == 'shared_library': target_output_directory = '${builddir}/lib.${TOOLSET}' elif spec.get('standalone_static_library', False): target_output_directory = generator_default_variables['PRODUCT_DIR'] else: base_path = gyp.common.RelativePath(os.path.dirname(gyp_file), options.toplevel_dir) target_output_directory = '${obj}.${TOOLSET}' target_output_directory = ( os.path.join(target_output_directory, base_path)) cmake_target_output_directory = NormjoinPathForceCMakeSource( path_from_cmakelists_to_gyp, target_output_directory) SetTargetProperty(output, cmake_target_name, cmake_target_type.property_modifier + '_OUTPUT_DIRECTORY', cmake_target_output_directory) # Output name default_product_prefix = '' default_product_name = target_name default_product_ext = '' if target_type == 'static_library': static_library_prefix = generator_default_variables['STATIC_LIB_PREFIX'] default_product_name = RemovePrefix(default_product_name, static_library_prefix) default_product_prefix = static_library_prefix default_product_ext = generator_default_variables['STATIC_LIB_SUFFIX'] elif target_type in ('loadable_module', 'shared_library'): shared_library_prefix = generator_default_variables['SHARED_LIB_PREFIX'] default_product_name = RemovePrefix(default_product_name, shared_library_prefix) default_product_prefix = shared_library_prefix default_product_ext = generator_default_variables['SHARED_LIB_SUFFIX'] elif target_type != 'executable': print ('ERROR: What output file should be generated?', 'type', target_type, 'target', target_name) product_prefix = spec.get('product_prefix', default_product_prefix) product_name = spec.get('product_name', default_product_name) product_ext = spec.get('product_extension') if product_ext: product_ext = '.' + product_ext else: product_ext = default_product_ext SetTargetProperty(output, cmake_target_name, 'PREFIX', product_prefix) SetTargetProperty(output, cmake_target_name, cmake_target_type.property_modifier + '_OUTPUT_NAME', product_name) SetTargetProperty(output, cmake_target_name, 'SUFFIX', product_ext) # Make the output of this target referenceable as a source. cmake_target_output_basename = product_prefix + product_name + product_ext cmake_target_output = os.path.join(cmake_target_output_directory, cmake_target_output_basename) SetFileProperty(output, cmake_target_output, 'GENERATED', ['TRUE'], '') # Includes includes = config.get('include_dirs') if includes: # This (target include directories) is what requires CMake 2.8.8 includes_name = cmake_target_name + '__include_dirs' SetVariableList(output, includes_name, [NormjoinPathForceCMakeSource(path_from_cmakelists_to_gyp, include) for include in includes]) output.write('set_property(TARGET ') output.write(cmake_target_name) output.write(' APPEND PROPERTY INCLUDE_DIRECTORIES ') WriteVariable(output, includes_name, '') output.write(')\n') # Defines defines = config.get('defines') if defines is not None: SetTargetProperty(output, cmake_target_name, 'COMPILE_DEFINITIONS', defines, ';') # Compile Flags - http://www.cmake.org/Bug/view.php?id=6493 # CMake currently does not have target C and CXX flags. # So, instead of doing... # cflags_c = config.get('cflags_c') # if cflags_c is not None: # SetTargetProperty(output, cmake_target_name, # 'C_COMPILE_FLAGS', cflags_c, ' ') # cflags_cc = config.get('cflags_cc') # if cflags_cc is not None: # SetTargetProperty(output, cmake_target_name, # 'CXX_COMPILE_FLAGS', cflags_cc, ' ') # Instead we must... cflags = config.get('cflags', []) cflags_c = config.get('cflags_c', []) cflags_cxx = config.get('cflags_cc', []) if (not cflags_c or not c_sources) and (not cflags_cxx or not cxx_sources): SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', cflags, ' ') elif c_sources and not (s_sources or cxx_sources): flags = [] flags.extend(cflags) flags.extend(cflags_c) SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ') elif cxx_sources and not (s_sources or c_sources): flags = [] flags.extend(cflags) flags.extend(cflags_cxx) SetTargetProperty(output, cmake_target_name, 'COMPILE_FLAGS', flags, ' ') else: # TODO: This is broken, one cannot generally set properties on files, # as other targets may require different properties on the same files. if s_sources and cflags: SetFilesProperty(output, s_sources_name, 'COMPILE_FLAGS', cflags, ' ') if c_sources and (cflags or cflags_c): flags = [] flags.extend(cflags) flags.extend(cflags_c) SetFilesProperty(output, c_sources_name, 'COMPILE_FLAGS', flags, ' ') if cxx_sources and (cflags or cflags_cxx): flags = [] flags.extend(cflags) flags.extend(cflags_cxx) SetFilesProperty(output, cxx_sources_name, 'COMPILE_FLAGS', flags, ' ') # Linker flags ldflags = config.get('ldflags') if ldflags is not None: SetTargetProperty(output, cmake_target_name, 'LINK_FLAGS', ldflags, ' ') # Note on Dependencies and Libraries: # CMake wants to handle link order, resolving the link line up front. # Gyp does not retain or enforce specifying enough information to do so. # So do as other gyp generators and use --start-group and --end-group. # Give CMake as little information as possible so that it doesn't mess it up. # Dependencies rawDeps = spec.get('dependencies', []) static_deps = [] shared_deps = [] other_deps = [] for rawDep in rawDeps: dep_cmake_name = namer.CreateCMakeTargetName(rawDep) dep_spec = target_dicts.get(rawDep, {}) dep_target_type = dep_spec.get('type', None) if dep_target_type == 'static_library': static_deps.append(dep_cmake_name) elif dep_target_type == 'shared_library': shared_deps.append(dep_cmake_name) else: other_deps.append(dep_cmake_name) # ensure all external dependencies are complete before internal dependencies # extra_deps currently only depend on their own deps, so otherwise run early if static_deps or shared_deps or other_deps: for extra_dep in extra_deps: output.write('add_dependencies(') output.write(extra_dep) output.write('\n') for deps in (static_deps, shared_deps, other_deps): for dep in gyp.common.uniquer(deps): output.write(' ') output.write(dep) output.write('\n') output.write(')\n') linkable = target_type in ('executable', 'loadable_module', 'shared_library') other_deps.extend(extra_deps) if other_deps or (not linkable and (static_deps or shared_deps)): output.write('add_dependencies(') output.write(cmake_target_name) output.write('\n') for dep in gyp.common.uniquer(other_deps): output.write(' ') output.write(dep) output.write('\n') if not linkable: for deps in (static_deps, shared_deps): for lib_dep in gyp.common.uniquer(deps): output.write(' ') output.write(lib_dep) output.write('\n') output.write(')\n') # Libraries if linkable: external_libs = [lib for lib in spec.get('libraries', []) if len(lib) > 0] if external_libs or static_deps or shared_deps: output.write('target_link_libraries(') output.write(cmake_target_name) output.write('\n') if static_deps: write_group = circular_libs and len(static_deps) > 1 if write_group: output.write('-Wl,--start-group\n') for dep in gyp.common.uniquer(static_deps): output.write(' ') output.write(dep) output.write('\n') if write_group: output.write('-Wl,--end-group\n') if shared_deps: for dep in gyp.common.uniquer(shared_deps): output.write(' ') output.write(dep) output.write('\n') if external_libs: for lib in gyp.common.uniquer(external_libs): output.write(' ') output.write(lib) output.write('\n') output.write(')\n') UnsetVariable(output, 'TOOLSET') UnsetVariable(output, 'TARGET') def GenerateOutputForConfig(target_list, target_dicts, data, params, config_to_use): options = params['options'] generator_flags = params['generator_flags'] # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to cmake easier, cmake doesn't put anything here. # Each Gyp configuration creates a different CMakeLists.txt file # to avoid incompatibilities between Gyp and CMake configurations. generator_dir = os.path.relpath(options.generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = generator_flags.get('output_dir', 'out') # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath(os.path.join(generator_dir, output_dir, config_to_use)) toplevel_build = os.path.join(options.toplevel_dir, build_dir) output_file = os.path.join(toplevel_build, 'CMakeLists.txt') gyp.common.EnsureDirExists(output_file) output = open(output_file, 'w') output.write('cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)\n') output.write('cmake_policy(VERSION 2.8.8)\n') gyp_file, project_target, _ = gyp.common.ParseQualifiedTarget(target_list[-1]) output.write('project(') output.write(project_target) output.write(')\n') SetVariable(output, 'configuration', config_to_use) ar = None cc = None cxx = None make_global_settings = data[gyp_file].get('make_global_settings', []) build_to_top = gyp.common.InvertRelativePath(build_dir, options.toplevel_dir) for key, value in make_global_settings: if key == 'AR': ar = os.path.join(build_to_top, value) if key == 'CC': cc = os.path.join(build_to_top, value) if key == 'CXX': cxx = os.path.join(build_to_top, value) ar = gyp.common.GetEnvironFallback(['AR_target', 'AR'], ar) cc = gyp.common.GetEnvironFallback(['CC_target', 'CC'], cc) cxx = gyp.common.GetEnvironFallback(['CXX_target', 'CXX'], cxx) if ar: SetVariable(output, 'CMAKE_AR', ar) if cc: SetVariable(output, 'CMAKE_C_COMPILER', cc) if cxx: SetVariable(output, 'CMAKE_CXX_COMPILER', cxx) # The following appears to be as-yet undocumented. # http://public.kitware.com/Bug/view.php?id=8392 output.write('enable_language(ASM)\n') # ASM-ATT does not support .S files. # output.write('enable_language(ASM-ATT)\n') if cc: SetVariable(output, 'CMAKE_ASM_COMPILER', cc) SetVariable(output, 'builddir', '${CMAKE_CURRENT_BINARY_DIR}') SetVariable(output, 'obj', '${builddir}/obj') output.write('\n') # TODO: Undocumented/unsupported (the CMake Java generator depends on it). # CMake by default names the object resulting from foo.c to be foo.c.o. # Gyp traditionally names the object resulting from foo.c foo.o. # This should be irrelevant, but some targets extract .o files from .a # and depend on the name of the extracted .o files. output.write('set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)\n') output.write('set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)\n') output.write('\n') # Force ninja to use rsp files. Otherwise link and ar lines can get too long, # resulting in 'Argument list too long' errors. output.write('set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)\n') output.write('\n') namer = CMakeNamer(target_list) # The list of targets upon which the 'all' target should depend. # CMake has it's own implicit 'all' target, one is not created explicitly. all_qualified_targets = set() for build_file in params['build_files']: for qualified_target in gyp.common.AllTargets(target_list, target_dicts, os.path.normpath(build_file)): all_qualified_targets.add(qualified_target) for qualified_target in target_list: WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, options, generator_flags, all_qualified_targets, output) output.close() def PerformBuild(data, configurations, params): options = params['options'] generator_flags = params['generator_flags'] # generator_dir: relative path from pwd to where make puts build files. # Makes migrating from make to cmake easier, cmake doesn't put anything here. generator_dir = os.path.relpath(options.generator_output or '.') # output_dir: relative path from generator_dir to the build directory. output_dir = generator_flags.get('output_dir', 'out') for config_name in configurations: # build_dir: relative path from source root to our output files. # e.g. "out/Debug" build_dir = os.path.normpath(os.path.join(generator_dir, output_dir, config_name)) arguments = ['cmake', '-G', 'Ninja'] print 'Generating [%s]: %s' % (config_name, arguments) subprocess.check_call(arguments, cwd=build_dir) arguments = ['ninja', '-C', build_dir] print 'Building [%s]: %s' % (config_name, arguments) subprocess.check_call(arguments) def CallGenerateOutputForConfig(arglist): # Ignore the interrupt signal so that the parent process catches it and # kills all multiprocessing children. signal.signal(signal.SIGINT, signal.SIG_IGN) target_list, target_dicts, data, params, config_name = arglist GenerateOutputForConfig(target_list, target_dicts, data, params, config_name) def GenerateOutput(target_list, target_dicts, data, params): user_config = params.get('generator_flags', {}).get('config', None) if user_config: GenerateOutputForConfig(target_list, target_dicts, data, params, user_config) else: config_names = target_dicts[target_list[0]]['configurations'].keys() if params['parallel']: try: pool = multiprocessing.Pool(len(config_names)) arglists = [] for config_name in config_names: arglists.append((target_list, target_dicts, data, params, config_name)) pool.map(CallGenerateOutputForConfig, arglists) except KeyboardInterrupt, e: pool.terminate() raise e else: for config_name in config_names: GenerateOutputForConfig(target_list, target_dicts, data, params, config_name)
apache-2.0
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 16472, 1072, 859, 199, 199, 2765, 859, 365, 1334, 16367, 436, 1077, 506, 8652, 22820, 14, 199, 199, 2765, 859, 16904, 19773, 334, 18, 14, 24, 14, 24, 8771, 1324, 465, 2399, 1072, 14, 7309, 21355, 15116, 14, 2424, 365, 199, 3966, 367, 1924, 2897, 14, 199, 199, 2765, 859, 1159, 3379, 12016, 1990, 370, 2291, 20401, 315, 473, 1093, 83, 2839, 1804, 872, 7549, 199, 6777, 675, 21355, 367, 2199, 10041, 14, 2779, 365, 2597, 3962, 370, 675, 21355, 370, 199, 4208, 11336, 367, 1163, 473, 1093, 83, 4066, 465, 325, 7548, 261, 286, 3583, 436, 1233, 447, 4166, 14, 3959, 17523, 199, 14117, 3957, 314, 21355, 15116, 14, 2424, 370, 282, 1233, 447, 4166, 7434, 80, 367, 314, 8823, 370, 1586, 12, 199, 7911, 1900, 1808, 21355, 14, 3709, 282, 754, 3959, 17523, 8823, 365, 625, 14600, 402, 6365, 199, 14334, 14, 710, 4046, 21355, 15116, 14, 2424, 883, 2597, 506, 1202, 370, 1900, 641, 10130, 14, 6006, 199, 374, 5544, 949, 2291, 367, 10015, 641, 10677, 1163, 2419, 10130, 14, 199, 199, 1918, 4046, 21355, 15116, 14, 2424, 1077, 7684, 6555, 1006, 11336, 14, 9738, 12, 199, 16990, 365, 282, 15015, 3382, 4902, 436, 19773, 543, 8794, 370, 25833, 14, 2900, 12454, 199, 1530, 6326, 370, 1736, 6818, 642, 12, 1325, 21355, 15026, 542, 397, 446, 16239, 28925, 928, 13, 923, 465, 282, 199, 4342, 436, 22743, 28908, 652, 14, 3709, 282, 754, 314, 1072, 402, 642, 4306, 199, 5626, 440, 506, 295, 1857, 641, 367, 10015, 14, 199, 199, 11423, 1808, 543, 1022, 32176, 12, 675, 1015, 841, 14, 20, 26240, 26902, 5459, 402, 1022, 32176, 911, 199, 1397, 506, 7688, 370, 2342, 314, 1406, 570, 6602, 11736, 315, 314, 4046, 199, 27984, 15116, 14, 2424, 570, 14, 199, 624, 199, 199, 646, 12866, 199, 646, 747, 199, 646, 4673, 199, 646, 1059, 199, 646, 3873, 199, 646, 4902, 14, 2330, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 13772, 63, 5617, 63, 3022, 356, 20044, 21728, 5995, 773, 14, 10545, 16892, 7293, 523, 283, 5617, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 7293, 523, 283, 23227, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 5995, 10545, 9268, 5995, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 20044, 1113, 5995, 2268, 297, 523, 283, 14853, 63, 3022, 356, 20044, 21728, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 13578, 63, 7321, 63, 3243, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 13578, 63, 7321, 63, 3022, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 13578, 63, 7321, 63, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 13578, 63, 7321, 63, 5441, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 13578, 63, 7321, 63, 2472, 7293, 523, 283, 22212, 63, 2339, 356, 20044, 4758, 7293, 199, 93, 199, 199, 14742, 63, 3243, 63, 21367, 275, 661, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 20044, 21728, 7293, 20044, 1113, 12216, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 4679, 63, 28789, 63, 1986, 63, 4342, 63, 5714, 63, 23395, 275, 715, 199, 199, 6790, 1193, 2617, 63, 18451, 275, 469, 523, 1987, 67, 356, 283, 2055, 297, 523, 1987, 2055, 356, 283, 9634, 297, 523, 1987, 5910, 356, 283, 9634, 297, 523, 1987, 9634, 356, 283, 9634, 297, 523, 1987, 83, 356, 283, 83, 297, 327, 7429, 523, 1987, 51, 356, 283, 83, 297, 327, 7429, 199, 93, 421, 199, 318, 5852, 4793, 8, 65, 12, 2403, 304, 523, 408, 3407, 283, 65, 7, 1928, 283, 1861, 7, 340, 652, 9174, 543, 283, 1861, 23690, 523, 372, 282, 59, 552, 8, 1861, 15405, 340, 282, 14, 2460, 8, 1861, 9, 587, 282, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 849, 63, 3669, 14, 5486, 360, 3100, 297, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 430, 421, 199, 318, 3599, 382, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 1013, 382, 461, 334, 5626, 506, 315, 28652, 11378, 10477, 523, 372, 1263, 8, 1501, 14, 4130, 8, 69, 9, 367, 325, 315, 16503, 1193, 2617, 63, 18451, 9, 421, 199, 318, 10967, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 30258, 334, 5626, 506, 641, 314, 2142, 1004, 10477, 523, 372, 1788, 14, 4130, 5175, 79, 358, 421, 199, 318, 20800, 904, 2042, 13606, 27984, 2980, 8, 1095, 63, 515, 12, 4668, 63, 515, 304, 523, 408, 1322, 393, 2310, 4668, 63, 515, 6169, 1300, 63, 515, 436, 2529, 314, 754, 14, 819, 982, 4668, 63, 515, 365, 376, 3679, 931, 652, 365, 2138, 14874, 14, 523, 6630, 652, 365, 12152, 6169, 1300, 63, 515, 436, 9657, 14, 523, 982, 314, 754, 365, 282, 3847, 931, 12, 652, 365, 19565, 370, 506, 3847, 370, 314, 523, 21355, 15116, 14, 2424, 14, 523, 408, 523, 340, 747, 14, 515, 14, 17896, 8, 3369, 63, 515, 304, 272, 372, 4668, 63, 515, 523, 340, 1263, 779, 3369, 63, 515, 14, 2460, 8, 1391, 9, 367, 2729, 315, 18530, 63, 3243, 63, 21367, 4682, 272, 372, 4668, 63, 515, 523, 327, 3254, 26, 886, 781, 1929, 370, 1104, 1300, 63, 515, 367, 3679, 2860, 465, 5521, 31, 523, 372, 747, 14, 515, 14, 904, 360, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 1993, 747, 14, 515, 14, 9267 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 16472, 1072, 859, 199, 199, 2765, 859, 365, 1334, 16367, 436, 1077, 506, 8652, 22820, 14, 199, 199, 2765, 859, 16904, 19773, 334, 18, 14, 24, 14, 24, 8771, 1324, 465, 2399, 1072, 14, 7309, 21355, 15116, 14, 2424, 365, 199, 3966, 367, 1924, 2897, 14, 199, 199, 2765, 859, 1159, 3379, 12016, 1990, 370, 2291, 20401, 315, 473, 1093, 83, 2839, 1804, 872, 7549, 199, 6777, 675, 21355, 367, 2199, 10041, 14, 2779, 365, 2597, 3962, 370, 675, 21355, 370, 199, 4208, 11336, 367, 1163, 473, 1093, 83, 4066, 465, 325, 7548, 261, 286, 3583, 436, 1233, 447, 4166, 14, 3959, 17523, 199, 14117, 3957, 314, 21355, 15116, 14, 2424, 370, 282, 1233, 447, 4166, 7434, 80, 367, 314, 8823, 370, 1586, 12, 199, 7911, 1900, 1808, 21355, 14, 3709, 282, 754, 3959, 17523, 8823, 365, 625, 14600, 402, 6365, 199, 14334, 14, 710, 4046, 21355, 15116, 14, 2424, 883, 2597, 506, 1202, 370, 1900, 641, 10130, 14, 6006, 199, 374, 5544, 949, 2291, 367, 10015, 641, 10677, 1163, 2419, 10130, 14, 199, 199, 1918, 4046, 21355, 15116, 14, 2424, 1077, 7684, 6555, 1006, 11336, 14, 9738, 12, 199, 16990, 365, 282, 15015, 3382, 4902, 436, 19773, 543, 8794, 370, 25833, 14, 2900, 12454, 199, 1530, 6326, 370, 1736, 6818, 642, 12, 1325, 21355, 15026, 542, 397, 446, 16239, 28925, 928, 13, 923, 465, 282, 199, 4342, 436, 22743, 28908, 652, 14, 3709, 282, 754, 314, 1072, 402, 642, 4306, 199, 5626, 440, 506, 295, 1857, 641, 367, 10015, 14, 199, 199, 11423, 1808, 543, 1022, 32176, 12, 675, 1015, 841, 14, 20, 26240, 26902, 5459, 402, 1022, 32176, 911, 199, 1397, 506, 7688, 370, 2342, 314, 1406, 570, 6602, 11736, 315, 314, 4046, 199, 27984, 15116, 14, 2424, 570, 14, 199, 624, 199, 199, 646, 12866, 199, 646, 747, 199, 646, 4673, 199, 646, 1059, 199, 646, 3873, 199, 646, 4902, 14, 2330, 199, 199, 4679, 63, 885, 63, 3669, 275, 469, 523, 283, 21623, 63, 6351, 356, 3260, 523, 283, 21623, 63, 12273, 356, 3260, 523, 283, 10449, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 10449, 63, 5617, 63, 12273, 356, 1987, 65, 297, 523, 283, 13772, 63, 5617, 63, 6351, 356, 283, 773, 297, 523, 283, 13772, 63, 5617, 63, 12273, 356, 1987, 1152, 297, 523, 283, 13772, 63, 5617, 63, 3022, 356, 20044, 21728, 5995, 773, 14, 10545, 16892, 7293, 523, 283, 5617, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 7293, 523, 283, 23227, 63, 3022, 356, 20044, 1113, 5565, 10545, 16892, 5995, 10545, 9268, 5995, 2268, 73, 297, 523, 283, 13772, 63, 23227, 63, 3022, 356, 20044, 1113, 5995, 2268, 297, 523, 283, 14853, 63, 3022, 356, 20044, 21728, 7293, 523, 283, 13578, 63, 7321, 63, 3243, 356, 20044, 13578, 63, 7321, 63, 3243, 7293, 523, 283, 13578, 63, 7321, 63, 3022, 2339, 356, 20044, 13578, 63, 7321, 63, 3022, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 2339, 356, 20044, 13578, 63, 7321, 63, 2339, 7293, 523, 283, 13578, 63, 7321, 63, 5441, 356, 20044, 13578, 63, 7321, 63, 5441, 7293, 523, 283, 13578, 63, 7321, 63, 2472, 356, 20044, 13578, 63, 7321, 63, 2472, 7293, 523, 283, 22212, 63, 2339, 356, 20044, 4758, 7293, 199, 93, 199, 199, 14742, 63, 3243, 63, 21367, 275, 661, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 20044, 21728, 7293, 20044, 1113, 12216, 199, 199, 4679, 63, 9823, 63, 6048, 63, 30116, 275, 715, 199, 4679, 63, 28789, 63, 1986, 63, 4342, 63, 5714, 63, 23395, 275, 715, 199, 199, 6790, 1193, 2617, 63, 18451, 275, 469, 523, 1987, 67, 356, 283, 2055, 297, 523, 1987, 2055, 356, 283, 9634, 297, 523, 1987, 5910, 356, 283, 9634, 297, 523, 1987, 9634, 356, 283, 9634, 297, 523, 1987, 83, 356, 283, 83, 297, 327, 7429, 523, 1987, 51, 356, 283, 83, 297, 327, 7429, 199, 93, 421, 199, 318, 5852, 4793, 8, 65, 12, 2403, 304, 523, 408, 3407, 283, 65, 7, 1928, 283, 1861, 7, 340, 652, 9174, 543, 283, 1861, 23690, 523, 372, 282, 59, 552, 8, 1861, 15405, 340, 282, 14, 2460, 8, 1861, 9, 587, 282, 421, 199, 318, 12707, 11458, 8, 885, 63, 3669, 12, 1862, 304, 523, 408, 14860, 4722, 2860, 367, 675, 315, 314, 1900, 334, 3527, 701, 4902, 10477, 523, 849, 63, 3669, 14, 5486, 360, 3100, 297, 4902, 14, 2330, 14, 1002, 16739, 8, 1162, 430, 421, 199, 318, 3599, 382, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 1013, 382, 461, 334, 5626, 506, 315, 28652, 11378, 10477, 523, 372, 1263, 8, 1501, 14, 4130, 8, 69, 9, 367, 325, 315, 16503, 1193, 2617, 63, 18451, 9, 421, 199, 318, 10967, 461, 8, 1501, 304, 523, 408, 1767, 2549, 340, 314, 570, 365, 30258, 334, 5626, 506, 641, 314, 2142, 1004, 10477, 523, 372, 1788, 14, 4130, 5175, 79, 358, 421, 199, 318, 20800, 904, 2042, 13606, 27984, 2980, 8, 1095, 63, 515, 12, 4668, 63, 515, 304, 523, 408, 1322, 393, 2310, 4668, 63, 515, 6169, 1300, 63, 515, 436, 2529, 314, 754, 14, 819, 982, 4668, 63, 515, 365, 376, 3679, 931, 652, 365, 2138, 14874, 14, 523, 6630, 652, 365, 12152, 6169, 1300, 63, 515, 436, 9657, 14, 523, 982, 314, 754, 365, 282, 3847, 931, 12, 652, 365, 19565, 370, 506, 3847, 370, 314, 523, 21355, 15116, 14, 2424, 14, 523, 408, 523, 340, 747, 14, 515, 14, 17896, 8, 3369, 63, 515, 304, 272, 372, 4668, 63, 515, 523, 340, 1263, 779, 3369, 63, 515, 14, 2460, 8, 1391, 9, 367, 2729, 315, 18530, 63, 3243, 63, 21367, 4682, 272, 372, 4668, 63, 515, 523, 327, 3254, 26, 886, 781, 1929, 370, 1104, 1300, 63, 515, 367, 3679, 2860, 465, 5521, 31, 523, 372, 747, 14, 515, 14, 904, 360, 10545, 30250, 63, 14211, 63, 4924, 63, 3022, 7293, 1993, 747, 14, 515, 14, 9267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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