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
nagyistoce/odoo-dev-odoo
addons/l10n_in_hr_payroll/__init__.py
430
1117
#-*- coding:utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 OpenERP SA (<http://openerp.com>). All Rights Reserved # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import l10n_in_hr_payroll import report import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 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, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 634, 709, 78, 63, 262, 63, 6271, 63, 5989, 2827, 199, 646, 3622, 199, 646, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13, 1837, 2803, 26, 1624, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 7760, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 2900, 5924, 5702, 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, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 634, 709, 78, 63, 262, 63, 6271, 63, 5989, 2827, 199, 646, 3622, 199, 646, 12262, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 0, 0, 0, 0, 0, 0,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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 ]
virgree/odoo
addons/mrp_repair/wizard/__init__.py
445
1096
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import cancel_repair import make_invoice # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 646, 9311, 63, 25279, 199, 646, 1852, 63, 5404, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 258, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 420, 199, 3, 199, 4605, 199, 199, 646, 9311, 63, 25279, 199, 646, 1852, 63, 5404, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
RockySteveJobs/python-for-android
python3-alpha/python3-src/Tools/scripts/findnocoding.py
46
2722
#!/usr/bin/env python3 """List all those Python files that require a coding directive Usage: nocoding.py dir1 [dir2...] """ __author__ = "Oleg Broytmann, Georg Brandl" import sys, os, re, getopt # our pysource module finds Python source files try: import pysource except ImportError: # emulate the module with a simple os.walk class pysource: has_python_ext = looks_like_python = can_be_compiled = None def walk_python_files(self, paths, *args, **kwargs): for path in paths: if os.path.isfile(path): yield path.endswith(".py") elif os.path.isdir(path): for root, dirs, files in os.walk(path): for filename in files: if filename.endswith(".py"): yield os.path.join(root, filename) pysource = pysource() print("The pysource module is not available; " "no sophisticated Python source file search will be done.", file=sys.stderr) decl_re = re.compile(r"coding[=:]\s*([-\w.]+)") def get_declaration(line): match = decl_re.search(line) if match: return match.group(1) return '' def has_correct_encoding(text, codec): try: str(text, codec) except UnicodeDecodeError: return False else: return True def needs_declaration(fullpath): try: infile = open(fullpath, 'rU') except IOError: # Oops, the file was removed - ignore it return None line1 = infile.readline() line2 = infile.readline() if get_declaration(line1) or get_declaration(line2): # the file does have an encoding declaration, so trust it infile.close() return False # check the whole file for non utf-8 characters rest = infile.read() infile.close() if has_correct_encoding(line1+line2+rest, "utf-8"): return False return True usage = """Usage: %s [-cd] paths... -c: recognize Python source files trying to compile them -d: debug output""" % sys.argv[0] try: opts, args = getopt.getopt(sys.argv[1:], 'cd') except getopt.error as msg: print(msg, file=sys.stderr) print(usage, file=sys.stderr) sys.exit(1) is_python = pysource.looks_like_python debug = False for o, a in opts: if o == '-c': is_python = pysource.can_be_compiled elif o == '-d': debug = True if not args: print(usage, file=sys.stderr) sys.exit(1) for fullpath in pysource.walk_python_files(args, is_python): if debug: print("Testing for coding: %s" % fullpath) result = needs_declaration(fullpath) if result: print(fullpath)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 1296, 1006, 5204, 2018, 1584, 626, 4409, 282, 2803, 13613, 199, 199, 7692, 26, 949, 1523, 14, 647, 2935, 17, 359, 694, 18, 18737, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 47, 4170, 699, 4813, 7574, 1189, 12, 5346, 1308, 699, 3759, 76, 2, 199, 199, 646, 984, 12, 747, 12, 295, 12, 12733, 199, 199, 3, 4154, 10382, 616, 859, 17651, 2018, 1350, 1584, 199, 893, 26, 272, 492, 10382, 616, 199, 2590, 3545, 26, 272, 327, 31102, 314, 859, 543, 282, 3486, 747, 14, 7757, 272, 1021, 10382, 616, 26, 267, 965, 63, 1548, 63, 832, 275, 10734, 63, 2930, 63, 1548, 275, 883, 63, 1235, 63, 8427, 275, 488, 267, 347, 12778, 63, 1548, 63, 1725, 8, 277, 12, 3792, 12, 627, 589, 12, 1011, 958, 304, 288, 367, 931, 315, 3792, 26, 355, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 490, 1995, 931, 14, 4130, 9520, 647, 531, 355, 916, 747, 14, 515, 14, 6027, 8, 515, 304, 490, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 515, 304, 717, 367, 1788, 315, 1584, 26, 1169, 340, 1788, 14, 4130, 9520, 647, 2349, 1816, 1995, 747, 14, 515, 14, 904, 8, 1231, 12, 1788, 9, 272, 10382, 616, 275, 10382, 616, 342, 2378, 870, 480, 1918, 10382, 616, 859, 365, 440, 2808, 27, 298, 586, 298, 889, 308, 24316, 6937, 972, 2018, 1350, 570, 2754, 911, 506, 4224, 4765, 570, 29, 1274, 14, 3083, 9, 421, 199, 9427, 63, 264, 275, 295, 14, 2014, 8, 82, 2, 1523, 59, 29, 2938, 60, 83, 10, 779, 2696, 87, 32455, 6320, 199, 199, 318, 664, 63, 15477, 8, 604, 304, 272, 1336, 275, 15021, 63, 264, 14, 1733, 8, 604, 9, 272, 340, 1336, 26, 267, 372, 1336, 14, 923, 8, 17, 9, 272, 372, 2125, 199, 199, 318, 965, 63, 4525, 63, 2991, 8, 505, 12, 9076, 304, 272, 862, 26, 267, 620, 8, 505, 12, 9076, 9, 272, 871, 18965, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 318, 4839, 63, 15477, 8, 17943, 304, 272, 862, 26, 267, 14734, 275, 1551, 8, 17943, 12, 283, 28978, 358, 272, 871, 5925, 26, 327, 593, 1483, 12, 314, 570, 1990, 4829, 446, 3686, 652, 267, 372, 488, 339, 1004, 17, 275, 14734, 14, 6407, 342, 272, 1004, 18, 275, 14734, 14, 6407, 342, 339, 340, 664, 63, 15477, 8, 604, 17, 9, 503, 664, 63, 15477, 8, 604, 18, 304, 267, 327, 314, 570, 1630, 1172, 376, 2644, 12560, 12, 880, 16822, 652, 267, 14734, 14, 1600, 342, 267, 372, 756, 339, 327, 1104, 314, 8852, 570, 367, 2222, 2774, 13, 24, 4110, 272, 4618, 275, 14734, 14, 739, 342, 272, 14734, 14, 1600, 342, 339, 340, 965, 63, 4525, 63, 2991, 8, 604, 17, 11, 604, 18, 11, 3911, 12, 298, 1624, 13, 24, 2349, 267, 372, 756, 339, 372, 715, 421, 199, 3807, 275, 408, 7692, 26, 450, 83, 5243, 2866, 61, 3792, 1396, 272, 446, 67, 26, 27159, 2018, 1350, 1584, 9936, 370, 6555, 3062, 272, 446, 68, 26, 3105, 1072, 624, 450, 984, 14, 3020, 59, 16, 61, 199, 199, 893, 26, 272, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 2866, 358, 199, 2590, 12733, 14, 705, 465, 1499, 26, 272, 870, 8, 1328, 12, 570, 29, 1274, 14, 3083, 9, 272, 870, 8, 3807, 12, 570, 29, 1274, 14, 3083, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 374, 63, 1548, 275, 10382, 616, 14, 11660, 83, 63, 2930, 63, 1548, 199, 1757, 275, 756, 199, 199, 509, 312, 12, 282, 315, 3999, 26, 272, 340, 312, 508, 2475, 67, 356, 267, 365, 63, 1548, 275, 10382, 616, 14, 2425, 63, 1235, 63, 8427, 272, 916, 312, 508, 2475, 68, 356, 267, 3105, 275, 715, 199, 199, 692, 440, 1249, 26, 272, 870, 8, 3807, 12, 570, 29, 1274, 14, 3083, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 509, 26404, 315, 10382, 616, 14, 7757, 63, 1548, 63, 1725, 8, 589, 12, 365, 63, 1548, 304, 272, 340, 3105, 26, 267, 870, 480, 9029, 367, 2803, 26, 450, 83, 2, 450, 26404, 9, 272, 754, 275, 4839, 63, 15477, 8, 17943, 9, 272, 340, 754, 26, 267, 870, 8, 17943, 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 ]
[ 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 1296, 1006, 5204, 2018, 1584, 626, 4409, 282, 2803, 13613, 199, 199, 7692, 26, 949, 1523, 14, 647, 2935, 17, 359, 694, 18, 18737, 199, 624, 199, 199, 363, 2502, 363, 275, 298, 47, 4170, 699, 4813, 7574, 1189, 12, 5346, 1308, 699, 3759, 76, 2, 199, 199, 646, 984, 12, 747, 12, 295, 12, 12733, 199, 199, 3, 4154, 10382, 616, 859, 17651, 2018, 1350, 1584, 199, 893, 26, 272, 492, 10382, 616, 199, 2590, 3545, 26, 272, 327, 31102, 314, 859, 543, 282, 3486, 747, 14, 7757, 272, 1021, 10382, 616, 26, 267, 965, 63, 1548, 63, 832, 275, 10734, 63, 2930, 63, 1548, 275, 883, 63, 1235, 63, 8427, 275, 488, 267, 347, 12778, 63, 1548, 63, 1725, 8, 277, 12, 3792, 12, 627, 589, 12, 1011, 958, 304, 288, 367, 931, 315, 3792, 26, 355, 340, 747, 14, 515, 14, 6292, 8, 515, 304, 490, 1995, 931, 14, 4130, 9520, 647, 531, 355, 916, 747, 14, 515, 14, 6027, 8, 515, 304, 490, 367, 1738, 12, 7606, 12, 1584, 315, 747, 14, 7757, 8, 515, 304, 717, 367, 1788, 315, 1584, 26, 1169, 340, 1788, 14, 4130, 9520, 647, 2349, 1816, 1995, 747, 14, 515, 14, 904, 8, 1231, 12, 1788, 9, 272, 10382, 616, 275, 10382, 616, 342, 2378, 870, 480, 1918, 10382, 616, 859, 365, 440, 2808, 27, 298, 586, 298, 889, 308, 24316, 6937, 972, 2018, 1350, 570, 2754, 911, 506, 4224, 4765, 570, 29, 1274, 14, 3083, 9, 421, 199, 9427, 63, 264, 275, 295, 14, 2014, 8, 82, 2, 1523, 59, 29, 2938, 60, 83, 10, 779, 2696, 87, 32455, 6320, 199, 199, 318, 664, 63, 15477, 8, 604, 304, 272, 1336, 275, 15021, 63, 264, 14, 1733, 8, 604, 9, 272, 340, 1336, 26, 267, 372, 1336, 14, 923, 8, 17, 9, 272, 372, 2125, 199, 199, 318, 965, 63, 4525, 63, 2991, 8, 505, 12, 9076, 304, 272, 862, 26, 267, 620, 8, 505, 12, 9076, 9, 272, 871, 18965, 26, 267, 372, 756, 272, 587, 26, 267, 372, 715, 199, 199, 318, 4839, 63, 15477, 8, 17943, 304, 272, 862, 26, 267, 14734, 275, 1551, 8, 17943, 12, 283, 28978, 358, 272, 871, 5925, 26, 327, 593, 1483, 12, 314, 570, 1990, 4829, 446, 3686, 652, 267, 372, 488, 339, 1004, 17, 275, 14734, 14, 6407, 342, 272, 1004, 18, 275, 14734, 14, 6407, 342, 339, 340, 664, 63, 15477, 8, 604, 17, 9, 503, 664, 63, 15477, 8, 604, 18, 304, 267, 327, 314, 570, 1630, 1172, 376, 2644, 12560, 12, 880, 16822, 652, 267, 14734, 14, 1600, 342, 267, 372, 756, 339, 327, 1104, 314, 8852, 570, 367, 2222, 2774, 13, 24, 4110, 272, 4618, 275, 14734, 14, 739, 342, 272, 14734, 14, 1600, 342, 339, 340, 965, 63, 4525, 63, 2991, 8, 604, 17, 11, 604, 18, 11, 3911, 12, 298, 1624, 13, 24, 2349, 267, 372, 756, 339, 372, 715, 421, 199, 3807, 275, 408, 7692, 26, 450, 83, 5243, 2866, 61, 3792, 1396, 272, 446, 67, 26, 27159, 2018, 1350, 1584, 9936, 370, 6555, 3062, 272, 446, 68, 26, 3105, 1072, 624, 450, 984, 14, 3020, 59, 16, 61, 199, 199, 893, 26, 272, 3999, 12, 1249, 275, 12733, 14, 18907, 8, 1274, 14, 3020, 59, 17, 8429, 283, 2866, 358, 199, 2590, 12733, 14, 705, 465, 1499, 26, 272, 870, 8, 1328, 12, 570, 29, 1274, 14, 3083, 9, 272, 870, 8, 3807, 12, 570, 29, 1274, 14, 3083, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 374, 63, 1548, 275, 10382, 616, 14, 11660, 83, 63, 2930, 63, 1548, 199, 1757, 275, 756, 199, 199, 509, 312, 12, 282, 315, 3999, 26, 272, 340, 312, 508, 2475, 67, 356, 267, 365, 63, 1548, 275, 10382, 616, 14, 2425, 63, 1235, 63, 8427, 272, 916, 312, 508, 2475, 68, 356, 267, 3105, 275, 715, 199, 199, 692, 440, 1249, 26, 272, 870, 8, 3807, 12, 570, 29, 1274, 14, 3083, 9, 272, 984, 14, 2224, 8, 17, 9, 199, 199, 509, 26404, 315, 10382, 616, 14, 7757, 63, 1548, 63, 1725, 8, 589, 12, 365, 63, 1548, 304, 272, 340, 3105, 26, 267, 870, 480, 9029, 367, 2803, 26, 450, 83, 2, 450, 26404, 9, 272, 754, 275, 4839, 63, 15477, 8, 17943, 9, 272, 340, 754, 26, 267, 870, 8, 17943, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rmcgibbo/numpy
tools/win32build/build.py
81
4108
"""Python script to build windows binaries to be fed to the "superpack". The script is pretty dumb: it assumes python executables are installed the standard way, and the location for blas/lapack/atlas is harcoded. TODO: - integrate the x86analysis script to check built binaries - make the config configurable with a file """ from __future__ import division, print_function import sys import subprocess import os import shutil from os.path import join as pjoin, split as psplit, dirname PYEXECS = {"2.5" : "C:\python25\python.exe", "2.4" : "C:\python24\python24.exe", "2.6" : "C:\python26\python26.exe"} _SSE3_CFG = r"""[atlas] library_dirs = C:\local\lib\yop\sse3""" _SSE2_CFG = r"""[atlas] library_dirs = C:\local\lib\yop\sse2""" _NOSSE_CFG = r"""[DEFAULT] library_dirs = C:\local\lib\yop\nosse""" SITECFG = {"sse2" : _SSE2_CFG, "sse3" : _SSE3_CFG, "nosse" : _NOSSE_CFG} def get_python_exec(ver): """Return the executable of python for the given version.""" # XXX Check that the file actually exists try: return PYEXECS[ver] except KeyError: raise ValueError("Version %s not supported/recognized" % ver) def get_clean(): if os.path.exists("build"): shutil.rmtree("build") if os.path.exists("dist"): shutil.rmtree("dist") def write_site_cfg(arch): if os.path.exists("site.cfg"): os.remove("site.cfg") f = open("site.cfg", 'w') f.writelines(SITECFG[arch]) f.close() def build(arch, pyver): print("Building numpy binary for python %s, arch is %s" % (get_python_exec(pyver), arch)) get_clean() write_site_cfg(arch) if BUILD_MSI: cmd = "%s setup.py build -c mingw32 bdist_msi" % get_python_exec(pyver) else: cmd = "%s setup.py build -c mingw32 bdist_wininst" % get_python_exec(pyver) build_log = "build-%s-%s.log" % (arch, pyver) f = open(build_log, 'w') try: try: subprocess.check_call(cmd, shell = True, stderr = subprocess.STDOUT, stdout = f) finally: f.close() except subprocess.CalledProcessError as e: msg = """ There was an error while executing the following command: %s Error was : %s Look at the build log (%s).""" % (cmd, str(e), build_log) raise Exception(msg) move_binary(arch, pyver) def move_binary(arch, pyver): if not os.path.exists("binaries"): os.makedirs("binaries") shutil.move(os.path.join('dist', get_windist_exec(pyver)), os.path.join("binaries", get_binary_name(arch))) def get_numpy_version(): if sys.version_info[0] >= 3: import builtins else: import __builtin__ as builtins builtins.__NUMPY_SETUP__ = True from numpy.version import version return version def get_binary_name(arch): if BUILD_MSI: ext = '.msi' else: ext = '.exe' return "numpy-%s-%s%s" % (get_numpy_version(), arch, ext) def get_windist_exec(pyver): """Return the name of the installer built by wininst command.""" # Yeah, the name logic is harcoded in distutils. We have to reproduce it # here if BUILD_MSI: ext = '.msi' else: ext = '.exe' name = "numpy-%s.win32-py%s%s" % (get_numpy_version(), pyver, ext) return name if __name__ == '__main__': from optparse import OptionParser parser = OptionParser() parser.add_option("-a", "--arch", dest="arch", help = "Architecture to build (sse2, sse3, nosse, etc...)") parser.add_option("-p", "--pyver", dest="pyver", help = "Python version (2.4, 2.5, etc...)") parser.add_option("-m", "--build-msi", dest="msi", help = "0 or 1. If 1, build a msi instead of an exe.") opts, args = parser.parse_args() arch = opts.arch pyver = opts.pyver msi = opts.msi if not pyver: pyver = "2.5" if not msi: BUILD_MSI = False else: BUILD_MSI = True if not arch: for arch in SITECFG.keys(): build(arch, pyver) else: build(arch, pyver)
bsd-3-clause
[ 624, 4718, 2884, 370, 1900, 10061, 21984, 370, 506, 23036, 370, 314, 298, 4792, 1389, 1674, 199, 199, 1918, 2884, 365, 7268, 32490, 26, 652, 15194, 2366, 31172, 787, 4903, 314, 199, 6807, 4340, 12, 436, 314, 2909, 367, 6826, 305, 15, 26760, 15, 24935, 365, 12159, 15282, 14, 199, 199, 11768, 26, 272, 446, 21494, 314, 671, 1184, 10466, 2884, 370, 1104, 6137, 21984, 272, 446, 1852, 314, 1101, 30241, 543, 282, 570, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 747, 199, 646, 5145, 199, 504, 747, 14, 515, 492, 4263, 465, 299, 904, 12, 3715, 465, 299, 1294, 12, 9017, 199, 199, 4521, 23017, 3298, 275, 2420, 18, 14, 21, 2, 520, 298, 35, 3427, 1548, 821, 60, 1548, 14, 5803, 401, 267, 298, 18, 14, 20, 2, 520, 298, 35, 3427, 1548, 1194, 60, 1548, 1194, 14, 5803, 401, 267, 298, 18, 14, 22, 2, 520, 298, 35, 3427, 1548, 1479, 60, 1548, 1479, 14, 5803, 3570, 199, 199, 63, 24932, 19, 63, 10118, 275, 519, 624, 59, 24935, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 28780, 19, 624, 199, 63, 24932, 18, 63, 10118, 275, 519, 624, 59, 24935, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 28780, 18, 624, 199, 63, 23141, 899, 63, 10118, 275, 519, 624, 59, 3472, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 12712, 261, 624, 199, 199, 51, 649, 4220, 27453, 275, 2420, 28780, 18, 2, 520, 485, 24932, 18, 63, 10118, 12, 298, 28780, 19, 2, 520, 485, 24932, 19, 63, 10118, 12, 298, 12712, 261, 2, 520, 485, 23141, 899, 63, 10118, 93, 199, 199, 318, 664, 63, 1548, 63, 1628, 8, 422, 304, 272, 408, 1767, 314, 7286, 402, 2366, 367, 314, 1627, 1015, 1041, 272, 327, 5787, 2670, 626, 314, 570, 5965, 3495, 272, 862, 26, 267, 372, 7843, 23017, 3298, 59, 422, 61, 272, 871, 4067, 26, 267, 746, 1722, 480, 3353, 450, 83, 440, 3748, 15, 13221, 2, 450, 809, 9, 199, 199, 318, 664, 63, 3118, 837, 272, 340, 747, 14, 515, 14, 2444, 480, 1506, 2349, 267, 5145, 14, 9242, 480, 1506, 531, 272, 340, 747, 14, 515, 14, 2444, 480, 2686, 2349, 267, 5145, 14, 9242, 480, 2686, 531, 199, 199, 318, 2218, 63, 2124, 63, 4128, 8, 1047, 304, 272, 340, 747, 14, 515, 14, 2444, 480, 2124, 14, 4128, 2349, 267, 747, 14, 2168, 480, 2124, 14, 4128, 531, 272, 289, 275, 1551, 480, 2124, 14, 4128, 401, 283, 87, 358, 272, 289, 14, 23277, 8, 51, 649, 4220, 27453, 59, 1047, 566, 272, 289, 14, 1600, 342, 199, 199, 318, 1900, 8, 1047, 12, 1134, 422, 304, 272, 870, 480, 16461, 2680, 3366, 367, 2366, 450, 83, 12, 3819, 365, 450, 83, 2, 450, 334, 362, 63, 1548, 63, 1628, 8, 29686, 395, 3819, 430, 272, 664, 63, 3118, 342, 272, 2218, 63, 2124, 63, 4128, 8, 1047, 9, 339, 340, 22974, 63, 45, 2684, 26, 267, 2088, 275, 2071, 83, 3272, 14, 647, 1900, 446, 67, 333, 316, 87, 708, 26308, 63, 77, 338, 2, 450, 664, 63, 1548, 63, 1628, 8, 29686, 9, 272, 587, 26, 267, 2088, 275, 2071, 83, 3272, 14, 647, 1900, 446, 67, 333, 316, 87, 708, 26308, 63, 2676, 3615, 2, 450, 664, 63, 1548, 63, 1628, 8, 29686, 9, 272, 1900, 63, 793, 275, 298, 1506, 3295, 83, 3295, 83, 14, 793, 2, 450, 334, 1047, 12, 1134, 422, 9, 272, 289, 275, 1551, 8, 1506, 63, 793, 12, 283, 87, 358, 339, 862, 26, 267, 862, 26, 288, 3873, 14, 1074, 63, 1250, 8, 1760, 12, 5218, 275, 715, 12, 4635, 275, 3873, 14, 13850, 12, 3839, 275, 289, 9, 267, 3753, 26, 288, 289, 14, 1600, 342, 272, 871, 3873, 14, 24691, 465, 325, 26, 267, 1499, 275, 408, 199, 10924, 1990, 376, 1125, 1830, 14043, 314, 2569, 1414, 26, 339, 450, 83, 199, 199, 547, 1990, 520, 450, 83, 199, 199, 20926, 737, 314, 1900, 943, 4366, 83, 10477, 450, 334, 1760, 12, 620, 8, 69, 395, 1900, 63, 793, 9, 267, 746, 2186, 8, 1328, 9, 339, 4057, 63, 3008, 8, 1047, 12, 1134, 422, 9, 199, 199, 318, 4057, 63, 3008, 8, 1047, 12, 1134, 422, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 480, 27542, 2349, 267, 747, 14, 8347, 480, 27542, 531, 339, 5145, 14, 1185, 8, 736, 14, 515, 14, 904, 360, 2686, 297, 664, 63, 2676, 2686, 63, 1628, 8, 29686, 1826, 288, 747, 14, 515, 14, 904, 480, 27542, 401, 664, 63, 3008, 63, 354, 8, 1047, 1724, 199, 199, 318, 664, 63, 4714, 63, 1023, 837, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 267, 492, 12963, 272, 587, 26, 267, 492, 636, 5351, 363, 465, 12963, 339, 12963, 855, 1440, 1658, 57, 63, 20836, 363, 275, 715, 272, 687, 2680, 14, 1023, 492, 1015, 272, 372, 1015, 199, 199, 318, 664, 63, 3008, 63, 354, 8, 1047, 304, 272, 340, 22974, 63, 45, 2684, 26, 267, 1599, 275, 1987, 77, 338, 7, 272, 587, 26, 267, 1599, 275, 1987, 5803, 7, 272, 372, 298, 4714, 3295, 83, 3295, 83, 5, 83, 2, 450, 334, 362, 63, 4714, 63, 1023, 1062, 3819, 12, 1599, 9, 199, 199, 318, 664, 63, 2676, 2686, 63, 1628, 8, 29686, 304, 272, 408, 1767, 314, 536, 402, 314, 18535, 6137, 701, 4747, 3615, 1414, 1041, 272, 327, 1488, 4489, 72, 12, 314, 536, 9661, 365, 12159, 15282, 315, 7065, 14, 2136, 1172, 370, 9172, 652, 272, 327, 2348, 272, 340, 22974, 63, 45, 2684, 26, 267, 1599, 275, 1987, 77, 338, 7, 272, 587, 26, 267, 1599, 275, 1987, 5803, 7, 272, 536, 275, 298, 4714, 3295, 83, 14, 2676, 708, 13, 647, 5, 83, 5, 83, 2, 450, 334, 362, 63, 4714, 63, 1023, 1062, 1134, 422, 12, 1599, 9, 272, 372, 536, 199, 199, 692, 636, 354, 363, 508, 2560 ]
[ 4718, 2884, 370, 1900, 10061, 21984, 370, 506, 23036, 370, 314, 298, 4792, 1389, 1674, 199, 199, 1918, 2884, 365, 7268, 32490, 26, 652, 15194, 2366, 31172, 787, 4903, 314, 199, 6807, 4340, 12, 436, 314, 2909, 367, 6826, 305, 15, 26760, 15, 24935, 365, 12159, 15282, 14, 199, 199, 11768, 26, 272, 446, 21494, 314, 671, 1184, 10466, 2884, 370, 1104, 6137, 21984, 272, 446, 1852, 314, 1101, 30241, 543, 282, 570, 199, 199, 624, 199, 504, 636, 2443, 363, 492, 4629, 12, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 3873, 199, 646, 747, 199, 646, 5145, 199, 504, 747, 14, 515, 492, 4263, 465, 299, 904, 12, 3715, 465, 299, 1294, 12, 9017, 199, 199, 4521, 23017, 3298, 275, 2420, 18, 14, 21, 2, 520, 298, 35, 3427, 1548, 821, 60, 1548, 14, 5803, 401, 267, 298, 18, 14, 20, 2, 520, 298, 35, 3427, 1548, 1194, 60, 1548, 1194, 14, 5803, 401, 267, 298, 18, 14, 22, 2, 520, 298, 35, 3427, 1548, 1479, 60, 1548, 1479, 14, 5803, 3570, 199, 199, 63, 24932, 19, 63, 10118, 275, 519, 624, 59, 24935, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 28780, 19, 624, 199, 63, 24932, 18, 63, 10118, 275, 519, 624, 59, 24935, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 28780, 18, 624, 199, 63, 23141, 899, 63, 10118, 275, 519, 624, 59, 3472, 61, 199, 4342, 63, 3220, 275, 445, 3427, 1832, 60, 773, 60, 89, 411, 60, 12712, 261, 624, 199, 199, 51, 649, 4220, 27453, 275, 2420, 28780, 18, 2, 520, 485, 24932, 18, 63, 10118, 12, 298, 28780, 19, 2, 520, 485, 24932, 19, 63, 10118, 12, 298, 12712, 261, 2, 520, 485, 23141, 899, 63, 10118, 93, 199, 199, 318, 664, 63, 1548, 63, 1628, 8, 422, 304, 272, 408, 1767, 314, 7286, 402, 2366, 367, 314, 1627, 1015, 1041, 272, 327, 5787, 2670, 626, 314, 570, 5965, 3495, 272, 862, 26, 267, 372, 7843, 23017, 3298, 59, 422, 61, 272, 871, 4067, 26, 267, 746, 1722, 480, 3353, 450, 83, 440, 3748, 15, 13221, 2, 450, 809, 9, 199, 199, 318, 664, 63, 3118, 837, 272, 340, 747, 14, 515, 14, 2444, 480, 1506, 2349, 267, 5145, 14, 9242, 480, 1506, 531, 272, 340, 747, 14, 515, 14, 2444, 480, 2686, 2349, 267, 5145, 14, 9242, 480, 2686, 531, 199, 199, 318, 2218, 63, 2124, 63, 4128, 8, 1047, 304, 272, 340, 747, 14, 515, 14, 2444, 480, 2124, 14, 4128, 2349, 267, 747, 14, 2168, 480, 2124, 14, 4128, 531, 272, 289, 275, 1551, 480, 2124, 14, 4128, 401, 283, 87, 358, 272, 289, 14, 23277, 8, 51, 649, 4220, 27453, 59, 1047, 566, 272, 289, 14, 1600, 342, 199, 199, 318, 1900, 8, 1047, 12, 1134, 422, 304, 272, 870, 480, 16461, 2680, 3366, 367, 2366, 450, 83, 12, 3819, 365, 450, 83, 2, 450, 334, 362, 63, 1548, 63, 1628, 8, 29686, 395, 3819, 430, 272, 664, 63, 3118, 342, 272, 2218, 63, 2124, 63, 4128, 8, 1047, 9, 339, 340, 22974, 63, 45, 2684, 26, 267, 2088, 275, 2071, 83, 3272, 14, 647, 1900, 446, 67, 333, 316, 87, 708, 26308, 63, 77, 338, 2, 450, 664, 63, 1548, 63, 1628, 8, 29686, 9, 272, 587, 26, 267, 2088, 275, 2071, 83, 3272, 14, 647, 1900, 446, 67, 333, 316, 87, 708, 26308, 63, 2676, 3615, 2, 450, 664, 63, 1548, 63, 1628, 8, 29686, 9, 272, 1900, 63, 793, 275, 298, 1506, 3295, 83, 3295, 83, 14, 793, 2, 450, 334, 1047, 12, 1134, 422, 9, 272, 289, 275, 1551, 8, 1506, 63, 793, 12, 283, 87, 358, 339, 862, 26, 267, 862, 26, 288, 3873, 14, 1074, 63, 1250, 8, 1760, 12, 5218, 275, 715, 12, 4635, 275, 3873, 14, 13850, 12, 3839, 275, 289, 9, 267, 3753, 26, 288, 289, 14, 1600, 342, 272, 871, 3873, 14, 24691, 465, 325, 26, 267, 1499, 275, 408, 199, 10924, 1990, 376, 1125, 1830, 14043, 314, 2569, 1414, 26, 339, 450, 83, 199, 199, 547, 1990, 520, 450, 83, 199, 199, 20926, 737, 314, 1900, 943, 4366, 83, 10477, 450, 334, 1760, 12, 620, 8, 69, 395, 1900, 63, 793, 9, 267, 746, 2186, 8, 1328, 9, 339, 4057, 63, 3008, 8, 1047, 12, 1134, 422, 9, 199, 199, 318, 4057, 63, 3008, 8, 1047, 12, 1134, 422, 304, 272, 340, 440, 747, 14, 515, 14, 2444, 480, 27542, 2349, 267, 747, 14, 8347, 480, 27542, 531, 339, 5145, 14, 1185, 8, 736, 14, 515, 14, 904, 360, 2686, 297, 664, 63, 2676, 2686, 63, 1628, 8, 29686, 1826, 288, 747, 14, 515, 14, 904, 480, 27542, 401, 664, 63, 3008, 63, 354, 8, 1047, 1724, 199, 199, 318, 664, 63, 4714, 63, 1023, 837, 272, 340, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 267, 492, 12963, 272, 587, 26, 267, 492, 636, 5351, 363, 465, 12963, 339, 12963, 855, 1440, 1658, 57, 63, 20836, 363, 275, 715, 272, 687, 2680, 14, 1023, 492, 1015, 272, 372, 1015, 199, 199, 318, 664, 63, 3008, 63, 354, 8, 1047, 304, 272, 340, 22974, 63, 45, 2684, 26, 267, 1599, 275, 1987, 77, 338, 7, 272, 587, 26, 267, 1599, 275, 1987, 5803, 7, 272, 372, 298, 4714, 3295, 83, 3295, 83, 5, 83, 2, 450, 334, 362, 63, 4714, 63, 1023, 1062, 3819, 12, 1599, 9, 199, 199, 318, 664, 63, 2676, 2686, 63, 1628, 8, 29686, 304, 272, 408, 1767, 314, 536, 402, 314, 18535, 6137, 701, 4747, 3615, 1414, 1041, 272, 327, 1488, 4489, 72, 12, 314, 536, 9661, 365, 12159, 15282, 315, 7065, 14, 2136, 1172, 370, 9172, 652, 272, 327, 2348, 272, 340, 22974, 63, 45, 2684, 26, 267, 1599, 275, 1987, 77, 338, 7, 272, 587, 26, 267, 1599, 275, 1987, 5803, 7, 272, 536, 275, 298, 4714, 3295, 83, 14, 2676, 708, 13, 647, 5, 83, 5, 83, 2, 450, 334, 362, 63, 4714, 63, 1023, 1062, 1134, 422, 12, 1599, 9, 272, 372, 536, 199, 199, 692, 636, 354, 363, 508, 2560, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
leandrotoledo/oppia
extensions/interactions/LogicProof/LogicProof.py
6
1780
# coding: utf-8 # # Copyright 2014 The Oppia 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, softwar # 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. __author__ = 'Jacob Davis' from extensions.interactions import base class LogicProof(base.BaseInteraction): """Interaction for entering logic proofs.""" name = 'Logic Proof' description = ( 'Allows learners to write proofs for simple logical statements.') display_mode = base.DISPLAY_MODE_SUPPLEMENTAL _dependency_ids = ['logic_proof', 'codemirror'] answer_type = 'CheckedProof' instructions = 'Construct a proof' needs_summary = True _customization_arg_specs = [{ 'name': 'question', 'description': 'Question to ask', 'schema': { 'type': 'custom', 'obj_type': 'LogicQuestion', }, 'default_value': { 'assumptions': [{ 'top_kind_name': 'variable', 'top_operator_name': 'p', 'arguments': [], 'dummies': [] }], 'results': [{ 'top_kind_name': 'variable', 'top_operator_name': 'p', 'arguments': [], 'dummies': [] }], 'default_proof_string': '' }, }]
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 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, 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, 11620, 3281, 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, 363, 2502, 363, 275, 283, 42, 13286, 66, 577, 1214, 374, 7, 199, 199, 504, 5478, 14, 262, 22990, 492, 1300, 421, 199, 533, 5297, 530, 919, 1618, 8, 1095, 14, 1563, 31900, 304, 272, 408, 31900, 367, 9509, 316, 9661, 557, 14105, 1041, 339, 536, 275, 283, 32140, 2165, 1618, 7, 272, 1369, 275, 334, 267, 283, 19780, 12537, 1192, 370, 2218, 557, 14105, 367, 3486, 11461, 9834, 2659, 272, 2929, 63, 632, 275, 1300, 14, 20993, 63, 6963, 63, 7380, 48, 10320, 748, 272, 485, 8575, 63, 1580, 275, 788, 15370, 63, 496, 1618, 297, 283, 600, 12324, 418, 272, 6385, 63, 466, 275, 283, 14627, 919, 1618, 7, 272, 15794, 275, 283, 11493, 282, 557, 1618, 7, 272, 4839, 63, 4705, 275, 715, 339, 485, 4229, 2072, 63, 1273, 63, 7273, 275, 8910, 267, 283, 354, 356, 283, 4790, 297, 267, 283, 1802, 356, 283, 16778, 370, 7198, 297, 267, 283, 3629, 356, 469, 288, 283, 466, 356, 283, 4229, 297, 288, 283, 1113, 63, 466, 356, 283, 32140, 16778, 297, 267, 1660, 267, 283, 885, 63, 585, 356, 469, 288, 283, 405, 18064, 356, 8910, 355, 283, 2119, 63, 5091, 63, 354, 356, 283, 1975, 297, 355, 283, 2119, 63, 3856, 63, 354, 356, 283, 80, 297, 355, 283, 4958, 356, 990, 355, 283, 27512, 31284, 356, 942, 288, 19971, 288, 283, 2604, 356, 8910, 355, 283, 2119, 63, 5091, 63, 354, 356, 283, 1975, 297, 355, 283, 2119, 63, 3856, 63, 354, 356, 283, 80, 297, 355, 283, 4958, 356, 990, 355, 283, 27512, 31284, 356, 942, 288, 19971, 288, 283, 885, 63, 496, 1618, 63, 875, 356, 2125, 267, 1660, 272, 14877, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3, 199, 3, 1898, 6927, 710, 593, 802, 4674, 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, 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, 11620, 3281, 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, 363, 2502, 363, 275, 283, 42, 13286, 66, 577, 1214, 374, 7, 199, 199, 504, 5478, 14, 262, 22990, 492, 1300, 421, 199, 533, 5297, 530, 919, 1618, 8, 1095, 14, 1563, 31900, 304, 272, 408, 31900, 367, 9509, 316, 9661, 557, 14105, 1041, 339, 536, 275, 283, 32140, 2165, 1618, 7, 272, 1369, 275, 334, 267, 283, 19780, 12537, 1192, 370, 2218, 557, 14105, 367, 3486, 11461, 9834, 2659, 272, 2929, 63, 632, 275, 1300, 14, 20993, 63, 6963, 63, 7380, 48, 10320, 748, 272, 485, 8575, 63, 1580, 275, 788, 15370, 63, 496, 1618, 297, 283, 600, 12324, 418, 272, 6385, 63, 466, 275, 283, 14627, 919, 1618, 7, 272, 15794, 275, 283, 11493, 282, 557, 1618, 7, 272, 4839, 63, 4705, 275, 715, 339, 485, 4229, 2072, 63, 1273, 63, 7273, 275, 8910, 267, 283, 354, 356, 283, 4790, 297, 267, 283, 1802, 356, 283, 16778, 370, 7198, 297, 267, 283, 3629, 356, 469, 288, 283, 466, 356, 283, 4229, 297, 288, 283, 1113, 63, 466, 356, 283, 32140, 16778, 297, 267, 1660, 267, 283, 885, 63, 585, 356, 469, 288, 283, 405, 18064, 356, 8910, 355, 283, 2119, 63, 5091, 63, 354, 356, 283, 1975, 297, 355, 283, 2119, 63, 3856, 63, 354, 356, 283, 80, 297, 355, 283, 4958, 356, 990, 355, 283, 27512, 31284, 356, 942, 288, 19971, 288, 283, 2604, 356, 8910, 355, 283, 2119, 63, 5091, 63, 354, 356, 283, 1975, 297, 355, 283, 2119, 63, 3856, 63, 354, 356, 283, 80, 297, 355, 283, 4958, 356, 990, 355, 283, 27512, 31284, 356, 942, 288, 19971, 288, 283, 885, 63, 496, 1618, 63, 875, 356, 2125, 267, 1660, 272, 14877, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
xi/cplay-ng
cplay.py
1
22873
import curses import functools import json import os import random import re import selectors import signal import socket import subprocess import sys import termios import time from contextlib import contextmanager __version__ = 'cplay-ng 4.0.0' AUDIO_EXTENSIONS = [ 'mp3', 'ogg', 'oga', 'opus', 'flac', 'm4a', 'm4b', 'wav', 'mid', 'wma' ] HELP = """Global ------ Up, k : move to previous item Down, j : move to next item PageUp, K : move to previous page PageDown, J : move to next page Home, g : move to top End, G : move to bottom Enter : chdir or play Tab : switch between filelist/playlist n : next track x, Space : toggle play/pause Left, Right : seek backward/forward / : search C-s, C-r : next/previous search match Esc : cancel 0..9 : volume control h : help q, Q : quit Filelist -------- a : add to playlist s : recursive search BS : go to parent dir Playlist -------- d, D : delete item/all m, M : move item down/up r, R : toggle repeat/random s, S : shuffle/sort playlist w : enter filename for current playlist C : close current playlist @ : jump to current track""" def clamp(value, _min, _max): return max(_min, min(_max, value)) def space_between(a, b, n): d = n - (len(a) + len(b)) if d >= 0: return a + ' ' * d + b else: return a[:d] + b def format_time(total): h, s = divmod(total, 3600) m, s = divmod(s, 60) return '%02d:%02d:%02d' % (h, m, s) def str_match(query, s): return all(q in s.lower() for q in query.lower().split()) def set_volume(vol): subprocess.check_call([ 'pactl', '--', 'set-sink-volume', '0', '%i%%' % int(vol * 100) ]) def resize(*args): os.write(app.resize_out, b'.') def get_socket(path): while True: try: sock = socket.socket(family=socket.AF_UNIX) sock.connect(path) return sock except (FileNotFoundError, ConnectionRefusedError): time.sleep(0.1) @functools.lru_cache() def relpath(path): if path.startswith(filelist.path): return path[len(filelist.path):].lstrip('/') else: return os.path.relpath(path) @contextmanager def enable_ctrl_keys(): fd = sys.stdin.fileno() old = termios.tcgetattr(fd) try: tcattr = termios.tcgetattr(fd) tcattr[0] = tcattr[0] & ~(termios.IXON) termios.tcsetattr(fd, termios.TCSANOW, tcattr) yield finally: termios.tcsetattr(fd, termios.TCSADRAIN, old) def get_ext(path): return os.path.splitext(path)[1].lstrip('.') def listdir(path): with os.scandir(path) as it: for entry in sorted(it, key=lambda e: e.name): if entry.name[0] != '.': yield ( entry.path, get_ext(entry.name), entry.is_dir(follow_symlinks=False), ) class Player: def __init__(self): self.path = None self.position = 0 self.length = 0 self._seek_step = 0 self._seek_timeout = None self.is_playing = False self._playing = 0 self._buffer = b'' self.socket_path = '/tmp/mpv-cplay-%i.sock' % os.getpid() self._proc = subprocess.Popen( [ 'mpv', '--input-ipc-server=%s' % self.socket_path, '--idle', '--audio-display=no', '--replaygain=track', ], stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) self.socket = get_socket(self.socket_path) self._ipc('observe_property', 1, 'time-pos') self._ipc('observe_property', 2, 'duration') def _ipc(self, cmd, *args): data = json.dumps({'command': [cmd, *args]}) msg = data.encode('utf-8') + b'\n' self.socket.send(msg) def handle_ipc(self, data): if data.get('event') == 'property-change' and data['id'] == 1: if data['data'] is not None and not self._seek_step: self.position = data['data'] elif data.get('event') == 'property-change' and data['id'] == 2: if data['data'] is not None: self.length = data['data'] elif data.get('event') == 'end-file': self._playing -= 1 def parse_progress(self): self._buffer += self.socket.recv(1024) msgs = self._buffer.split(b'\n') self._buffer = msgs.pop() for msg in msgs: data = json.loads(msg.decode('utf-8')) self.handle_ipc(data) def get_progress(self): if self.length == 0: return 0 return self.position / self.length def stop(self): self.is_playing = False self._ipc('stop') def _play(self): if not self.path: self.is_playing = False return self.is_playing = True self._playing += 1 self._ipc('loadfile', self.path, 'replace', 'start=%i' % self.position) def play(self, path): self.path = path self.position = 0 self.length = 0 self._seek_step = 0 self._play() def toggle(self): if self.is_playing: self.stop() elif self.path: self._play() def seek(self, direction): d = direction * self.length * 0.002 if self._seek_step * d > 0: # same direction self._seek_step += d else: self._seek_step = d self.position += self._seek_step self.position = min(self.length, max(0, self.position)) self._seek_timeout = time.time() + 0.5 def finish_seek(self): if self._seek_timeout and time.time() >= self._seek_timeout: self._seek_timeout = None self._seek_step = 0 if self.is_playing: self._play() @property def is_finished(self): return self.is_playing and self._playing == 0 def cleanup(self): self._proc.terminate() os.remove(self.socket_path) class Input: def __init__(self): self.active = False self.str = '' def start(self, prompt, on_input, initial=''): self.str = initial self.prompt = prompt self.on_input = on_input self.active = True self.on_input(self.str) def process_key(self, key): if not self.active: return False if key == chr(27): self.str = '' self.active = False elif key == '\n': self.active = False elif key == curses.KEY_BACKSPACE: self.str = self.str[:-1] elif isinstance(key, str): self.str += key else: self.active = False return False self.on_input(self.str) return True class List: def __init__(self): self.items = [] self.position = 0 self.cursor = 0 self.active = -1 self.search_str = '' @property def rows(self): return app.rows - 4 def get_title(self): raise NotImplementedError def set_cursor(self, cursor): self.cursor = clamp(cursor, 0, len(self.items) - 1) self.position = clamp( self.position, self.cursor - self.rows + 1, self.cursor ) def move_cursor(self, diff): self.set_cursor(self.cursor + diff) def search(self, q, diff=1, offset=0): self.search_str = q for i in range(len(self.items)): pos = (self.cursor + (i + offset) * diff) % len(self.items) if str_match(q, self.format_item(self.items[pos])): self.set_cursor(pos) return True return False def format_item(self, item): return relpath(item) def render(self): items = self.items[self.position:self.position + self.rows] for i, item in enumerate(items): attr = 0 if self.position + i == self.cursor: attr |= curses.A_REVERSE if self.position + i == self.active: attr |= curses.A_BOLD item = self.format_item(item) item = space_between(' ' + item, '', app.cols) yield (item, attr) for i in range(max(0, self.rows - len(items))): yield '' def process_key(self, key): if key in [curses.KEY_DOWN, 'j']: self.move_cursor(1) elif key in [curses.KEY_UP, 'k']: self.move_cursor(-1) elif key in [curses.KEY_NPAGE, 'J']: self.move_cursor(self.rows - 2) elif key in [curses.KEY_PPAGE, 'K']: self.move_cursor(-(self.rows - 2)) elif key in [curses.KEY_END, 'G']: self.set_cursor(len(self.items)) elif key in [curses.KEY_HOME, 'g']: self.set_cursor(0) elif key == '/': app.input.start('/', self.search) elif key == chr(19): if self.search_str: self.search(self.search_str, 1, 1) elif key == chr(18): if self.search_str: self.search(self.search_str, -1, 1) else: return False return True class HelpList(List): def __init__(self): super().__init__() self.items = HELP.split('\n') def get_title(self): return 'Help' def format_item(self, item): return item def process_key(self, key): if key in ['q', 'h']: app.help = False else: return super().process_key(key) return True class Filelist(List): def __init__(self): super().__init__() self.path = None self.rsearch_str = '' self.set_path(os.getcwd()) def get_title(self): title = 'Filelist: %s/' % self.path.rstrip('/') if self.rsearch_str: title += 'search "%s"/' % self.rsearch_str return title @functools.lru_cache() def format_item(self, item): s = super().format_item(item) ext = get_ext(item) if not (ext in AUDIO_EXTENSIONS or ext == 'm3u'): s += '/' return s def set_path(self, path, prev=None): if path != self.path: self.path = path os.chdir(path) relpath.cache_clear() self.format_item.cache_clear() self.search_cache = [] self.all_items = [] self.rsearch_str = '' for p, ext, is_dir in listdir(path): if is_dir or ext == 'm3u' or ext in AUDIO_EXTENSIONS: self.all_items.append(p) self.items = self.all_items if prev and prev in self.items: self.set_cursor(self.items.index(prev)) else: self.position = 0 self.cursor = 0 def build_search_cache(self, root): results = [] for path, ext, is_dir in listdir(root): if is_dir: children = self.build_search_cache(path) if children: results.append(path) results += children elif ext in AUDIO_EXTENSIONS or ext == 'm3u': results.append(path) return results def filter(self, query): if not self.search_cache: self.search_cache = self.build_search_cache(self.path) if query: if self.rsearch_str and query.startswith(self.rsearch_str): base = self.items else: base = self.search_cache self.items = [] for path in base: if str_match(query, self.format_item(path)): self.items.append(path) else: self.items = self.all_items self.rsearch_str = query self.set_cursor(self.cursor) def process_key(self, key): if key == 'a': if not self.items: return True if playlist.add(self.items[self.cursor]): playlist.write() self.move_cursor(1) elif key == 's': app.input.start('search: ', self.filter) self.filter(self.rsearch_str) elif key == '\n': if not self.items: return True item = self.items[self.cursor] ext = item.rsplit('.', 1)[-1] if os.path.isdir(item): self.set_path(item) elif ext in AUDIO_EXTENSIONS: playlist.active = -1 player.play(item) elif ext == 'm3u': playlist.clear() playlist.add_playlist(item) playlist.path = item app.toggle_tabs() elif key == curses.KEY_BACKSPACE: if self.rsearch_str: self.set_path(self.path) else: self.set_path(os.path.dirname(self.path), prev=self.path) else: return super().process_key(key) return True class Playlist(List): def __init__(self): super().__init__() self.repeat = False self.random = False self._played = set() self.path = None def get_title(self): title = 'Playlist' if self.path: title += ' ' + os.path.basename(self.path) if self.repeat: title += ' [repeat all]' if self.random: title += ' [random]' return title def clear(self): self.items = [] self.position = 0 self.cursor = 0 self.active = -1 self._played = set() def reorder(self, fn): if not self.items: return cursor_item = self.items[self.cursor] try: active_item = self.items[self.active] except IndexError: active_item = None fn() self.set_cursor(self.items.index(cursor_item)) if active_item: self.active = self.items.index(active_item) def shuffle(self): self.reorder(lambda: random.shuffle(self.items)) def sort(self): self.reorder(lambda: self.items.sort()) def remove_item(self): self.items.pop(self.cursor) if self.active == self.cursor: self.active = -1 elif self.active > self.cursor: self.active -= 1 def move_item(self, direction): new_cursor = clamp(self.cursor + direction, 0, len(self.items) - 1) if self.active == self.cursor: self.active = new_cursor elif direction < 0: if self.active >= new_cursor and self.active < self.cursor: self.active += 1 else: if self.active <= new_cursor and self.active > self.cursor: self.active -= 1 item = self.items.pop(self.cursor) self.items.insert(new_cursor, item) self.set_cursor(new_cursor) def next(self): if not self.items: return if self.random: self._played.add(self.active) left = set(range(len(self.items))).difference(self._played) if left: self.active = random.choice(list(left)) else: self._played = set() if self.repeat: self.active = random.randrange(len(self.items)) else: self.active = -1 return else: self.active += 1 if self.active >= len(self.items) and self.repeat: self.active = 0 try: return self.items[self.active] except IndexError: self.active = -1 def add_dir(self, path): count = 0 for p, ext, is_dir in listdir(path): count += self.add(p, recursive=True) return count def add_playlist(self, path): count = 0 dirname = os.path.dirname(path) with open(path, errors='replace') as fh: for line in fh: line = line.strip() if not line or line[0] == '#': continue if not re.match(r'^(/|https?://)', line): line = os.path.join(dirname, line) self.items.append(line) count += 1 return count def add(self, path, recursive=False): ext = path.rsplit('.', 1)[-1] if os.path.isdir(path): return self.add_dir(path) elif ext == 'm3u' and not recursive: return self.add_playlist(path) elif ext in AUDIO_EXTENSIONS: self.items.append(path) return 1 else: return 0 def write(self): if not self.path: return try: with open(self.path, 'w') as fh: for item in self.items: fh.write('%s\n' % item) except IOError: pass def set_path(self, path): self.path = path def process_key(self, key): if key == 'm': self.move_item(1) elif key == 'M': self.move_item(-1) elif key == 'd': self.remove_item() elif key == 'D': self.clear() elif key == 'C': self.clear() self.path = None elif key == '\n': if not self.items: return True self.active = self.cursor player.play(self.items[self.active]) elif key == '@': self.set_cursor(self.active) elif key == 's': self.shuffle() elif key == 'S': self.sort() elif key == 'r': self.repeat = not self.repeat elif key == 'R': self.random = not self.random elif key == 'w': app.input.start( 'playlist path: ', self.set_path, self.path or filelist.path ) else: return super().process_key(key) self.write() return True class Application: def __init__(self): self.tabs = [filelist, playlist] self.help = False self.input = Input() self.old_lines = [] # self-pipe to avoid concurrency issues with signal self.resize_in, self.resize_out = os.pipe2(os.O_NONBLOCK) def refresh_dimensions(self): self.rows, self.cols = screen.getmaxyx() def on_resize(self): curses.endwin() screen.refresh() self.refresh_dimensions() self.tab.set_cursor(app.tab.cursor) @property def tab(self): if self.help: return helplist else: return self.tabs[0] def toggle_tabs(self): self.tabs.append(self.tabs.pop(0)) def format_progress(self): progress = min(int(self.cols * player.get_progress()), self.cols - 1) return '=' * (progress - 1) + '|' + '-' * (self.cols - progress) def _render(self): yield (self.tab.get_title(), curses.A_BOLD) yield '-' * self.cols yield from self.tab.render() yield self.format_progress() if self.input.active: status = self.input.prompt + self.input.str elif self.tab == helplist: status = __version__ elif player.is_playing: status = 'Playing %s' % relpath(player.path) else: status = '' counter = '%s / %s' % ( format_time(player.position), format_time(player.length), ) yield space_between(status, counter, self.cols) def render(self, force=False): lines = list(self._render()) try: for i, line in enumerate(lines): if ( not force and len(self.old_lines) > i and line == self.old_lines[i] ): continue screen.move(i, 0) screen.clrtoeol() if isinstance(line, str): line = (line, 0) screen.insstr(i, 0, *line) # make sure cursor is in a meaningful position for a11y screen.move(self.tab.cursor - self.tab.position + 2, 0) screen.refresh() except curses.error: pass self.old_lines = lines def process_key(self, key): if self.input.process_key(key): pass elif self.tab.process_key(key): pass elif key in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']: set_volume(int(key, 10) / 9.0) elif key == curses.KEY_RIGHT: player.seek(1) elif key == curses.KEY_LEFT: player.seek(-1) elif key in ['x', ' ']: player.toggle() elif key == 'n': player.play(playlist.next()) elif key == 'h': self.help = True elif key in ['q', 'Q']: sys.exit(0) elif key == '\t': app.toggle_tabs() else: return False return True def run(self): self.refresh_dimensions() self.render() with selectors.DefaultSelector() as sel: sel.register(sys.stdin, selectors.EVENT_READ) sel.register(self.resize_in, selectors.EVENT_READ) sel.register(player.socket, selectors.EVENT_READ) while True: player.finish_seek() timeout = 0.5 if player.is_playing else None for key, mask in sel.select(timeout): if key.fileobj is self.resize_in: os.read(self.resize_in, 8) self.on_resize() self.render(force=True) elif key.fileobj is sys.stdin: self.process_key(screen.get_wch()) elif key.fileobj is player.socket: player.parse_progress() if player.is_finished: player.play(playlist.next()) self.render() player = Player() playlist = Playlist() filelist = Filelist() helplist = HelpList() app = Application() screen = curses.initscr() def main(): screen.keypad(True) curses.cbreak() curses.noecho() curses.meta(True) curses.curs_set(0) signal.signal(signal.SIGWINCH, resize) try: with enable_ctrl_keys(): app.run() finally: player.cleanup() curses.endwin() if __name__ == '__main__': main()
gpl-2.0
[ 646, 15429, 199, 646, 9143, 199, 646, 2022, 199, 646, 747, 199, 646, 2196, 199, 646, 295, 199, 646, 9759, 83, 199, 646, 4673, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 646, 28725, 199, 646, 900, 199, 504, 15502, 492, 27608, 199, 199, 363, 1023, 363, 275, 283, 1850, 817, 13, 2753, 841, 14, 16, 14, 16, 7, 199, 199, 27743, 63, 18451, 275, 359, 272, 283, 311, 19, 297, 283, 24798, 297, 283, 974, 65, 297, 283, 411, 527, 297, 283, 14163, 67, 297, 283, 77, 20, 65, 297, 283, 77, 20, 66, 297, 283, 19118, 297, 283, 8523, 297, 283, 87, 391, 7, 199, 61, 199, 199, 17930, 275, 408, 7025, 199, 8648, 199, 1721, 12, 1022, 263, 520, 4057, 370, 4136, 1242, 199, 3514, 12, 1335, 420, 520, 4057, 370, 2163, 1242, 199, 3276, 1721, 12, 1804, 259, 520, 4057, 370, 4136, 2034, 199, 3276, 3514, 12, 1603, 221, 520, 4057, 370, 2163, 2034, 199, 12054, 12, 486, 420, 520, 4057, 370, 2746, 199, 3005, 12, 598, 755, 520, 4057, 370, 9048, 199, 8468, 263, 520, 13097, 503, 5232, 199, 7690, 3515, 520, 6258, 3382, 26148, 15, 10411, 199, 78, 3322, 520, 2163, 4426, 199, 88, 12, 19326, 258, 520, 19420, 5232, 15, 11241, 199, 8185, 12, 20854, 221, 520, 12005, 13388, 15, 6688, 199, 15, 3322, 520, 2754, 199, 35, 13, 83, 12, 445, 13, 82, 258, 520, 2163, 15, 6352, 2754, 1336, 199, 37, 551, 3515, 520, 9311, 199, 16, 703, 25, 260, 520, 3301, 3304, 199, 72, 3322, 520, 1720, 199, 81, 12, 1413, 260, 520, 17242, 199, 199, 1173, 513, 199, 518, 199, 65, 3322, 520, 1050, 370, 13210, 199, 83, 3322, 520, 9133, 2754, 199, 11087, 3698, 520, 2621, 370, 1676, 2935, 199, 199, 27259, 199, 518, 199, 68, 12, 577, 260, 520, 3145, 1242, 15, 452, 199, 77, 12, 603, 260, 520, 4057, 1242, 3224, 15, 384, 199, 82, 12, 820, 260, 520, 19420, 11982, 15, 2355, 199, 83, 12, 428, 260, 520, 13031, 15, 3191, 13210, 199, 87, 3322, 520, 9509, 1788, 367, 1453, 13210, 199, 35, 3322, 520, 4002, 1453, 13210, 199, 32, 3322, 520, 14882, 370, 1453, 4426, 624, 421, 199, 318, 6108, 311, 8, 585, 12, 485, 827, 12, 485, 988, 304, 272, 372, 1390, 1547, 827, 12, 1748, 1547, 988, 12, 574, 430, 421, 199, 318, 4601, 63, 13007, 8, 65, 12, 330, 12, 302, 304, 272, 366, 275, 302, 446, 334, 552, 8, 65, 9, 435, 822, 8, 66, 430, 272, 340, 366, 2356, 378, 26, 267, 372, 282, 435, 283, 283, 627, 366, 435, 330, 272, 587, 26, 267, 372, 282, 1491, 68, 61, 435, 330, 421, 199, 318, 1475, 63, 521, 8, 2923, 304, 272, 394, 12, 308, 275, 16438, 8, 2923, 12, 15751, 9, 272, 333, 12, 308, 275, 16438, 8, 83, 12, 5212, 9, 272, 372, 1543, 996, 68, 2689, 996, 68, 2689, 996, 68, 7, 450, 334, 72, 12, 333, 12, 308, 9, 421, 199, 318, 620, 63, 1431, 8, 1131, 12, 308, 304, 272, 372, 1006, 8, 81, 315, 308, 14, 2325, 342, 367, 1894, 315, 1827, 14, 2325, 1252, 1294, 1012, 421, 199, 318, 663, 63, 2405, 8, 5650, 304, 272, 3873, 14, 1074, 63, 1250, 779, 267, 283, 387, 8077, 297, 2850, 297, 283, 409, 13, 11279, 13, 2405, 297, 283, 16, 297, 1543, 73, 8530, 7, 450, 1109, 8, 5650, 627, 2948, 9, 272, 4794, 421, 199, 318, 15210, 2031, 589, 304, 272, 747, 14, 952, 8, 571, 14, 8709, 63, 548, 12, 330, 1370, 358, 421, 199, 318, 664, 63, 3450, 8, 515, 304, 272, 1830, 715, 26, 267, 862, 26, 288, 6771, 275, 2838, 14, 3450, 8, 6606, 29, 3450, 14, 5699, 63, 19584, 9, 288, 6771, 14, 2242, 8, 515, 9, 288, 372, 6771, 267, 871, 334, 1173, 10870, 12, 8113, 2891, 2972, 547, 304, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 421, 199, 32, 17869, 14, 25003, 63, 1637, 342, 199, 318, 20700, 8, 515, 304, 272, 340, 931, 14, 2460, 8, 14964, 14, 515, 304, 267, 372, 931, 59, 552, 8, 14964, 14, 515, 304, 1055, 10124, 7825, 272, 587, 26, 267, 372, 747, 14, 515, 14, 12405, 8, 515, 9, 421, 199, 32, 14237, 199, 318, 4756, 63, 12476, 63, 1612, 837, 272, 6111, 275, 984, 14, 6626, 14, 9843, 342, 272, 2269, 275, 28725, 14, 3641, 5675, 8, 2592, 9, 272, 862, 26, 267, 14415, 962, 275, 28725, 14, 3641, 5675, 8, 2592, 9, 267, 14415, 962, 59, 16, 61, 275, 14415, 962, 59, 16, 61, 1253, 6146, 8, 351, 24597, 14, 3867, 615, 9, 267, 28725, 14, 3641, 10202, 8, 2592, 12, 28725, 14, 52, 3298, 879, 19716, 12, 14415, 962, 9, 267, 1995, 272, 3753, 26, 267, 28725, 14, 3641, 10202, 8, 2592, 12, 28725, 14, 52, 3298, 1554, 21715, 12, 2269, 9, 421, 199, 318, 664, 63, 832, 8, 515, 304, 272, 372, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 1055, 10124, 7563, 421, 199, 318, 27483, 8, 515, 304, 272, 543, 747, 14, 6282, 694, 8, 515, 9, 465, 652, 26, 267, 367, 2397, 315, 3355, 8, 390, 12, 790, 29, 2734, 325, 26, 325, 14, 354, 304, 288, 340, 2397, 14, 354, 59, 16, 61, 1137, 26351, 355, 1995, 334, 490, 2397, 14, 515, 12, 490, 664, 63, 832, 8, 2373, 14, 354, 395, 490, 2397, 14, 374, 63, 694, 8, 7207, 63, 19522, 29, 797, 395, 355, 776, 421, 199, 533, 25610, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 515, 275, 488, 267, 291, 14, 3124, 275, 378, 267, 291, 14, 1267, 275, 378, 267, 291, 423, 5507, 63, 2926, 275, 378, 267, 291, 423, 5507, 63, 2593, 275, 488, 267, 291, 14, 374, 63, 22224, 275, 756, 267, 291, 423, 22224, 275, 378, 267, 291, 423, 2738, 275, 330, 891, 398, 291, 14, 3450, 63, 515, 275, 1994, 2791, 15, 311, 86, 13, 1850, 817, 3295, 73, 14, 5096, 7, 450, 747, 14, 17829, 342, 267, 291, 423, 4687, 275, 3873, 14, 7942, 8, 288, 359, 355, 283, 311, 86, 297, 355, 2850, 1210, 13 ]
[ 15429, 199, 646, 9143, 199, 646, 2022, 199, 646, 747, 199, 646, 2196, 199, 646, 295, 199, 646, 9759, 83, 199, 646, 4673, 199, 646, 2838, 199, 646, 3873, 199, 646, 984, 199, 646, 28725, 199, 646, 900, 199, 504, 15502, 492, 27608, 199, 199, 363, 1023, 363, 275, 283, 1850, 817, 13, 2753, 841, 14, 16, 14, 16, 7, 199, 199, 27743, 63, 18451, 275, 359, 272, 283, 311, 19, 297, 283, 24798, 297, 283, 974, 65, 297, 283, 411, 527, 297, 283, 14163, 67, 297, 283, 77, 20, 65, 297, 283, 77, 20, 66, 297, 283, 19118, 297, 283, 8523, 297, 283, 87, 391, 7, 199, 61, 199, 199, 17930, 275, 408, 7025, 199, 8648, 199, 1721, 12, 1022, 263, 520, 4057, 370, 4136, 1242, 199, 3514, 12, 1335, 420, 520, 4057, 370, 2163, 1242, 199, 3276, 1721, 12, 1804, 259, 520, 4057, 370, 4136, 2034, 199, 3276, 3514, 12, 1603, 221, 520, 4057, 370, 2163, 2034, 199, 12054, 12, 486, 420, 520, 4057, 370, 2746, 199, 3005, 12, 598, 755, 520, 4057, 370, 9048, 199, 8468, 263, 520, 13097, 503, 5232, 199, 7690, 3515, 520, 6258, 3382, 26148, 15, 10411, 199, 78, 3322, 520, 2163, 4426, 199, 88, 12, 19326, 258, 520, 19420, 5232, 15, 11241, 199, 8185, 12, 20854, 221, 520, 12005, 13388, 15, 6688, 199, 15, 3322, 520, 2754, 199, 35, 13, 83, 12, 445, 13, 82, 258, 520, 2163, 15, 6352, 2754, 1336, 199, 37, 551, 3515, 520, 9311, 199, 16, 703, 25, 260, 520, 3301, 3304, 199, 72, 3322, 520, 1720, 199, 81, 12, 1413, 260, 520, 17242, 199, 199, 1173, 513, 199, 518, 199, 65, 3322, 520, 1050, 370, 13210, 199, 83, 3322, 520, 9133, 2754, 199, 11087, 3698, 520, 2621, 370, 1676, 2935, 199, 199, 27259, 199, 518, 199, 68, 12, 577, 260, 520, 3145, 1242, 15, 452, 199, 77, 12, 603, 260, 520, 4057, 1242, 3224, 15, 384, 199, 82, 12, 820, 260, 520, 19420, 11982, 15, 2355, 199, 83, 12, 428, 260, 520, 13031, 15, 3191, 13210, 199, 87, 3322, 520, 9509, 1788, 367, 1453, 13210, 199, 35, 3322, 520, 4002, 1453, 13210, 199, 32, 3322, 520, 14882, 370, 1453, 4426, 624, 421, 199, 318, 6108, 311, 8, 585, 12, 485, 827, 12, 485, 988, 304, 272, 372, 1390, 1547, 827, 12, 1748, 1547, 988, 12, 574, 430, 421, 199, 318, 4601, 63, 13007, 8, 65, 12, 330, 12, 302, 304, 272, 366, 275, 302, 446, 334, 552, 8, 65, 9, 435, 822, 8, 66, 430, 272, 340, 366, 2356, 378, 26, 267, 372, 282, 435, 283, 283, 627, 366, 435, 330, 272, 587, 26, 267, 372, 282, 1491, 68, 61, 435, 330, 421, 199, 318, 1475, 63, 521, 8, 2923, 304, 272, 394, 12, 308, 275, 16438, 8, 2923, 12, 15751, 9, 272, 333, 12, 308, 275, 16438, 8, 83, 12, 5212, 9, 272, 372, 1543, 996, 68, 2689, 996, 68, 2689, 996, 68, 7, 450, 334, 72, 12, 333, 12, 308, 9, 421, 199, 318, 620, 63, 1431, 8, 1131, 12, 308, 304, 272, 372, 1006, 8, 81, 315, 308, 14, 2325, 342, 367, 1894, 315, 1827, 14, 2325, 1252, 1294, 1012, 421, 199, 318, 663, 63, 2405, 8, 5650, 304, 272, 3873, 14, 1074, 63, 1250, 779, 267, 283, 387, 8077, 297, 2850, 297, 283, 409, 13, 11279, 13, 2405, 297, 283, 16, 297, 1543, 73, 8530, 7, 450, 1109, 8, 5650, 627, 2948, 9, 272, 4794, 421, 199, 318, 15210, 2031, 589, 304, 272, 747, 14, 952, 8, 571, 14, 8709, 63, 548, 12, 330, 1370, 358, 421, 199, 318, 664, 63, 3450, 8, 515, 304, 272, 1830, 715, 26, 267, 862, 26, 288, 6771, 275, 2838, 14, 3450, 8, 6606, 29, 3450, 14, 5699, 63, 19584, 9, 288, 6771, 14, 2242, 8, 515, 9, 288, 372, 6771, 267, 871, 334, 1173, 10870, 12, 8113, 2891, 2972, 547, 304, 288, 900, 14, 4532, 8, 16, 14, 17, 9, 421, 199, 32, 17869, 14, 25003, 63, 1637, 342, 199, 318, 20700, 8, 515, 304, 272, 340, 931, 14, 2460, 8, 14964, 14, 515, 304, 267, 372, 931, 59, 552, 8, 14964, 14, 515, 304, 1055, 10124, 7825, 272, 587, 26, 267, 372, 747, 14, 515, 14, 12405, 8, 515, 9, 421, 199, 32, 14237, 199, 318, 4756, 63, 12476, 63, 1612, 837, 272, 6111, 275, 984, 14, 6626, 14, 9843, 342, 272, 2269, 275, 28725, 14, 3641, 5675, 8, 2592, 9, 272, 862, 26, 267, 14415, 962, 275, 28725, 14, 3641, 5675, 8, 2592, 9, 267, 14415, 962, 59, 16, 61, 275, 14415, 962, 59, 16, 61, 1253, 6146, 8, 351, 24597, 14, 3867, 615, 9, 267, 28725, 14, 3641, 10202, 8, 2592, 12, 28725, 14, 52, 3298, 879, 19716, 12, 14415, 962, 9, 267, 1995, 272, 3753, 26, 267, 28725, 14, 3641, 10202, 8, 2592, 12, 28725, 14, 52, 3298, 1554, 21715, 12, 2269, 9, 421, 199, 318, 664, 63, 832, 8, 515, 304, 272, 372, 747, 14, 515, 14, 7973, 8, 515, 2788, 17, 1055, 10124, 7563, 421, 199, 318, 27483, 8, 515, 304, 272, 543, 747, 14, 6282, 694, 8, 515, 9, 465, 652, 26, 267, 367, 2397, 315, 3355, 8, 390, 12, 790, 29, 2734, 325, 26, 325, 14, 354, 304, 288, 340, 2397, 14, 354, 59, 16, 61, 1137, 26351, 355, 1995, 334, 490, 2397, 14, 515, 12, 490, 664, 63, 832, 8, 2373, 14, 354, 395, 490, 2397, 14, 374, 63, 694, 8, 7207, 63, 19522, 29, 797, 395, 355, 776, 421, 199, 533, 25610, 26, 272, 347, 636, 826, 721, 277, 304, 267, 291, 14, 515, 275, 488, 267, 291, 14, 3124, 275, 378, 267, 291, 14, 1267, 275, 378, 267, 291, 423, 5507, 63, 2926, 275, 378, 267, 291, 423, 5507, 63, 2593, 275, 488, 267, 291, 14, 374, 63, 22224, 275, 756, 267, 291, 423, 22224, 275, 378, 267, 291, 423, 2738, 275, 330, 891, 398, 291, 14, 3450, 63, 515, 275, 1994, 2791, 15, 311, 86, 13, 1850, 817, 3295, 73, 14, 5096, 7, 450, 747, 14, 17829, 342, 267, 291, 423, 4687, 275, 3873, 14, 7942, 8, 288, 359, 355, 283, 311, 86, 297, 355, 2850, 1210, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
queenp/wakatime
wakatime/packages/pygments_py3/pygments/token.py
125
5772
# -*- coding: utf-8 -*- """ pygments.token ~~~~~~~~~~~~~~ Basic token types and the standard tokens. :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ class _TokenType(tuple): parent = None def split(self): buf = [] node = self while node is not None: buf.append(node) node = node.parent buf.reverse() return buf def __init__(self, *args): # no need to call super.__init__ self.subtypes = set() def __contains__(self, val): return self is val or ( type(val) is self.__class__ and val[:len(self)] == self ) def __getattr__(self, val): if not val or not val[0].isupper(): return tuple.__getattribute__(self, val) new = _TokenType(self + (val,)) setattr(self, val, new) self.subtypes.add(new) new.parent = self return new def __repr__(self): return 'Token' + (self and '.' or '') + '.'.join(self) Token = _TokenType() # Special token types Text = Token.Text Whitespace = Text.Whitespace Escape = Token.Escape Error = Token.Error # Text that doesn't belong to this lexer (e.g. HTML in PHP) Other = Token.Other # Common token types for source code Keyword = Token.Keyword Name = Token.Name Literal = Token.Literal String = Literal.String Number = Literal.Number Punctuation = Token.Punctuation Operator = Token.Operator Comment = Token.Comment # Generic types for non-source code Generic = Token.Generic # String and some others are not direct childs of Token. # alias them: Token.Token = Token Token.String = String Token.Number = Number def is_token_subtype(ttype, other): """ Return True if ``ttype`` is a subtype of ``other``. exists for backwards compatibility. use ``ttype in other`` now. """ return ttype in other def string_to_tokentype(s): """ Convert a string into a token type:: >>> string_to_token('String.Double') Token.Literal.String.Double >>> string_to_token('Token.Literal.Number') Token.Literal.Number >>> string_to_token('') Token Tokens that are already tokens are returned unchanged: >>> string_to_token(String) Token.Literal.String """ if isinstance(s, _TokenType): return s if not s: return Token node = Token for item in s.split('.'): node = getattr(node, item) return node # Map standard token types to short names, used in CSS class naming. # If you add a new item, please be sure to run this file to perform # a consistency check for duplicate values. STANDARD_TYPES = { Token: '', Text: '', Whitespace: 'w', Escape: 'esc', Error: 'err', Other: 'x', Keyword: 'k', Keyword.Constant: 'kc', Keyword.Declaration: 'kd', Keyword.Namespace: 'kn', Keyword.Pseudo: 'kp', Keyword.Reserved: 'kr', Keyword.Type: 'kt', Name: 'n', Name.Attribute: 'na', Name.Builtin: 'nb', Name.Builtin.Pseudo: 'bp', Name.Class: 'nc', Name.Constant: 'no', Name.Decorator: 'nd', Name.Entity: 'ni', Name.Exception: 'ne', Name.Function: 'nf', Name.Property: 'py', Name.Label: 'nl', Name.Namespace: 'nn', Name.Other: 'nx', Name.Tag: 'nt', Name.Variable: 'nv', Name.Variable.Class: 'vc', Name.Variable.Global: 'vg', Name.Variable.Instance: 'vi', Literal: 'l', Literal.Date: 'ld', String: 's', String.Backtick: 'sb', String.Char: 'sc', String.Doc: 'sd', String.Double: 's2', String.Escape: 'se', String.Heredoc: 'sh', String.Interpol: 'si', String.Other: 'sx', String.Regex: 'sr', String.Single: 's1', String.Symbol: 'ss', Number: 'm', Number.Bin: 'mb', Number.Float: 'mf', Number.Hex: 'mh', Number.Integer: 'mi', Number.Integer.Long: 'il', Number.Oct: 'mo', Operator: 'o', Operator.Word: 'ow', Punctuation: 'p', Comment: 'c', Comment.Multiline: 'cm', Comment.Preproc: 'cp', Comment.Single: 'c1', Comment.Special: 'cs', Generic: 'g', Generic.Deleted: 'gd', Generic.Emph: 'ge', Generic.Error: 'gr', Generic.Heading: 'gh', Generic.Inserted: 'gi', Generic.Output: 'go', Generic.Prompt: 'gp', Generic.Strong: 'gs', Generic.Subheading: 'gu', Generic.Traceback: 'gt', }
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 1418, 272, 32202, 1714, 339, 10082, 1526, 2943, 436, 314, 4465, 4645, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7280, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 533, 485, 3264, 804, 8, 2960, 304, 272, 1676, 275, 488, 339, 347, 3715, 8, 277, 304, 267, 4123, 275, 942, 267, 1031, 275, 291, 267, 1830, 1031, 365, 440, 488, 26, 288, 4123, 14, 740, 8, 932, 9, 288, 1031, 275, 1031, 14, 1708, 267, 4123, 14, 4471, 342, 267, 372, 4123, 339, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 327, 949, 1929, 370, 1240, 1613, 855, 826, 363, 267, 291, 14, 954, 1313, 275, 663, 342, 339, 347, 636, 6134, 721, 277, 12, 1139, 304, 267, 372, 291, 365, 1139, 503, 334, 288, 730, 8, 637, 9, 365, 291, 855, 533, 363, 436, 288, 1139, 1491, 552, 8, 277, 1874, 508, 291, 267, 776, 339, 347, 636, 5675, 721, 277, 12, 1139, 304, 267, 340, 440, 1139, 503, 440, 1139, 59, 16, 1055, 374, 4142, 837, 288, 372, 2008, 855, 18480, 721, 277, 12, 1139, 9, 267, 892, 275, 485, 3264, 804, 8, 277, 435, 334, 637, 4641, 267, 5371, 8, 277, 12, 1139, 12, 892, 9, 267, 291, 14, 954, 1313, 14, 525, 8, 1222, 9, 267, 892, 14, 1708, 275, 291, 267, 372, 892, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 3264, 7, 435, 334, 277, 436, 7815, 503, 4074, 435, 15671, 904, 8, 277, 9, 421, 199, 3264, 755, 275, 485, 3264, 804, 342, 199, 199, 3, 12568, 1526, 2943, 199, 1872, 263, 275, 8767, 14, 1872, 199, 16552, 221, 275, 4516, 14, 16552, 199, 10260, 420, 275, 8767, 14, 10260, 199, 547, 755, 275, 8767, 14, 547, 199, 3, 4516, 626, 3181, 1133, 13511, 370, 642, 10426, 334, 69, 14, 71, 14, 4163, 315, 510, 18635, 9, 199, 8632, 755, 275, 8767, 14, 8632, 199, 199, 3, 13964, 1526, 2943, 367, 1350, 1233, 199, 10650, 258, 275, 8767, 14, 10650, 199, 985, 263, 275, 8767, 14, 985, 199, 7621, 258, 275, 8767, 14, 7621, 199, 1558, 420, 275, 18271, 14, 1558, 199, 3259, 420, 275, 18271, 14, 3259, 199, 48, 7771, 275, 8767, 14, 48, 7771, 199, 7961, 259, 275, 8767, 14, 7961, 199, 7488, 258, 275, 8767, 14, 7488, 199, 199, 3, 8307, 2943, 367, 2222, 13, 1365, 1233, 199, 9417, 258, 275, 8767, 14, 9417, 199, 199, 3, 2624, 436, 2005, 11789, 787, 440, 4125, 1982, 83, 402, 8767, 14, 199, 3, 5162, 3062, 26, 199, 3264, 14, 3264, 275, 8767, 199, 3264, 14, 1558, 275, 2624, 199, 3264, 14, 3259, 275, 4860, 421, 199, 318, 365, 63, 1418, 63, 10512, 8, 21002, 12, 1163, 304, 272, 408, 272, 1432, 715, 340, 1124, 21002, 1040, 365, 282, 15686, 402, 1124, 1848, 4345, 339, 3495, 367, 8552, 7163, 14, 675, 1124, 21002, 315, 1163, 1040, 3063, 14, 272, 408, 272, 372, 17860, 315, 1163, 421, 199, 318, 1059, 63, 475, 63, 1418, 466, 8, 83, 304, 272, 408, 272, 7905, 282, 1059, 1901, 282, 1526, 730, 447, 398, 1306, 1059, 63, 475, 63, 1418, 360, 1558, 14, 7281, 358, 267, 8767, 14, 7621, 14, 1558, 14, 7281, 267, 1306, 1059, 63, 475, 63, 1418, 360, 3264, 14, 7621, 14, 3259, 358, 267, 8767, 14, 7621, 14, 3259, 267, 1306, 1059, 63, 475, 63, 1418, 8355, 267, 8767, 339, 8767, 83, 626, 787, 2575, 4645, 787, 2138, 14874, 26, 398, 1306, 1059, 63, 475, 63, 1418, 8, 1558, 9, 267, 8767, 14, 7621, 14, 1558, 272, 408, 272, 340, 1228, 8, 83, 12, 485, 3264, 804, 304, 267, 372, 308, 272, 340, 440, 308, 26, 267, 372, 8767, 272, 1031, 275, 8767, 272, 367, 1242, 315, 308, 14, 1294, 26461, 267, 1031, 275, 2519, 8, 932, 12, 1242, 9, 272, 372, 1031, 421, 199, 3, 9672, 4465, 1526, 2943, 370, 3974, 1561, 12, 1202, 315, 15750, 1021, 19720, 14, 199, 3, 982, 1265, 1050, 282, 892, 1242, 12, 8749, 506, 3238, 370, 1255, 642, 570, 370, 5147, 199, 3, 282, 17754, 1104, 367, 9250, 1338, 14, 199, 19547, 63, 7893, 275, 469, 272, 8767, 26, 12793, 3260, 339, 4516, 26, 14516, 3260, 272, 24403, 26, 8540, 283, 87, 297, 272, 21067, 26, 12788, 283, 19303, 297, 272, 4520, 26, 12793, 283, 1508, 297, 272, 5439, 26, 12793, 283, 88, 297, 339, 6431, 26, 9668, 283, 75, 297, 272, 6431, 14, 9737, 26, 4519, 283, 75, 67, 297, 272, 6431, 14, 17737, 26, 3698, 283, 25606, 297, 272, 6431, 14, 8814, 26, 3777, 283, 18974, 297, 272, 6431, 14, 23414, 26, 4483, 283, 25017, 297, 272, 6431, 14, 10285, 26, 4519, 283, 16779, 297, 272, 6431, 14, 804, 26, 8295, 283, 5973, 297, 339, 2812, 26, 14516, 283, 78, 297, 272, 2812, 14, 1646, 26, 4483, 283, 3540, 297, 272, 2812, 14, 12306, 26, 8295, 283, 4994, 297, 272, 2812, 14, 12306, 14, 23414, 26, 3698, 283, 10913, 297, 272, 2812, 14, 2543, 26, 8540, 283, 7966, 297, 272, 2812, 14, 9737, 26, 463, 283, 889, 297, 272, 2812, 14, 14946, 26, 4483, 283, 977, 297, 272, 2812, 14, 7302, 26, 7861, 283, 8445, 297, 272, 2812, 14, 1726, 26, 4483, 283, 685, 297, 272, 2812, 14, 3481, 26, 463, 283, 9914, 297, 272, 2812, 14, 3697, 26, 463, 283, 647, 297, 272, 2812, 14, 4314, 26, 8540, 283, 7530, 297, 272, 2812, 14, 8814, 26, 4483, 283, 4411, 297, 272, 2812, 14, 8632, 26, 8540, 283, 7343, 297, 272, 2812, 14, 1931, 26, 10473, 283, 343, 297, 272, 2812, 14, 2773, 26, 463, 283, 15969, 297, 272, 2812, 14, 2773, 14, 2543, 26, 3698, 283, 6737, 297, 272, 2812, 14, 2773, 14, 7025, 26, 3515, 283, 10929, 297, 272, 2812, 14, 2773, 14, 3244, 26, 263, 283, 433, 297, 339, 18271, 26, 9668, 283, 76, 297, 272, 18271, 14, 2506, 26, 8295, 283, 1447, 297, 339, 2624, 26, 12788, 283, 83, 297, 272, 2624, 14, 4540, 8284, 26, 5185, 283, 9264, 297, 272, 2624, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 13277, 14, 1418, 272, 32202, 1714, 339, 10082, 1526, 2943, 436, 314, 4465, 4645, 14, 339, 520, 7307, 26, 1898, 8315, 13, 7280, 701, 314, 14493, 8099, 12, 1937, 10610, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 2436, 14, 199, 624, 199, 199, 533, 485, 3264, 804, 8, 2960, 304, 272, 1676, 275, 488, 339, 347, 3715, 8, 277, 304, 267, 4123, 275, 942, 267, 1031, 275, 291, 267, 1830, 1031, 365, 440, 488, 26, 288, 4123, 14, 740, 8, 932, 9, 288, 1031, 275, 1031, 14, 1708, 267, 4123, 14, 4471, 342, 267, 372, 4123, 339, 347, 636, 826, 721, 277, 12, 627, 589, 304, 267, 327, 949, 1929, 370, 1240, 1613, 855, 826, 363, 267, 291, 14, 954, 1313, 275, 663, 342, 339, 347, 636, 6134, 721, 277, 12, 1139, 304, 267, 372, 291, 365, 1139, 503, 334, 288, 730, 8, 637, 9, 365, 291, 855, 533, 363, 436, 288, 1139, 1491, 552, 8, 277, 1874, 508, 291, 267, 776, 339, 347, 636, 5675, 721, 277, 12, 1139, 304, 267, 340, 440, 1139, 503, 440, 1139, 59, 16, 1055, 374, 4142, 837, 288, 372, 2008, 855, 18480, 721, 277, 12, 1139, 9, 267, 892, 275, 485, 3264, 804, 8, 277, 435, 334, 637, 4641, 267, 5371, 8, 277, 12, 1139, 12, 892, 9, 267, 291, 14, 954, 1313, 14, 525, 8, 1222, 9, 267, 892, 14, 1708, 275, 291, 267, 372, 892, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 3264, 7, 435, 334, 277, 436, 7815, 503, 4074, 435, 15671, 904, 8, 277, 9, 421, 199, 3264, 755, 275, 485, 3264, 804, 342, 199, 199, 3, 12568, 1526, 2943, 199, 1872, 263, 275, 8767, 14, 1872, 199, 16552, 221, 275, 4516, 14, 16552, 199, 10260, 420, 275, 8767, 14, 10260, 199, 547, 755, 275, 8767, 14, 547, 199, 3, 4516, 626, 3181, 1133, 13511, 370, 642, 10426, 334, 69, 14, 71, 14, 4163, 315, 510, 18635, 9, 199, 8632, 755, 275, 8767, 14, 8632, 199, 199, 3, 13964, 1526, 2943, 367, 1350, 1233, 199, 10650, 258, 275, 8767, 14, 10650, 199, 985, 263, 275, 8767, 14, 985, 199, 7621, 258, 275, 8767, 14, 7621, 199, 1558, 420, 275, 18271, 14, 1558, 199, 3259, 420, 275, 18271, 14, 3259, 199, 48, 7771, 275, 8767, 14, 48, 7771, 199, 7961, 259, 275, 8767, 14, 7961, 199, 7488, 258, 275, 8767, 14, 7488, 199, 199, 3, 8307, 2943, 367, 2222, 13, 1365, 1233, 199, 9417, 258, 275, 8767, 14, 9417, 199, 199, 3, 2624, 436, 2005, 11789, 787, 440, 4125, 1982, 83, 402, 8767, 14, 199, 3, 5162, 3062, 26, 199, 3264, 14, 3264, 275, 8767, 199, 3264, 14, 1558, 275, 2624, 199, 3264, 14, 3259, 275, 4860, 421, 199, 318, 365, 63, 1418, 63, 10512, 8, 21002, 12, 1163, 304, 272, 408, 272, 1432, 715, 340, 1124, 21002, 1040, 365, 282, 15686, 402, 1124, 1848, 4345, 339, 3495, 367, 8552, 7163, 14, 675, 1124, 21002, 315, 1163, 1040, 3063, 14, 272, 408, 272, 372, 17860, 315, 1163, 421, 199, 318, 1059, 63, 475, 63, 1418, 466, 8, 83, 304, 272, 408, 272, 7905, 282, 1059, 1901, 282, 1526, 730, 447, 398, 1306, 1059, 63, 475, 63, 1418, 360, 1558, 14, 7281, 358, 267, 8767, 14, 7621, 14, 1558, 14, 7281, 267, 1306, 1059, 63, 475, 63, 1418, 360, 3264, 14, 7621, 14, 3259, 358, 267, 8767, 14, 7621, 14, 3259, 267, 1306, 1059, 63, 475, 63, 1418, 8355, 267, 8767, 339, 8767, 83, 626, 787, 2575, 4645, 787, 2138, 14874, 26, 398, 1306, 1059, 63, 475, 63, 1418, 8, 1558, 9, 267, 8767, 14, 7621, 14, 1558, 272, 408, 272, 340, 1228, 8, 83, 12, 485, 3264, 804, 304, 267, 372, 308, 272, 340, 440, 308, 26, 267, 372, 8767, 272, 1031, 275, 8767, 272, 367, 1242, 315, 308, 14, 1294, 26461, 267, 1031, 275, 2519, 8, 932, 12, 1242, 9, 272, 372, 1031, 421, 199, 3, 9672, 4465, 1526, 2943, 370, 3974, 1561, 12, 1202, 315, 15750, 1021, 19720, 14, 199, 3, 982, 1265, 1050, 282, 892, 1242, 12, 8749, 506, 3238, 370, 1255, 642, 570, 370, 5147, 199, 3, 282, 17754, 1104, 367, 9250, 1338, 14, 199, 19547, 63, 7893, 275, 469, 272, 8767, 26, 12793, 3260, 339, 4516, 26, 14516, 3260, 272, 24403, 26, 8540, 283, 87, 297, 272, 21067, 26, 12788, 283, 19303, 297, 272, 4520, 26, 12793, 283, 1508, 297, 272, 5439, 26, 12793, 283, 88, 297, 339, 6431, 26, 9668, 283, 75, 297, 272, 6431, 14, 9737, 26, 4519, 283, 75, 67, 297, 272, 6431, 14, 17737, 26, 3698, 283, 25606, 297, 272, 6431, 14, 8814, 26, 3777, 283, 18974, 297, 272, 6431, 14, 23414, 26, 4483, 283, 25017, 297, 272, 6431, 14, 10285, 26, 4519, 283, 16779, 297, 272, 6431, 14, 804, 26, 8295, 283, 5973, 297, 339, 2812, 26, 14516, 283, 78, 297, 272, 2812, 14, 1646, 26, 4483, 283, 3540, 297, 272, 2812, 14, 12306, 26, 8295, 283, 4994, 297, 272, 2812, 14, 12306, 14, 23414, 26, 3698, 283, 10913, 297, 272, 2812, 14, 2543, 26, 8540, 283, 7966, 297, 272, 2812, 14, 9737, 26, 463, 283, 889, 297, 272, 2812, 14, 14946, 26, 4483, 283, 977, 297, 272, 2812, 14, 7302, 26, 7861, 283, 8445, 297, 272, 2812, 14, 1726, 26, 4483, 283, 685, 297, 272, 2812, 14, 3481, 26, 463, 283, 9914, 297, 272, 2812, 14, 3697, 26, 463, 283, 647, 297, 272, 2812, 14, 4314, 26, 8540, 283, 7530, 297, 272, 2812, 14, 8814, 26, 4483, 283, 4411, 297, 272, 2812, 14, 8632, 26, 8540, 283, 7343, 297, 272, 2812, 14, 1931, 26, 10473, 283, 343, 297, 272, 2812, 14, 2773, 26, 463, 283, 15969, 297, 272, 2812, 14, 2773, 14, 2543, 26, 3698, 283, 6737, 297, 272, 2812, 14, 2773, 14, 7025, 26, 3515, 283, 10929, 297, 272, 2812, 14, 2773, 14, 3244, 26, 263, 283, 433, 297, 339, 18271, 26, 9668, 283, 76, 297, 272, 18271, 14, 2506, 26, 8295, 283, 1447, 297, 339, 2624, 26, 12788, 283, 83, 297, 272, 2624, 14, 4540, 8284, 26, 5185, 283, 9264, 297, 272, 2624, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
JasonSanchez/w261
week2/NaiveBayesL.py
1
1635
import sys import re from mrjob.job import MRJob from mrjob.step import MRStep from mrjob.protocol import TextProtocol, TextValueProtocol # Prevents broken pipe errors from using ... | head from signal import signal, SIGPIPE, SIG_DFL signal(SIGPIPE,SIG_DFL) def sum_hs(counts): h_total, s_total = 0, 0 for h, s in counts: h_total += h s_total += s return (h_total, s_total) class NaiveBayesL(MRJob): MRJob.OUTPUT_PROTOCOL = TextValueProtocol def mapper(self, _, lines): _, spam, subject, email = lines.split("\t") words = re.findall(r'[a-z]+', (email.lower()+" "+subject.lower())) if spam == "1": h, s = 0, 1 else: h, s = 1, 0 yield "***Total Emails", (h, s) for word in words: yield word, (h, s) yield "***Total Words", (h, s) def combiner(self, key, count): yield key, sum_hs(count) def reducer_init(self): self.total_ham = 0 self.total_spam = 0 def reducer(self, key, count): ham, spam = sum_hs(count) if key.startswith("***"): if "Words" in key: self.total_ham, self.total_spam = ham, spam elif "Emails" in key: total = ham + spam yield "_", "***Priors\t%.10f\t%.10f" % (ham/total, spam/total) else: pg_ham, pg_spam = (ham+1)/self.total_ham, (spam+1)/self.total_spam yield "_", "%s\t%.10f\t%.10f" % (key, pg_ham, pg_spam) if __name__ == "__main__": NaiveBayesL.run()
mit
[ 199, 646, 984, 199, 646, 295, 199, 504, 25478, 2423, 14, 2423, 492, 603, 50, 6694, 199, 504, 25478, 2423, 14, 2926, 492, 603, 50, 7801, 199, 504, 25478, 2423, 14, 3922, 492, 4516, 3658, 12, 4516, 1110, 3658, 199, 199, 3, 29861, 83, 10529, 5200, 2552, 687, 1808, 2263, 1204, 4854, 199, 504, 4673, 492, 4673, 12, 15522, 6089, 12, 15522, 63, 36, 3143, 199, 4653, 8, 7864, 6089, 12, 7864, 63, 36, 3143, 9, 9948, 199, 318, 3089, 63, 4213, 8, 6851, 304, 272, 394, 63, 2923, 12, 308, 63, 2923, 275, 378, 12, 378, 272, 367, 394, 12, 308, 315, 8242, 26, 267, 394, 63, 2923, 847, 394, 267, 308, 63, 2923, 847, 308, 272, 372, 334, 72, 63, 2923, 12, 308, 63, 2923, 9, 421, 199, 533, 11290, 1912, 29115, 397, 44, 8, 22153, 6694, 304, 272, 603, 50, 6694, 14, 8414, 63, 9583, 275, 4516, 1110, 3658, 339, 347, 7796, 8, 277, 12, 5501, 2385, 304, 267, 5501, 14909, 12, 5420, 12, 3031, 275, 2385, 14, 1294, 4582, 84, 531, 267, 5932, 275, 295, 14, 6452, 8, 82, 3894, 65, 13, 90, 11529, 334, 2123, 14, 2325, 342, 5207, 7210, 5875, 14, 2325, 4059, 2728, 340, 14909, 508, 298, 17, 582, 288, 394, 12, 308, 275, 378, 12, 413, 267, 587, 26, 288, 394, 12, 308, 275, 413, 12, 378, 18418, 1995, 298, 9153, 7316, 11426, 83, 401, 334, 72, 12, 308, 9, 2728, 367, 4349, 315, 5932, 26, 288, 1995, 4349, 12, 334, 72, 12, 308, 9, 288, 1995, 298, 9153, 7316, 644, 5630, 401, 334, 72, 12, 308, 9, 2151, 272, 347, 5300, 16187, 8, 277, 12, 790, 12, 2338, 304, 267, 1995, 790, 12, 3089, 63, 4213, 8, 835, 9, 2286, 347, 295, 7610, 63, 826, 8, 277, 304, 267, 291, 14, 2923, 63, 10670, 275, 378, 267, 291, 14, 2923, 63, 8283, 275, 378, 5493, 347, 295, 7610, 8, 277, 12, 790, 12, 2338, 304, 267, 24868, 12, 14909, 275, 3089, 63, 4213, 8, 835, 9, 267, 340, 790, 14, 2460, 480, 9153, 2349, 288, 340, 298, 23759, 2, 315, 790, 26, 355, 291, 14, 2923, 63, 10670, 12, 291, 14, 2923, 63, 8283, 275, 24868, 12, 14909, 288, 916, 298, 7035, 83, 2, 315, 790, 26, 355, 3141, 275, 24868, 435, 14909, 355, 1995, 2668, 401, 298, 9153, 4562, 1384, 60, 84, 17229, 709, 70, 60, 84, 17229, 709, 70, 2, 450, 334, 10670, 15, 2923, 12, 14909, 15, 2923, 9, 267, 587, 26, 288, 10275, 63, 10670, 12, 10275, 63, 8283, 275, 334, 10670, 11, 17, 2447, 277, 14, 2923, 63, 10670, 12, 334, 8283, 11, 17, 2447, 277, 14, 2923, 63, 8283, 288, 1995, 2668, 401, 2071, 83, 60, 84, 17229, 709, 70, 60, 84, 17229, 709, 70, 2, 450, 334, 498, 12, 10275, 63, 10670, 12, 10275, 63, 8283, 9, 1362, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11290, 1912, 29115, 397, 44, 14, 1065, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 646, 984, 199, 646, 295, 199, 504, 25478, 2423, 14, 2423, 492, 603, 50, 6694, 199, 504, 25478, 2423, 14, 2926, 492, 603, 50, 7801, 199, 504, 25478, 2423, 14, 3922, 492, 4516, 3658, 12, 4516, 1110, 3658, 199, 199, 3, 29861, 83, 10529, 5200, 2552, 687, 1808, 2263, 1204, 4854, 199, 504, 4673, 492, 4673, 12, 15522, 6089, 12, 15522, 63, 36, 3143, 199, 4653, 8, 7864, 6089, 12, 7864, 63, 36, 3143, 9, 9948, 199, 318, 3089, 63, 4213, 8, 6851, 304, 272, 394, 63, 2923, 12, 308, 63, 2923, 275, 378, 12, 378, 272, 367, 394, 12, 308, 315, 8242, 26, 267, 394, 63, 2923, 847, 394, 267, 308, 63, 2923, 847, 308, 272, 372, 334, 72, 63, 2923, 12, 308, 63, 2923, 9, 421, 199, 533, 11290, 1912, 29115, 397, 44, 8, 22153, 6694, 304, 272, 603, 50, 6694, 14, 8414, 63, 9583, 275, 4516, 1110, 3658, 339, 347, 7796, 8, 277, 12, 5501, 2385, 304, 267, 5501, 14909, 12, 5420, 12, 3031, 275, 2385, 14, 1294, 4582, 84, 531, 267, 5932, 275, 295, 14, 6452, 8, 82, 3894, 65, 13, 90, 11529, 334, 2123, 14, 2325, 342, 5207, 7210, 5875, 14, 2325, 4059, 2728, 340, 14909, 508, 298, 17, 582, 288, 394, 12, 308, 275, 378, 12, 413, 267, 587, 26, 288, 394, 12, 308, 275, 413, 12, 378, 18418, 1995, 298, 9153, 7316, 11426, 83, 401, 334, 72, 12, 308, 9, 2728, 367, 4349, 315, 5932, 26, 288, 1995, 4349, 12, 334, 72, 12, 308, 9, 288, 1995, 298, 9153, 7316, 644, 5630, 401, 334, 72, 12, 308, 9, 2151, 272, 347, 5300, 16187, 8, 277, 12, 790, 12, 2338, 304, 267, 1995, 790, 12, 3089, 63, 4213, 8, 835, 9, 2286, 347, 295, 7610, 63, 826, 8, 277, 304, 267, 291, 14, 2923, 63, 10670, 275, 378, 267, 291, 14, 2923, 63, 8283, 275, 378, 5493, 347, 295, 7610, 8, 277, 12, 790, 12, 2338, 304, 267, 24868, 12, 14909, 275, 3089, 63, 4213, 8, 835, 9, 267, 340, 790, 14, 2460, 480, 9153, 2349, 288, 340, 298, 23759, 2, 315, 790, 26, 355, 291, 14, 2923, 63, 10670, 12, 291, 14, 2923, 63, 8283, 275, 24868, 12, 14909, 288, 916, 298, 7035, 83, 2, 315, 790, 26, 355, 3141, 275, 24868, 435, 14909, 355, 1995, 2668, 401, 298, 9153, 4562, 1384, 60, 84, 17229, 709, 70, 60, 84, 17229, 709, 70, 2, 450, 334, 10670, 15, 2923, 12, 14909, 15, 2923, 9, 267, 587, 26, 288, 10275, 63, 10670, 12, 10275, 63, 8283, 275, 334, 10670, 11, 17, 2447, 277, 14, 2923, 63, 10670, 12, 334, 8283, 11, 17, 2447, 277, 14, 2923, 63, 8283, 288, 1995, 2668, 401, 2071, 83, 60, 84, 17229, 709, 70, 60, 84, 17229, 709, 70, 2, 450, 334, 498, 12, 10275, 63, 10670, 12, 10275, 63, 8283, 9, 1362, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 11290, 1912, 29115, 397, 44, 14, 1065, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
alu042/edx-platform
lms/djangoapps/course_api/blocks/transformers/block_counts.py
35
1703
""" Block Counts Transformer """ from openedx.core.lib.block_structure.transformer import BlockStructureTransformer class BlockCountsTransformer(BlockStructureTransformer): """ Keep a count of descendant blocks of the requested types """ VERSION = 1 BLOCK_COUNTS = 'block_counts' def __init__(self, block_types_to_count): self.block_types_to_count = block_types_to_count @classmethod def name(cls): return "blocks_api:block_counts" @classmethod def collect(cls, block_structure): """ Collects any information that's necessary to execute this transformer's transform method. """ # collect basic xblock fields block_structure.request_xblock_fields('category') def transform(self, usage_info, block_structure): """ Mutates block_structure based on the given usage_info. """ if not self.block_types_to_count: return for block_key in block_structure.post_order_traversal(): for block_type in self.block_types_to_count: descendants_type_count = sum([ block_structure.get_transformer_block_field(child_key, self, block_type, 0) for child_key in block_structure.get_children(block_key) ]) block_structure.set_transformer_block_field( block_key, self, block_type, ( descendants_type_count + (1 if (block_structure.get_xblock_field(block_key, 'category') == block_type) else 0) ) )
agpl-3.0
[ 624, 199, 3142, 14826, 83, 30486, 199, 624, 199, 504, 22709, 14, 1018, 14, 773, 14, 1457, 63, 6976, 14, 19754, 492, 8651, 10766, 19761, 421, 199, 533, 8651, 23209, 19761, 8, 3142, 10766, 19761, 304, 272, 408, 272, 14797, 282, 2338, 402, 27509, 5664, 402, 314, 5839, 2943, 272, 408, 272, 15945, 275, 413, 272, 8068, 63, 8760, 51, 275, 283, 1457, 63, 6851, 7, 339, 347, 636, 826, 721, 277, 12, 1853, 63, 1313, 63, 475, 63, 835, 304, 267, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 275, 1853, 63, 1313, 63, 475, 63, 835, 339, 768, 3744, 272, 347, 536, 8, 1886, 304, 267, 372, 298, 4166, 63, 1246, 26, 1457, 63, 6851, 2, 339, 768, 3744, 272, 347, 8775, 8, 1886, 12, 1853, 63, 6976, 304, 267, 408, 267, 19649, 83, 1263, 2556, 626, 1159, 5784, 370, 5341, 642, 21484, 1159, 267, 5793, 1083, 14, 267, 408, 267, 327, 8775, 5678, 12971, 1504, 267, 1853, 63, 6976, 14, 1069, 63, 11283, 63, 955, 360, 3710, 358, 339, 347, 5793, 8, 277, 12, 4503, 63, 815, 12, 1853, 63, 6976, 304, 267, 408, 267, 26550, 2335, 1853, 63, 6976, 4079, 641, 314, 1627, 4503, 63, 815, 14, 267, 408, 267, 340, 440, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 26, 288, 372, 398, 367, 1853, 63, 498, 315, 1853, 63, 6976, 14, 1932, 63, 1648, 63, 1239, 16222, 837, 288, 367, 1853, 63, 466, 315, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 26, 355, 26061, 63, 466, 63, 835, 275, 3089, 779, 490, 1853, 63, 6976, 14, 362, 63, 19754, 63, 1457, 63, 698, 8, 1739, 63, 498, 12, 291, 12, 1853, 63, 466, 12, 378, 9, 490, 367, 1982, 63, 498, 315, 1853, 63, 6976, 14, 362, 63, 3223, 8, 1457, 63, 498, 9, 355, 4794, 355, 1853, 63, 6976, 14, 409, 63, 19754, 63, 1457, 63, 698, 8, 490, 1853, 63, 498, 12, 490, 291, 12, 490, 1853, 63, 466, 12, 490, 334, 717, 26061, 63, 466, 63, 835, 435, 717, 334, 17, 340, 334, 1457, 63, 6976, 14, 362, 63, 11283, 63, 698, 8, 1457, 63, 498, 12, 283, 3710, 358, 508, 1853, 63, 466, 9, 587, 378, 9, 490, 776, 355, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 3142, 14826, 83, 30486, 199, 624, 199, 504, 22709, 14, 1018, 14, 773, 14, 1457, 63, 6976, 14, 19754, 492, 8651, 10766, 19761, 421, 199, 533, 8651, 23209, 19761, 8, 3142, 10766, 19761, 304, 272, 408, 272, 14797, 282, 2338, 402, 27509, 5664, 402, 314, 5839, 2943, 272, 408, 272, 15945, 275, 413, 272, 8068, 63, 8760, 51, 275, 283, 1457, 63, 6851, 7, 339, 347, 636, 826, 721, 277, 12, 1853, 63, 1313, 63, 475, 63, 835, 304, 267, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 275, 1853, 63, 1313, 63, 475, 63, 835, 339, 768, 3744, 272, 347, 536, 8, 1886, 304, 267, 372, 298, 4166, 63, 1246, 26, 1457, 63, 6851, 2, 339, 768, 3744, 272, 347, 8775, 8, 1886, 12, 1853, 63, 6976, 304, 267, 408, 267, 19649, 83, 1263, 2556, 626, 1159, 5784, 370, 5341, 642, 21484, 1159, 267, 5793, 1083, 14, 267, 408, 267, 327, 8775, 5678, 12971, 1504, 267, 1853, 63, 6976, 14, 1069, 63, 11283, 63, 955, 360, 3710, 358, 339, 347, 5793, 8, 277, 12, 4503, 63, 815, 12, 1853, 63, 6976, 304, 267, 408, 267, 26550, 2335, 1853, 63, 6976, 4079, 641, 314, 1627, 4503, 63, 815, 14, 267, 408, 267, 340, 440, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 26, 288, 372, 398, 367, 1853, 63, 498, 315, 1853, 63, 6976, 14, 1932, 63, 1648, 63, 1239, 16222, 837, 288, 367, 1853, 63, 466, 315, 291, 14, 1457, 63, 1313, 63, 475, 63, 835, 26, 355, 26061, 63, 466, 63, 835, 275, 3089, 779, 490, 1853, 63, 6976, 14, 362, 63, 19754, 63, 1457, 63, 698, 8, 1739, 63, 498, 12, 291, 12, 1853, 63, 466, 12, 378, 9, 490, 367, 1982, 63, 498, 315, 1853, 63, 6976, 14, 362, 63, 3223, 8, 1457, 63, 498, 9, 355, 4794, 355, 1853, 63, 6976, 14, 409, 63, 19754, 63, 1457, 63, 698, 8, 490, 1853, 63, 498, 12, 490, 291, 12, 490, 1853, 63, 466, 12, 490, 334, 717, 26061, 63, 466, 63, 835, 435, 717, 334, 17, 340, 334, 1457, 63, 6976, 14, 362, 63, 11283, 63, 698, 8, 1457, 63, 498, 12, 283, 3710, 358, 508, 1853, 63, 466, 9, 587, 378, 9, 490, 776, 355, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
luotao1/Paddle
python/paddle/fluid/tests/unittests/dygraph_to_static/test_slice.py
2
4916
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function import unittest import numpy as np import paddle SEED = 2020 np.random.seed(SEED) prog_trans = paddle.jit.ProgramTranslator() @paddle.jit.to_static def test_slice_without_control_flow(x): # Python slice will not be transformed. x = paddle.to_tensor(x) a = [x] a[0] = paddle.full(shape=[2], fill_value=2, dtype="float32") return a[0] @paddle.jit.to_static def test_slice_in_if(x): x = paddle.to_tensor(x) a = [] if x.numpy()[0] > 0: a.append(x) else: a.append(paddle.full(shape=[1, 2], fill_value=9, dtype="int32")) if x.numpy()[0] > 0: a[0] = x a[0] = x + 1 out = a[0] return out @paddle.jit.to_static def test_slice_in_while_loop(x, iter_num=3): x = paddle.to_tensor(x) iter_num_var = paddle.full(shape=[1], fill_value=iter_num, dtype="int32") a = [] i = 0 while i < iter_num_var: a.append(x) i += 1 i = 0 while i < iter_num_var.numpy()[0]: a[i] = paddle.full(shape=[2], fill_value=2, dtype="float32") i += 1 out = a[0:iter_num] return out[0] @paddle.jit.to_static def test_slice_in_for_loop(x, iter_num=3): x = paddle.to_tensor(x) a = [] # Use `paddle.full` so that static analysis can analyze the type of iter_num is Tensor iter_num = paddle.full( shape=[1], fill_value=iter_num, dtype="int32" ) # TODO(liym27): Delete it if the type of parameter iter_num can be resolved for i in range(iter_num): a.append(x) for i in range(iter_num): a[i] = x out = a[2] return out @paddle.jit.to_static def test_set_value(x): x = paddle.to_tensor(x) x[0] = paddle.full(shape=[1], fill_value=2, dtype="float32") x[1:2, 0:1] = 10 return x class LayerWithSetValue(paddle.nn.Layer): def __init__(self, input_dim, hidden): super(LayerWithSetValue, self).__init__() self.linear = paddle.nn.Linear(input_dim, hidden) @paddle.jit.to_static def forward(self, x): x = self.linear(x) x[0] = 1 return x class TestSliceWithoutControlFlow(unittest.TestCase): def setUp(self): self.init_input() self.place = paddle.CUDAPlace(0) if paddle.is_compiled_with_cuda( ) else paddle.CPUPlace() self.init_dygraph_func() paddle.disable_static() def init_input(self): self.input = np.random.random((3)).astype('int32') def init_dygraph_func(self): self.dygraph_func = test_slice_without_control_flow def run_dygraph_mode(self): return self._run(to_static=False) def _run(self, to_static): prog_trans.enable(to_static) res = self.dygraph_func(self.input) return res.numpy() def run_static_mode(self): return self._run(to_static=True) def test_transformed_static_result(self): static_res = self.run_static_mode() dygraph_res = self.run_dygraph_mode() self.assertTrue( np.allclose(dygraph_res, static_res), msg='dygraph_res is {}\nstatic_res is {}'.format(dygraph_res, static_res)) class TestSliceInIf(TestSliceWithoutControlFlow): def init_dygraph_func(self): self.dygraph_func = test_slice_in_if class TestSliceInWhileLoop(TestSliceWithoutControlFlow): def init_dygraph_func(self): self.dygraph_func = test_slice_in_while_loop class TestSliceInForLoop(TestSliceWithoutControlFlow): def init_dygraph_func(self): self.dygraph_func = test_slice_in_for_loop class TestSetValue(TestSliceWithoutControlFlow): def init_input(self): self.input = np.full([3, 4, 5], 5).astype('float32') def init_dygraph_func(self): self.dygraph_func = test_set_value class TestSetValueWithLayerAndSave(unittest.TestCase): def test_set_value_with_save(self): prog_trans.enable(True) model = LayerWithSetValue(input_dim=10, hidden=1) x = paddle.full(shape=[5, 10], fill_value=5.0, dtype="float32") paddle.jit.save( layer=model, path="./layer_use_set_value", input_spec=[x], output_spec=None) if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 1898, 334, 67, 9, 25455, 510, 20101, 48, 20101, 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, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2882, 199, 646, 2680, 465, 980, 199, 199, 646, 28525, 199, 199, 25508, 275, 25455, 199, 1590, 14, 2355, 14, 5176, 8, 25508, 9, 199, 6595, 63, 1515, 275, 28525, 14, 17676, 14, 9184, 26059, 342, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 7395, 63, 2785, 63, 1659, 8, 88, 304, 272, 327, 2018, 6014, 911, 440, 506, 14834, 14, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 359, 88, 61, 272, 282, 59, 16, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 18, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 272, 372, 282, 59, 16, 61, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 692, 8, 88, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 942, 272, 340, 671, 14, 4714, 3430, 16, 61, 690, 378, 26, 267, 282, 14, 740, 8, 88, 9, 272, 587, 26, 267, 282, 14, 740, 8, 80, 20101, 14, 2861, 8, 1392, 1524, 17, 12, 499, 467, 5554, 63, 585, 29, 25, 12, 2152, 628, 442, 708, 2237, 339, 340, 671, 14, 4714, 3430, 16, 61, 690, 378, 26, 267, 282, 59, 16, 61, 275, 671, 339, 282, 59, 16, 61, 275, 671, 435, 413, 272, 734, 275, 282, 59, 16, 61, 272, 372, 734, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 6710, 63, 3813, 8, 88, 12, 2740, 63, 1507, 29, 19, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 2740, 63, 1507, 63, 1391, 275, 28525, 14, 2861, 8, 1392, 1524, 17, 467, 5554, 63, 585, 29, 1661, 63, 1507, 12, 2152, 628, 442, 708, 531, 272, 282, 275, 942, 272, 284, 275, 378, 339, 1830, 284, 665, 2740, 63, 1507, 63, 1391, 26, 267, 282, 14, 740, 8, 88, 9, 267, 284, 847, 413, 339, 284, 275, 378, 272, 1830, 284, 665, 2740, 63, 1507, 63, 1391, 14, 4714, 3430, 16, 2189, 267, 282, 59, 73, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 18, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 267, 284, 847, 413, 272, 734, 275, 282, 59, 16, 26, 1661, 63, 1507, 61, 272, 372, 734, 59, 16, 61, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 509, 63, 3813, 8, 88, 12, 2740, 63, 1507, 29, 19, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 942, 272, 327, 3645, 658, 80, 20101, 14, 2861, 64, 880, 626, 2955, 11284, 883, 19897, 314, 730, 402, 2740, 63, 1507, 365, 5878, 272, 2740, 63, 1507, 275, 28525, 14, 2861, 8, 267, 2215, 1524, 17, 467, 5554, 63, 585, 29, 1661, 63, 1507, 12, 2152, 628, 442, 708, 2, 272, 776, 221, 327, 3254, 8, 317, 12828, 1465, 304, 8496, 652, 340, 314, 730, 402, 2725, 2740, 63, 1507, 883, 506, 12152, 339, 367, 284, 315, 1425, 8, 1661, 63, 1507, 304, 267, 282, 14, 740, 8, 88, 9, 339, 367, 284, 315, 1425, 8, 1661, 63, 1507, 304, 267, 282, 59, 73, 61, 275, 671, 272, 734, 275, 282, 59, 18, 61, 272, 372, 734, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 409, 63, 585, 8, 88, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 671, 59, 16, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 17, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 272, 671, 59, 17, 26, 18, 12, 378, 26, 17, 61, 275, 1616, 272, 372, 671, 421, 199, 533, 11915, 3007, 21322, 8, 80, 20101, 14, 4411, 14, 5003, 304, 272, 347, 636, 826, 721, 277, 12, 1324, 63, 3572, 12, 8752, 304, 267, 1613, 8, 5003, 3007, 21322, 12, 291, 2843, 826, 4533, 267, 291, 14, 6676, 275, 28525, 14, 4411, 14, 10608, 8, 1210, 63, 3572, 12, 8752, 9, 339, 768, 80, 20101, 14, 17676, 14, 475, 63, 1986, 272, 347, 7568, 8, 277, 12, 671, 304, 267, 671, 275, 291, 14, 6676, 8, 88, 9, 267, 671, 59, 16, 61, 275, 413, 267, 372, 671, 421, 199, 533, 1379, 14034, 12450, 3717, 5060, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 826, 63, 1210, 342, 267, 291, 14, 2778, 275, 28525, 14, 30925, 1282, 1071, 8, 16, 9, 340, 28525, 14, 374, 63, 8427, 63, 1045, 63, 16309, 8, 267, 776, 587, 28525, 14, 2890, 2160, 1071, 342, 267, 291, 14, 826, 63, 8161, 2180, 63, 1532, 342, 267, 28525, 14, 5993, 63, 1986, 342, 339, 347, 4205, 63, 1210, 8, 277, 304, 267, 291, 14, 1210, 275, 980, 14, 2355, 14, 2355, 1332, 19, 4992, 6041, 360, 442, 708, 358, 339, 347, 4205, 63, 8161, 2180, 63, 1532, 8, 277, 304, 267, 291, 14, 8161, 2180, 63, 1532, 275, 511, 63, 5224, 63, 7395, 63, 2785, 63, 1659, 339, 347 ]
[ 1898, 334, 67, 9, 25455, 510, 20101, 48, 20101, 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, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2882, 199, 646, 2680, 465, 980, 199, 199, 646, 28525, 199, 199, 25508, 275, 25455, 199, 1590, 14, 2355, 14, 5176, 8, 25508, 9, 199, 6595, 63, 1515, 275, 28525, 14, 17676, 14, 9184, 26059, 342, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 7395, 63, 2785, 63, 1659, 8, 88, 304, 272, 327, 2018, 6014, 911, 440, 506, 14834, 14, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 359, 88, 61, 272, 282, 59, 16, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 18, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 272, 372, 282, 59, 16, 61, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 692, 8, 88, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 942, 272, 340, 671, 14, 4714, 3430, 16, 61, 690, 378, 26, 267, 282, 14, 740, 8, 88, 9, 272, 587, 26, 267, 282, 14, 740, 8, 80, 20101, 14, 2861, 8, 1392, 1524, 17, 12, 499, 467, 5554, 63, 585, 29, 25, 12, 2152, 628, 442, 708, 2237, 339, 340, 671, 14, 4714, 3430, 16, 61, 690, 378, 26, 267, 282, 59, 16, 61, 275, 671, 339, 282, 59, 16, 61, 275, 671, 435, 413, 272, 734, 275, 282, 59, 16, 61, 272, 372, 734, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 6710, 63, 3813, 8, 88, 12, 2740, 63, 1507, 29, 19, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 2740, 63, 1507, 63, 1391, 275, 28525, 14, 2861, 8, 1392, 1524, 17, 467, 5554, 63, 585, 29, 1661, 63, 1507, 12, 2152, 628, 442, 708, 531, 272, 282, 275, 942, 272, 284, 275, 378, 339, 1830, 284, 665, 2740, 63, 1507, 63, 1391, 26, 267, 282, 14, 740, 8, 88, 9, 267, 284, 847, 413, 339, 284, 275, 378, 272, 1830, 284, 665, 2740, 63, 1507, 63, 1391, 14, 4714, 3430, 16, 2189, 267, 282, 59, 73, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 18, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 267, 284, 847, 413, 272, 734, 275, 282, 59, 16, 26, 1661, 63, 1507, 61, 272, 372, 734, 59, 16, 61, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 5224, 63, 262, 63, 509, 63, 3813, 8, 88, 12, 2740, 63, 1507, 29, 19, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 282, 275, 942, 272, 327, 3645, 658, 80, 20101, 14, 2861, 64, 880, 626, 2955, 11284, 883, 19897, 314, 730, 402, 2740, 63, 1507, 365, 5878, 272, 2740, 63, 1507, 275, 28525, 14, 2861, 8, 267, 2215, 1524, 17, 467, 5554, 63, 585, 29, 1661, 63, 1507, 12, 2152, 628, 442, 708, 2, 272, 776, 221, 327, 3254, 8, 317, 12828, 1465, 304, 8496, 652, 340, 314, 730, 402, 2725, 2740, 63, 1507, 883, 506, 12152, 339, 367, 284, 315, 1425, 8, 1661, 63, 1507, 304, 267, 282, 14, 740, 8, 88, 9, 339, 367, 284, 315, 1425, 8, 1661, 63, 1507, 304, 267, 282, 59, 73, 61, 275, 671, 272, 734, 275, 282, 59, 18, 61, 272, 372, 734, 421, 199, 32, 80, 20101, 14, 17676, 14, 475, 63, 1986, 199, 318, 511, 63, 409, 63, 585, 8, 88, 304, 272, 671, 275, 28525, 14, 475, 63, 3128, 8, 88, 9, 272, 671, 59, 16, 61, 275, 28525, 14, 2861, 8, 1392, 1524, 17, 467, 5554, 63, 585, 29, 18, 12, 2152, 628, 1609, 708, 531, 272, 671, 59, 17, 26, 18, 12, 378, 26, 17, 61, 275, 1616, 272, 372, 671, 421, 199, 533, 11915, 3007, 21322, 8, 80, 20101, 14, 4411, 14, 5003, 304, 272, 347, 636, 826, 721, 277, 12, 1324, 63, 3572, 12, 8752, 304, 267, 1613, 8, 5003, 3007, 21322, 12, 291, 2843, 826, 4533, 267, 291, 14, 6676, 275, 28525, 14, 4411, 14, 10608, 8, 1210, 63, 3572, 12, 8752, 9, 339, 768, 80, 20101, 14, 17676, 14, 475, 63, 1986, 272, 347, 7568, 8, 277, 12, 671, 304, 267, 671, 275, 291, 14, 6676, 8, 88, 9, 267, 671, 59, 16, 61, 275, 413, 267, 372, 671, 421, 199, 533, 1379, 14034, 12450, 3717, 5060, 8, 2796, 14, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 826, 63, 1210, 342, 267, 291, 14, 2778, 275, 28525, 14, 30925, 1282, 1071, 8, 16, 9, 340, 28525, 14, 374, 63, 8427, 63, 1045, 63, 16309, 8, 267, 776, 587, 28525, 14, 2890, 2160, 1071, 342, 267, 291, 14, 826, 63, 8161, 2180, 63, 1532, 342, 267, 28525, 14, 5993, 63, 1986, 342, 339, 347, 4205, 63, 1210, 8, 277, 304, 267, 291, 14, 1210, 275, 980, 14, 2355, 14, 2355, 1332, 19, 4992, 6041, 360, 442, 708, 358, 339, 347, 4205, 63, 8161, 2180, 63, 1532, 8, 277, 304, 267, 291, 14, 8161, 2180, 63, 1532, 275, 511, 63, 5224, 63, 7395, 63, 2785, 63, 1659, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ergodicbreak/evennia
evennia/scripts/scripts.py
1
18627
""" This module defines Scripts, out-of-character entities that can store data both on themselves and on other objects while also having the ability to run timers. """ from twisted.internet.defer import Deferred, maybeDeferred from twisted.internet.task import LoopingCall from django.core.exceptions import ObjectDoesNotExist from django.utils.translation import ugettext as _ from evennia.typeclasses.models import TypeclassBase from evennia.scripts.models import ScriptDB from evennia.scripts.manager import ScriptManager from evennia.utils import logger from future.utils import with_metaclass __all__ = ["DefaultScript", "DoNothing", "Store"] _GA = object.__getattribute__ _SESSIONS = None class ExtendedLoopingCall(LoopingCall): """ LoopingCall that can start at a delay different than `self.interval`. """ start_delay = None callcount = 0 def start(self, interval, now=True, start_delay=None, count_start=0): """ Start running function every interval seconds. This overloads the LoopingCall default by offering the start_delay keyword and ability to repeat. Args: interval (int): Repeat interval in seconds. now (bool, optional): Whether to start immediately or after `start_delay` seconds. start_delay (int): The number of seconds before starting. If None, wait interval seconds. Only valid if `now` is `False`. It is used as a way to start with a variable start time after a pause. count_start (int): Number of repeats to start at. The count goes up every time the system repeats. This is used to implement something repeating `N` number of times etc. Raises: AssertError: if trying to start a task which is already running. ValueError: If interval is set to an invalid value < 0. Notes: As opposed to Twisted's inbuilt count mechanism, this system will count also if force_repeat() was called rather than just the number of `interval` seconds since the start. This allows us to force-step through a limited number of steps if we want. """ assert not self.running, ("Tried to start an already running " "ExtendedLoopingCall.") if interval < 0: raise ValueError("interval must be >= 0") self.running = True deferred = self._deferred = Deferred() self.starttime = self.clock.seconds() self.interval = interval self._runAtStart = now self.callcount = max(0, count_start) self.start_delay = start_delay if start_delay is None else max(0, start_delay) if now: # run immediately self() elif start_delay is not None and start_delay >= 0: # start after some time: for this to work we need to # trick _scheduleFrom by temporarily setting a different # self.interval for it to check. real_interval, self.interval = self.interval, start_delay self._scheduleFrom(self.starttime) # re-set the actual interval (this will be picked up # next time it runs self.interval = real_interval else: self._scheduleFrom(self.starttime) return deferred def __call__(self): """ Tick one step. We update callcount (tracks number of calls) as well as null start_delay (needed in order to correctly estimate next_call_time at all times). """ self.callcount += 1 if self.start_delay: self.start_delay = None self.starttime = self.clock.seconds() super(ExtendedLoopingCall, self).__call__() def force_repeat(self): """ Force-fire the callback Raises: AssertionError: When trying to force a task that is not running. """ assert self.running, ("Tried to fire an ExtendedLoopingCall " "that was not running.") self.call.cancel() self.call = None self.starttime = self.clock.seconds() self() def next_call_time(self): """ Get the next call time. This also takes the eventual effect of start_delay into account. Returns: next (int or None): The time in seconds until the next call. This takes `start_delay` into account. Returns `None` if the task is not running. """ if self.running: total_runtime = self.clock.seconds() - self.starttime interval = self.start_delay or self.interval return interval - (total_runtime % self.interval) return None class ScriptBase(with_metaclass(TypeclassBase, ScriptDB)): """ Base class for scripts. Don't inherit from this, inherit from the class `DefaultScript` below instead. """ objects = ScriptManager() class DefaultScript(ScriptBase): """ This is the base TypeClass for all Scripts. Scripts describe events, timers and states in game, they can have a time component or describe a state that changes under certain conditions. """ def __eq__(self, other): """ Compares two Scripts. Compares dbids. Args: other (Script): A script to compare with. """ try: return other.dbid == self.dbid except Exception: return False def _start_task(self): """ Start task runner. """ self.ndb._task = ExtendedLoopingCall(self._step_task) if self.db._paused_time: # the script was paused; restarting callcount = self.db._paused_callcount or 0 self.ndb._task.start(self.db_interval, now=False, start_delay=self.db._paused_time, count_start=callcount) del self.db._paused_time del self.db._paused_repeats else: # starting script anew self.ndb._task.start(self.db_interval, now=not self.db_start_delay) def _stop_task(self): """ Stop task runner """ task = self.ndb._task if task and task.running: task.stop() def _step_errback(self, e): """ Callback for runner errors """ cname = self.__class__.__name__ estring = _("Script %(key)s(#%(dbid)s) of type '%(cname)s': at_repeat() error '%(err)s'.") % \ {"key": self.key, "dbid": self.dbid, "cname": cname, "err": e.getErrorMessage()} try: self.db_obj.msg(estring) except Exception: pass logger.log_err(estring) def _step_callback(self): """ Step task runner. No try..except needed due to defer wrap. """ if not self.is_valid(): self.stop() return # call hook self.at_repeat() # check repeats callcount = self.ndb._task.callcount maxcount = self.db_repeats if maxcount > 0 and maxcount <= callcount: self.stop() def _step_task(self): """ Step task. This groups error handling. """ try: return maybeDeferred(self._step_callback).addErrback(self._step_errback) except Exception: logger.log_trace() # Public methods def time_until_next_repeat(self): """ Get time until the script fires it `at_repeat` hook again. Returns: next (int): Time in seconds until the script runs again. If not a timed script, return `None`. Notes: This hook is not used in any way by the script's stepping system; it's only here for the user to be able to check in on their scripts and when they will next be run. """ task = self.ndb._task if task: try: return int(round(task.next_call_time())) except TypeError: pass return None def remaining_repeats(self): """ Get the number of returning repeats for limited Scripts. Returns: remaining (int or `None`): The number of repeats remaining until the Script stops. Returns `None` if it has unlimited repeats. """ task = self.ndb._task if task: return max(0, self.db_repeats - task.callcount) def start(self, force_restart=False): """ Called every time the script is started (for persistent scripts, this is usually once every server start) Args: force_restart (bool, optional): Normally an already started script will not be started again. if `force_restart=True`, the script will always restart the script, regardless of if it has started before. Returns: result (int): 0 or 1 depending on if the script successfully started or not. Used in counting. """ if self.is_active and not force_restart: # script already runs and should not be restarted. return 0 obj = self.obj if obj: # check so the scripted object is valid and initalized try: obj.cmdset except AttributeError: # this means the object is not initialized. logger.log_trace() self.is_active = False return 0 # try to restart a paused script try: if self.unpause(manual_unpause=False): return 1 except RuntimeError: # manually paused. return 0 # start the script from scratch self.is_active = True try: self.at_start() except Exception: logger.log_trace() if self.db_interval > 0: self._start_task() return 1 def stop(self, kill=False): """ Called to stop the script from running. This also deletes the script. Args: kill (bool, optional): - Stop the script without calling any relevant script hooks. Returns: result (int): 0 if the script failed to stop, 1 otherwise. Used in counting. """ if not kill: try: self.at_stop() except Exception: logger.log_trace() self._stop_task() try: self.delete() except AssertionError: logger.log_trace() return 0 except ObjectDoesNotExist: return 0 return 1 def pause(self, manual_pause=True): """ This stops a running script and stores its active state. It WILL NOT call the `at_stop()` hook. """ self.db._manual_pause = manual_pause if not self.db._paused_time: # only allow pause if not already paused task = self.ndb._task if task: self.db._paused_time = task.next_call_time() self.db._paused_callcount = task.callcount self._stop_task() self.is_active = False def unpause(self, manual_unpause=True): """ Restart a paused script. This WILL call the `at_start()` hook. Args: manual_unpause (bool, optional): This is False if unpause is called by the server reload/reset mechanism. Returns: result (bool): True if unpause was triggered, False otherwise. Raises: RuntimeError: If trying to automatically resart this script (usually after a reset/reload), but it was manually paused, and so should not the auto-unpaused. """ if not manual_unpause and self.db._manual_pause: # if this script was paused manually (by a direct call of pause), # it cannot be automatically unpaused (e.g. by a @reload) raise RuntimeError if self.db._paused_time: # only unpause if previously paused self.is_active = True try: self.at_start() except Exception: logger.log_trace() self._start_task() return True def restart(self, interval=None, repeats=None, start_delay=None): """ Restarts an already existing/running Script from the beginning, optionally using different settings. This will first call the stop hooks, and then the start hooks again. Args: interval (int, optional): Allows for changing the interval of the Script. Given in seconds. if `None`, will use the already stored interval. repeats (int, optional): The number of repeats. If unset, will use the previous setting. start_delay (bool, optional): If we should wait `interval` seconds before starting or not. If `None`, re-use the previous setting. """ try: self.at_stop() except Exception: logger.log_trace() self._stop_task() self.is_active = False if interval is not None: self.interval = interval if repeats is not None: self.repeats = repeats if start_delay is not None: self.start_delay = start_delay self.start() def reset_callcount(self, value=0): """ Reset the count of the number of calls done. Args: value (int, optional): The repeat value to reset to. Default is to set it all the way back to 0. Notes: This is only useful if repeats != 0. """ task = self.ndb._task if task: task.callcount = max(0, int(value)) def force_repeat(self): """ Fire a premature triggering of the script callback. This will reset the timer and count down repeats as if the script had fired normally. """ task = self.ndb._task if task: task.force_repeat() def at_first_save(self): """ This is called after very first time this object is saved. Generally, you don't need to overload this, but only the hooks called by this method. """ self.at_script_creation() if hasattr(self, "_createdict"): # this will only be set if the utils.create_script # function was used to create the object. We want # the create call's kwargs to override the values # set by hooks. cdict = self._createdict updates = [] if not cdict.get("key"): if not self.db_key: self.db_key = "#%i" % self.dbid updates.append("db_key") elif self.db_key != cdict["key"]: self.db_key = cdict["key"] updates.append("db_key") if cdict.get("interval") and self.interval != cdict["interval"]: self.db_interval = cdict["interval"] updates.append("db_interval") if cdict.get("start_delay") and self.start_delay != cdict["start_delay"]: self.db_start_delay = cdict["start_delay"] updates.append("db_start_delay") if cdict.get("repeats") and self.repeats != cdict["repeats"]: self.db_repeats = cdict["repeats"] updates.append("db_repeats") if cdict.get("persistent") and self.persistent != cdict["persistent"]: self.db_persistent = cdict["persistent"] updates.append("db_persistent") if updates: self.save(update_fields=updates) if not cdict.get("autostart"): # don't auto-start the script return # auto-start script (default) self.start() def at_script_creation(self): """ Only called once, by the create function. """ pass def is_valid(self): """ Is called to check if the script is valid to run at this time. Should return a boolean. The method is assumed to collect all needed information from its related self.obj. """ return not self._is_deleted def at_start(self): """ Called whenever the script is started, which for persistent scripts is at least once every server start. It will also be called when starting again after a pause (such as after a server reload) """ pass def at_repeat(self): """ Called repeatedly if this Script is set to repeat regularly. """ pass def at_stop(self): """ Called whenever when it's time for this script to stop (either because is_valid returned False or it runs out of iterations) """ pass def at_server_reload(self): """ This hook is called whenever the server is shutting down for restart/reboot. If you want to, for example, save non-persistent properties across a restart, this is the place to do it. """ pass def at_server_shutdown(self): """ This hook is called whenever the server is shutting down fully (i.e. not for a restart). """ pass # Some useful default Script types used by Evennia. class DoNothing(DefaultScript): """ A script that does nothing. Used as default fallback. """ def at_script_creation(self): """ Setup the script """ self.key = "sys_do_nothing" self.desc = "This is an empty placeholder script." class Store(DefaultScript): """ Simple storage script """ def at_script_creation(self): """ Setup the script """ self.key = "sys_storage" self.desc = "This is a generic storage container."
bsd-3-clause
[ 624, 199, 2765, 859, 7890, 14914, 83, 12, 734, 13, 1618, 13, 10856, 9045, 626, 883, 3877, 199, 576, 3865, 641, 17279, 436, 641, 1163, 2251, 1830, 2597, 9445, 314, 199, 3616, 370, 1255, 900, 2393, 14, 199, 199, 624, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 11703, 9937, 199, 504, 7390, 14, 4901, 14, 1765, 492, 18175, 316, 2176, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 2755, 22042, 14, 466, 2888, 14, 992, 492, 2434, 533, 1563, 199, 504, 2755, 22042, 14, 6429, 14, 992, 492, 14914, 2846, 199, 504, 2755, 22042, 14, 6429, 14, 2609, 492, 14914, 2988, 199, 504, 2755, 22042, 14, 1208, 492, 2512, 199, 504, 6466, 14, 1208, 492, 543, 63, 6577, 199, 199, 363, 452, 363, 275, 2097, 2698, 5229, 401, 298, 2585, 19627, 401, 298, 5502, 937, 421, 199, 63, 9741, 275, 909, 855, 18480, 363, 199, 63, 51, 1608, 2823, 275, 488, 199, 199, 533, 13706, 7382, 316, 2176, 8, 7382, 316, 2176, 304, 272, 408, 272, 18175, 316, 2176, 626, 883, 1343, 737, 282, 7339, 3365, 272, 2419, 658, 277, 14, 4284, 2313, 339, 408, 272, 1343, 63, 5814, 275, 488, 272, 1240, 835, 275, 378, 339, 347, 1343, 8, 277, 12, 6252, 12, 3063, 29, 549, 12, 1343, 63, 5814, 29, 403, 12, 2338, 63, 928, 29, 16, 304, 267, 408, 267, 7707, 3879, 805, 4036, 6252, 4696, 14, 398, 961, 1806, 3640, 314, 18175, 316, 2176, 849, 701, 2331, 15663, 314, 267, 1343, 63, 5814, 4252, 436, 21255, 370, 11982, 14, 398, 3033, 26, 288, 6252, 334, 442, 304, 21973, 292, 6252, 315, 4696, 14, 288, 3063, 334, 2245, 12, 2716, 304, 7480, 370, 1343, 9939, 503, 2410, 355, 658, 928, 63, 5814, 64, 4696, 14, 288, 1343, 63, 5814, 334, 442, 304, 710, 1329, 402, 4696, 2544, 6617, 14, 355, 982, 488, 12, 3618, 6252, 4696, 14, 5972, 1686, 340, 658, 2131, 64, 365, 658, 797, 2313, 355, 2779, 365, 1202, 465, 282, 4340, 370, 1343, 543, 282, 1750, 1343, 900, 355, 2410, 282, 16834, 14, 288, 2338, 63, 928, 334, 442, 304, 4860, 402, 28908, 370, 1343, 737, 14, 710, 221, 2338, 355, 13538, 1536, 4036, 900, 314, 2656, 28908, 14, 961, 365, 1202, 370, 355, 5669, 6020, 6375, 1958, 658, 46, 64, 1329, 402, 5431, 5423, 14, 398, 6218, 26, 288, 10716, 547, 26, 340, 9936, 370, 1343, 282, 2120, 1314, 365, 2575, 3879, 14, 288, 1722, 26, 982, 6252, 365, 663, 370, 376, 3866, 574, 665, 378, 14, 398, 8144, 26, 288, 3709, 25068, 370, 17078, 1159, 315, 11730, 2338, 14729, 12, 642, 288, 2656, 911, 2338, 2597, 340, 3542, 63, 8755, 342, 1990, 2797, 7830, 288, 2419, 2951, 314, 1329, 402, 658, 4284, 64, 4696, 3967, 314, 1343, 14, 288, 961, 6127, 2739, 370, 3542, 13, 2926, 4012, 282, 13988, 1329, 402, 288, 7124, 340, 781, 2934, 14, 398, 408, 267, 702, 440, 291, 14, 5720, 12, 1689, 6948, 379, 370, 1343, 376, 2575, 3879, 298, 3303, 298, 14107, 7382, 316, 2176, 2685, 267, 340, 6252, 665, 378, 26, 288, 746, 1722, 480, 4284, 1471, 506, 2356, 378, 531, 267, 291, 14, 5720, 275, 715, 267, 12309, 275, 291, 423, 12116, 275, 17448, 342, 267, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 291, 14, 4284, 275, 6252, 267, 291, 423, 1065, 25946, 275, 3063, 267, 291, 14, 1250, 835, 275, 1390, 8, 16, 12, 2338, 63, 928, 9, 267, 291, 14, 928, 63, 5814, 275, 1343, 63, 5814, 340, 1343, 63, 5814, 365, 488, 587, 1390, 8, 16, 12, 1343, 63, 5814, 9, 398, 340, 3063, 26, 288, 327, 1255, 9939, 288, 291, 342, 267, 916, 1343, 63, 5814, 365, 440, 488, 436, 1343, 63, 5814, 2356, 378, 26, 288, 327, 1343, 2410, 2005, 900, 26, 367, 642, 370, 1736, 781, 1929, 370, 288, 327, 20907, 485, 7211, 2532, 701, 22256, 4260, 282, 3365, 288, 327, 291, 14, 4284, 367, 652, 370, 1104, 14, 288, 3363, 63, 4284, 12, 291, 14, 4284, 275, 291, 14, 4284, 12, 1343, 63, 5814, 288, 291, 423, 7211, 2532, 8, 277, 14, 32183, 9, 288, 327, 295, 13, 409, 314, 3503, 6252, 334, 3749, 911, 506, 29438, 1536, 288, 327, 2163, 900, 652, 7858, 288, 291, 14, 4284, 275, 3363, 63, 4284, 267, 587, 26, 288, 291, 423, 7211, 2532, 8, 277, 14, 32183, 9, 267, 372, 12309, 339, 347, 636, 1250, 721, 277, 304, 267, 408, 267, 18742, 1373, 3650, 14, 2136, 1678, 1240, 835, 334, 16274, 1329, 402, 4882, 9, 465, 267, 5521, 465, 2973, 1343, 63, 5814, 334, 11368, 315, 1865, 370, 6657, 267, 14497, 2163, 63, 1250, 63, 521, 737, 1006, 5431, 680, 398, 408, 267, 291, 14, 1250, 835, 847, 413, 267, 340, 291, 14, 928, 63, 5814, 26, 288, 291, 14, 928, 63, 5814, 275, 488, 288, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 1613, 8, 14107, 7382, 316, 2176, 12, 291, 2843, 1250, 4533, 339, 347, 3542, 63, 8755, 8, 277, 304, 267, 408, 267, 18771, 13, 8935, 314, 3233, 398, 6218, 26, 288, 9070, 26, 3979, 9936, 370, 3542, 282, 2120, 626, 365, 440, 355, 3879, 14, 398, 408, 267, 702, 291, 14, 5720, 12, 1689, 6948, 379, 370, 8344, 376, 13706, 7382, 316, 2176, 298, 2892, 298, 9099, 1990, 440, 3879, 2685, 267, 291, 14, 1250, 14, 6406, 342, 267, 291, 14, 1250, 275, 488, 267, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 291, 342, 2378, 347, 2163, 63, 1250, 63, 521, 8, 277, 304, 267, 408, 267, 2372, 314, 2163, 1240, 900, 14, 961, 2597, 6181, 314, 1566, 1061, 7763, 267, 402, 1343, 63, 5814, 1901, 2933, 14, 398, 1803, 26, 288, 2163, 334, 442, 503, 488, 304, 710, 900, 315, 4696, 5133, 314, 2163, 1240, 14, 961, 355, 6181, 658, 928, 63, 5814, 64, 1901, 2933, 14, 1803, 658, 403, 64, 340, 355, 314, 2120, 365, 440, 3879, 14, 398, 408, 267, 340, 291, 14, 5720, 26, 288, 3141, 63, 7726, 275, 291, 14, 9597, 14, 4515, 342, 446, 291 ]
[ 199, 2765, 859, 7890, 14914, 83, 12, 734, 13, 1618, 13, 10856, 9045, 626, 883, 3877, 199, 576, 3865, 641, 17279, 436, 641, 1163, 2251, 1830, 2597, 9445, 314, 199, 3616, 370, 1255, 900, 2393, 14, 199, 199, 624, 199, 199, 504, 7390, 14, 4901, 14, 11610, 492, 17448, 12, 11703, 9937, 199, 504, 7390, 14, 4901, 14, 1765, 492, 18175, 316, 2176, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 465, 485, 199, 504, 2755, 22042, 14, 466, 2888, 14, 992, 492, 2434, 533, 1563, 199, 504, 2755, 22042, 14, 6429, 14, 992, 492, 14914, 2846, 199, 504, 2755, 22042, 14, 6429, 14, 2609, 492, 14914, 2988, 199, 504, 2755, 22042, 14, 1208, 492, 2512, 199, 504, 6466, 14, 1208, 492, 543, 63, 6577, 199, 199, 363, 452, 363, 275, 2097, 2698, 5229, 401, 298, 2585, 19627, 401, 298, 5502, 937, 421, 199, 63, 9741, 275, 909, 855, 18480, 363, 199, 63, 51, 1608, 2823, 275, 488, 199, 199, 533, 13706, 7382, 316, 2176, 8, 7382, 316, 2176, 304, 272, 408, 272, 18175, 316, 2176, 626, 883, 1343, 737, 282, 7339, 3365, 272, 2419, 658, 277, 14, 4284, 2313, 339, 408, 272, 1343, 63, 5814, 275, 488, 272, 1240, 835, 275, 378, 339, 347, 1343, 8, 277, 12, 6252, 12, 3063, 29, 549, 12, 1343, 63, 5814, 29, 403, 12, 2338, 63, 928, 29, 16, 304, 267, 408, 267, 7707, 3879, 805, 4036, 6252, 4696, 14, 398, 961, 1806, 3640, 314, 18175, 316, 2176, 849, 701, 2331, 15663, 314, 267, 1343, 63, 5814, 4252, 436, 21255, 370, 11982, 14, 398, 3033, 26, 288, 6252, 334, 442, 304, 21973, 292, 6252, 315, 4696, 14, 288, 3063, 334, 2245, 12, 2716, 304, 7480, 370, 1343, 9939, 503, 2410, 355, 658, 928, 63, 5814, 64, 4696, 14, 288, 1343, 63, 5814, 334, 442, 304, 710, 1329, 402, 4696, 2544, 6617, 14, 355, 982, 488, 12, 3618, 6252, 4696, 14, 5972, 1686, 340, 658, 2131, 64, 365, 658, 797, 2313, 355, 2779, 365, 1202, 465, 282, 4340, 370, 1343, 543, 282, 1750, 1343, 900, 355, 2410, 282, 16834, 14, 288, 2338, 63, 928, 334, 442, 304, 4860, 402, 28908, 370, 1343, 737, 14, 710, 221, 2338, 355, 13538, 1536, 4036, 900, 314, 2656, 28908, 14, 961, 365, 1202, 370, 355, 5669, 6020, 6375, 1958, 658, 46, 64, 1329, 402, 5431, 5423, 14, 398, 6218, 26, 288, 10716, 547, 26, 340, 9936, 370, 1343, 282, 2120, 1314, 365, 2575, 3879, 14, 288, 1722, 26, 982, 6252, 365, 663, 370, 376, 3866, 574, 665, 378, 14, 398, 8144, 26, 288, 3709, 25068, 370, 17078, 1159, 315, 11730, 2338, 14729, 12, 642, 288, 2656, 911, 2338, 2597, 340, 3542, 63, 8755, 342, 1990, 2797, 7830, 288, 2419, 2951, 314, 1329, 402, 658, 4284, 64, 4696, 3967, 314, 1343, 14, 288, 961, 6127, 2739, 370, 3542, 13, 2926, 4012, 282, 13988, 1329, 402, 288, 7124, 340, 781, 2934, 14, 398, 408, 267, 702, 440, 291, 14, 5720, 12, 1689, 6948, 379, 370, 1343, 376, 2575, 3879, 298, 3303, 298, 14107, 7382, 316, 2176, 2685, 267, 340, 6252, 665, 378, 26, 288, 746, 1722, 480, 4284, 1471, 506, 2356, 378, 531, 267, 291, 14, 5720, 275, 715, 267, 12309, 275, 291, 423, 12116, 275, 17448, 342, 267, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 291, 14, 4284, 275, 6252, 267, 291, 423, 1065, 25946, 275, 3063, 267, 291, 14, 1250, 835, 275, 1390, 8, 16, 12, 2338, 63, 928, 9, 267, 291, 14, 928, 63, 5814, 275, 1343, 63, 5814, 340, 1343, 63, 5814, 365, 488, 587, 1390, 8, 16, 12, 1343, 63, 5814, 9, 398, 340, 3063, 26, 288, 327, 1255, 9939, 288, 291, 342, 267, 916, 1343, 63, 5814, 365, 440, 488, 436, 1343, 63, 5814, 2356, 378, 26, 288, 327, 1343, 2410, 2005, 900, 26, 367, 642, 370, 1736, 781, 1929, 370, 288, 327, 20907, 485, 7211, 2532, 701, 22256, 4260, 282, 3365, 288, 327, 291, 14, 4284, 367, 652, 370, 1104, 14, 288, 3363, 63, 4284, 12, 291, 14, 4284, 275, 291, 14, 4284, 12, 1343, 63, 5814, 288, 291, 423, 7211, 2532, 8, 277, 14, 32183, 9, 288, 327, 295, 13, 409, 314, 3503, 6252, 334, 3749, 911, 506, 29438, 1536, 288, 327, 2163, 900, 652, 7858, 288, 291, 14, 4284, 275, 3363, 63, 4284, 267, 587, 26, 288, 291, 423, 7211, 2532, 8, 277, 14, 32183, 9, 267, 372, 12309, 339, 347, 636, 1250, 721, 277, 304, 267, 408, 267, 18742, 1373, 3650, 14, 2136, 1678, 1240, 835, 334, 16274, 1329, 402, 4882, 9, 465, 267, 5521, 465, 2973, 1343, 63, 5814, 334, 11368, 315, 1865, 370, 6657, 267, 14497, 2163, 63, 1250, 63, 521, 737, 1006, 5431, 680, 398, 408, 267, 291, 14, 1250, 835, 847, 413, 267, 340, 291, 14, 928, 63, 5814, 26, 288, 291, 14, 928, 63, 5814, 275, 488, 288, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 1613, 8, 14107, 7382, 316, 2176, 12, 291, 2843, 1250, 4533, 339, 347, 3542, 63, 8755, 8, 277, 304, 267, 408, 267, 18771, 13, 8935, 314, 3233, 398, 6218, 26, 288, 9070, 26, 3979, 9936, 370, 3542, 282, 2120, 626, 365, 440, 355, 3879, 14, 398, 408, 267, 702, 291, 14, 5720, 12, 1689, 6948, 379, 370, 8344, 376, 13706, 7382, 316, 2176, 298, 2892, 298, 9099, 1990, 440, 3879, 2685, 267, 291, 14, 1250, 14, 6406, 342, 267, 291, 14, 1250, 275, 488, 267, 291, 14, 32183, 275, 291, 14, 9597, 14, 4515, 342, 267, 291, 342, 2378, 347, 2163, 63, 1250, 63, 521, 8, 277, 304, 267, 408, 267, 2372, 314, 2163, 1240, 900, 14, 961, 2597, 6181, 314, 1566, 1061, 7763, 267, 402, 1343, 63, 5814, 1901, 2933, 14, 398, 1803, 26, 288, 2163, 334, 442, 503, 488, 304, 710, 900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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
npuichigo/ttsflow
third_party/tensorflow/tensorflow/contrib/distributions/python/kernel_tests/bijectors/power_transform_test.py
72
2610
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for Bijector.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.contrib.distributions.python.ops.bijectors.power_transform import PowerTransform from tensorflow.python.ops.distributions.bijector_test_util import assert_bijective_and_finite from tensorflow.python.ops.distributions.bijector_test_util import assert_scalar_congruency from tensorflow.python.platform import test class PowerTransformBijectorTest(test.TestCase): """Tests correctness of the power transformation.""" def testBijector(self): with self.test_session(): c = 0.2 bijector = PowerTransform( power=c, event_ndims=1, validate_args=True) self.assertEqual("power_transform", bijector.name) x = np.array([[[-1.], [2.], [-5. + 1e-4]]]) y = (1. + x * c)**(1. / c) self.assertAllClose(y, bijector.forward(x).eval()) self.assertAllClose(x, bijector.inverse(y).eval()) self.assertAllClose( (c - 1.) * np.sum(np.log(y), axis=-1), bijector.inverse_log_det_jacobian(y).eval()) self.assertAllClose( -bijector.inverse_log_det_jacobian(y).eval(), bijector.forward_log_det_jacobian(x).eval(), rtol=1e-4, atol=0.) def testScalarCongruency(self): with self.test_session(): bijector = PowerTransform( power=0.2, validate_args=True) assert_scalar_congruency( bijector, lower_x=-2., upper_x=1.5, rtol=0.05) def testBijectiveAndFinite(self): with self.test_session(): bijector = PowerTransform( power=0.2, event_ndims=0, validate_args=True) x = np.linspace(-4.999, 10, num=10).astype(np.float32) y = np.logspace(0.001, 10, num=10).astype(np.float32) assert_bijective_and_finite(bijector, x, y, rtol=1e-3) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 31012, 19625, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 14, 4492, 963, 1384, 14, 5652, 63, 4711, 492, 18879, 6939, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 14, 4492, 19625, 63, 396, 63, 1974, 492, 702, 63, 4492, 74, 6850, 63, 460, 63, 8005, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 14, 4492, 19625, 63, 396, 63, 1974, 492, 702, 63, 7033, 63, 388, 2587, 85, 9501, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 18879, 6939, 17975, 19625, 774, 8, 396, 14, 1746, 304, 523, 408, 2925, 29102, 402, 314, 7074, 13315, 1041, 819, 347, 511, 17975, 19625, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 286, 275, 378, 14, 18, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 67, 12, 1566, 63, 13575, 29, 17, 12, 4107, 63, 589, 29, 549, 9, 489, 291, 14, 629, 480, 5652, 63, 4711, 401, 12111, 19625, 14, 354, 9, 489, 671, 275, 980, 14, 1144, 4038, 1988, 17, 8333, 359, 18, 8333, 5243, 21, 14, 435, 413, 69, 13, 20, 25724, 489, 612, 275, 334, 17, 14, 435, 671, 627, 286, 25288, 17, 14, 1182, 286, 9, 489, 291, 14, 7260, 8, 89, 12, 12111, 19625, 14, 6688, 8, 88, 680, 2579, 1012, 489, 291, 14, 7260, 8, 88, 12, 12111, 19625, 14, 11668, 8, 89, 680, 2579, 1012, 489, 291, 14, 7260, 8, 881, 334, 67, 446, 413, 4959, 627, 980, 14, 1838, 8, 1590, 14, 793, 8, 89, 395, 3114, 4022, 17, 395, 881, 12111, 19625, 14, 11668, 63, 793, 63, 9886, 63, 27342, 8, 89, 680, 2579, 1012, 489, 291, 14, 7260, 8, 881, 446, 4492, 19625, 14, 11668, 63, 793, 63, 9886, 63, 27342, 8, 89, 680, 2579, 1062, 881, 12111, 19625, 14, 6688, 63, 793, 63, 9886, 63, 27342, 8, 88, 680, 2579, 1062, 881, 10561, 29, 17, 69, 13, 20, 12, 881, 9543, 29, 16, 4959, 819, 347, 511, 13090, 714, 2587, 85, 9501, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 16, 14, 18, 12, 4107, 63, 589, 29, 549, 9, 489, 702, 63, 7033, 63, 388, 2587, 85, 9501, 8, 881, 12111, 19625, 12, 5117, 63, 88, 4022, 18, 2020, 7008, 63, 88, 29, 17, 14, 21, 12, 10561, 29, 16, 14, 1717, 9, 819, 347, 511, 34, 7879, 6850, 3325, 8694, 1175, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 16, 14, 18, 12, 1566, 63, 13575, 29, 16, 12, 4107, 63, 589, 29, 549, 9, 489, 671, 275, 980, 14, 11649, 2801, 20, 14, 5637, 12, 1616, 12, 1967, 29, 709, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 612, 275, 980, 14, 7270, 1142, 8, 16, 14, 4587, 12, 1616, 12, 1967, 29, 709, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 702, 63, 4492, 74, 6850, 63, 460, 63, 8005, 8, 4492, 19625, 12, 671, 12, 612, 12, 10561, 29, 17, 69, 13, 19, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 511, 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 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 31012, 19625, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 2828, 14, 5613, 14, 1548, 14, 1483, 14, 4492, 963, 1384, 14, 5652, 63, 4711, 492, 18879, 6939, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 14, 4492, 19625, 63, 396, 63, 1974, 492, 702, 63, 4492, 74, 6850, 63, 460, 63, 8005, 199, 504, 3228, 14, 1548, 14, 1483, 14, 5613, 14, 4492, 19625, 63, 396, 63, 1974, 492, 702, 63, 7033, 63, 388, 2587, 85, 9501, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 18879, 6939, 17975, 19625, 774, 8, 396, 14, 1746, 304, 523, 408, 2925, 29102, 402, 314, 7074, 13315, 1041, 819, 347, 511, 17975, 19625, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 286, 275, 378, 14, 18, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 67, 12, 1566, 63, 13575, 29, 17, 12, 4107, 63, 589, 29, 549, 9, 489, 291, 14, 629, 480, 5652, 63, 4711, 401, 12111, 19625, 14, 354, 9, 489, 671, 275, 980, 14, 1144, 4038, 1988, 17, 8333, 359, 18, 8333, 5243, 21, 14, 435, 413, 69, 13, 20, 25724, 489, 612, 275, 334, 17, 14, 435, 671, 627, 286, 25288, 17, 14, 1182, 286, 9, 489, 291, 14, 7260, 8, 89, 12, 12111, 19625, 14, 6688, 8, 88, 680, 2579, 1012, 489, 291, 14, 7260, 8, 88, 12, 12111, 19625, 14, 11668, 8, 89, 680, 2579, 1012, 489, 291, 14, 7260, 8, 881, 334, 67, 446, 413, 4959, 627, 980, 14, 1838, 8, 1590, 14, 793, 8, 89, 395, 3114, 4022, 17, 395, 881, 12111, 19625, 14, 11668, 63, 793, 63, 9886, 63, 27342, 8, 89, 680, 2579, 1012, 489, 291, 14, 7260, 8, 881, 446, 4492, 19625, 14, 11668, 63, 793, 63, 9886, 63, 27342, 8, 89, 680, 2579, 1062, 881, 12111, 19625, 14, 6688, 63, 793, 63, 9886, 63, 27342, 8, 88, 680, 2579, 1062, 881, 10561, 29, 17, 69, 13, 20, 12, 881, 9543, 29, 16, 4959, 819, 347, 511, 13090, 714, 2587, 85, 9501, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 16, 14, 18, 12, 4107, 63, 589, 29, 549, 9, 489, 702, 63, 7033, 63, 388, 2587, 85, 9501, 8, 881, 12111, 19625, 12, 5117, 63, 88, 4022, 18, 2020, 7008, 63, 88, 29, 17, 14, 21, 12, 10561, 29, 16, 14, 1717, 9, 819, 347, 511, 34, 7879, 6850, 3325, 8694, 1175, 8, 277, 304, 272, 543, 291, 14, 396, 63, 1730, 837, 489, 12111, 19625, 275, 18879, 6939, 8, 881, 7074, 29, 16, 14, 18, 12, 1566, 63, 13575, 29, 16, 12, 4107, 63, 589, 29, 549, 9, 489, 671, 275, 980, 14, 11649, 2801, 20, 14, 5637, 12, 1616, 12, 1967, 29, 709, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 612, 275, 980, 14, 7270, 1142, 8, 16, 14, 4587, 12, 1616, 12, 1967, 29, 709, 680, 6041, 8, 1590, 14, 1609, 708, 9, 489, 702, 63, 4492, 74, 6850, 63, 460, 63, 8005, 8, 4492, 19625, 12, 671, 12, 612, 12, 10561, 29, 17, 69, 13, 19, 9, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 523, 511, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
acquia/Diamond
src/collectors/ip/test/testip.py
30
4179
#!/usr/bin/env python # coding=utf-8 ############################################################################### from test import CollectorTestCase from test import get_collector_config from test import unittest from mock import Mock from mock import patch try: from cStringIO import StringIO except ImportError: from StringIO import StringIO from ip import IPCollector ############################################################################### class TestIPCollector(CollectorTestCase): def setUp(self, allowed_names=None): if not allowed_names: allowed_names = [] config = get_collector_config('IPCollector', { 'allowed_names': allowed_names, 'interval': 1, }) self.collector = IPCollector(config, None) def test_import(self): self.assertTrue(IPCollector) @patch('os.access', Mock(return_value=True)) @patch('__builtin__.open') @patch('diamond.collector.Collector.publish') def test_should_open_proc_net_snmp(self, publish_mock, open_mock): IPCollector.PROC = ['/proc/net/snmp'] open_mock.return_value = StringIO('') self.collector.collect() open_mock.assert_called_once_with('/proc/net/snmp') @patch('os.access', Mock(return_value=True)) @patch('__builtin__.open') @patch('diamond.collector.Collector.publish') def test_should_work_with_synthetic_data(self, publish_mock, open_mock): IPCollector.PROC = ['/proc/net/snmp'] self.setUp(['A', 'C']) open_mock.return_value = StringIO(''' Ip: A B C Ip: 0 0 0 '''.strip()) self.collector.collect() open_mock.return_value = StringIO(''' Ip: A B C Ip: 0 1 2 '''.strip()) publish_mock.call_args_list = [] self.collector.collect() self.assertEqual(len(publish_mock.call_args_list), 2) metrics = { 'A': 0, 'C': 2, } self.assertPublishedMany(publish_mock, metrics) @patch('diamond.collector.Collector.publish') def test_should_work_with_real_data(self, publish_mock): self.setUp(['InDiscards', 'InReceives', 'OutDiscards', 'OutRequests']) IPCollector.PROC = [self.getFixturePath('proc_net_snmp_1')] self.collector.collect() self.assertPublishedMany(publish_mock, {}) IPCollector.PROC = [self.getFixturePath('proc_net_snmp_2')] self.collector.collect() metrics = { 'InDiscards': 0, 'InReceives': 2, 'OutDiscards': 0, 'OutRequests': 1, } self.assertPublishedMany(publish_mock, metrics) @patch('diamond.collector.Collector.publish') def test_should_work_with_all_data(self, publish_mock): metrics = { 'Forwarding': 2, 'DefaultTTL': 64, 'InReceives': 2, 'InHdrErrors': 0, 'InAddrErrors': 0, 'ForwDatagrams': 0, 'InUnknownProtos': 0, 'InDiscards': 0, 'InDelivers': 2, 'OutRequests': 1, 'OutDiscards': 0, 'OutNoRoutes': 0, 'ReasmTimeout': 0, 'ReasmReqds': 0, 'ReasmOKs': 0, 'ReasmFails': 0, 'FragOKs': 0, 'FragFails': 0, 'FragCreates': 0, } self.setUp(allowed_names=metrics.keys()) IPCollector.PROC = [ self.getFixturePath('proc_net_snmp_1'), ] self.collector.collect() self.assertPublishedMany(publish_mock, {}) IPCollector.PROC = [ self.getFixturePath('proc_net_snmp_2'), ] self.collector.collect() self.setDocExample(collector=self.collector.__class__.__name__, metrics=metrics, defaultpath=self.collector.config['path']) self.assertPublishedMany(publish_mock, metrics) ############################################################################### if __name__ == '__main__': unittest.main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 29, 1624, 13, 24, 199, 11490, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 504, 3384, 492, 3531, 12852, 199, 199, 11490, 421, 199, 533, 1379, 1772, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 12, 4370, 63, 1247, 29, 403, 304, 267, 340, 440, 4370, 63, 1247, 26, 288, 4370, 63, 1247, 275, 942, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 1772, 12852, 297, 469, 288, 283, 6541, 63, 1247, 356, 4370, 63, 1247, 12, 288, 283, 4284, 356, 413, 12, 267, 3828, 267, 291, 14, 10946, 275, 3531, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 1772, 12852, 9, 339, 768, 2068, 360, 736, 14, 2732, 297, 4420, 8, 1107, 63, 585, 29, 549, 430, 272, 768, 2068, 10714, 5351, 4343, 1490, 358, 272, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 1490, 63, 4687, 63, 846, 63, 15523, 8, 277, 12, 2780, 63, 1805, 12, 1551, 63, 1805, 304, 267, 3531, 12852, 14, 6072, 275, 18744, 4687, 15, 846, 15, 15523, 418, 267, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 8355, 267, 291, 14, 10946, 14, 7112, 342, 267, 1551, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 2336, 4687, 15, 846, 15, 15523, 358, 339, 768, 2068, 360, 736, 14, 2732, 297, 4420, 8, 1107, 63, 585, 29, 549, 430, 272, 768, 2068, 10714, 5351, 4343, 1490, 358, 272, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 9466, 21231, 63, 576, 8, 277, 12, 2780, 63, 1805, 12, 1551, 63, 1805, 304, 267, 3531, 12852, 14, 6072, 275, 18744, 4687, 15, 846, 15, 15523, 418, 267, 291, 14, 5996, 2941, 33, 297, 283, 35, 1105, 267, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 10505, 199, 6583, 26, 437, 699, 445, 199, 6583, 26, 378, 378, 378, 199, 891, 1370, 1913, 1012, 398, 291, 14, 10946, 14, 7112, 342, 398, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 10505, 199, 6583, 26, 437, 699, 445, 199, 6583, 26, 378, 413, 499, 199, 891, 1370, 1913, 1012, 398, 2780, 63, 1805, 14, 1250, 63, 589, 63, 513, 275, 942, 398, 291, 14, 10946, 14, 7112, 342, 398, 291, 14, 629, 8, 552, 8, 4763, 63, 1805, 14, 1250, 63, 589, 63, 513, 395, 499, 9, 398, 7186, 275, 469, 288, 283, 33, 356, 378, 12, 288, 283, 35, 356, 499, 12, 267, 789, 398, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 3093, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 5996, 2941, 607, 2825, 13761, 297, 283, 607, 497, 2375, 397, 297, 283, 2204, 2825, 13761, 297, 283, 2204, 16272, 1105, 398, 3531, 12852, 14, 6072, 275, 359, 277, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 17, 5440, 267, 291, 14, 10946, 14, 7112, 342, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 5009, 398, 3531, 12852, 14, 6072, 275, 359, 277, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 18, 5440, 267, 291, 14, 10946, 14, 7112, 342, 398, 7186, 275, 469, 288, 283, 607, 2825, 13761, 356, 378, 12, 288, 283, 607, 497, 2375, 397, 356, 499, 12, 288, 283, 2204, 2825, 13761, 356, 378, 12, 288, 283, 2204, 16272, 356, 413, 12, 267, 789, 398, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 452, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 7186, 275, 469, 288, 283, 26427, 356, 755, 499, 12, 288, 283, 2698, 25567, 356, 755, 5049, 12, 288, 283, 607, 497, 2375, 397, 356, 755, 499, 12, 288, 283, 607, 40, 5012, 9298, 356, 420, 378, 12, 288, 283, 607, 11404, 9298, 356, 258, 378, 12, 288, 283, 1858, 87, 1451, 9292, 356, 259, 378, 12, 288, 283, 607, 5912, 21349, 356, 221, 378, 12, 288, 283, 607, 2825, 13761, 356, 755, 378, 12, 288, 283, 607, 19898, 14895, 356, 755, 499, 12, 288, 283, 2204, 16272, 356, 420, 413, 12, 288, 283, 2204, 2825, 13761, 356, 420, 378, 12, 288, 283, 2204, 1944, 5407, 744, 356, 420, 378, 12, 288, 283, 497, 11374, 6372, 356, 258, 378, 12, 288, 283, 497, 11374, 11981, 795, 356, 755, 378, 12, 288, 283, 497, 11374, 3593, 83, 356, 260, 378, 12, 288, 283, 497, 11374, 4874, 83, 356, 755, 378, 12, 288, 283, 24552, 3593, 83, 356, 3515, 378, 12, 288, 283, 24552, 4874, 83, 356, 263, 378, 12, 288, 283, 24552, 10607, 356, 420, 378, 12, 267, 789, 398, 291, 14, 5996, 8, 6541, 63, 1247, 29, 6759, 14, 1612, 1012, 398, 3531, 12852, 14, 6072, 275, 359, 288, 291, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 17, 659, 267, 1622, 267, 291, 14, 10946, 14, 7112, 342, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 5009, 398, 3531, 12852, 14, 6072, 275, 359, 288, 291, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 18, 659, 267, 1622, 267, 291, 14, 10946, 14, 7112, 342, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 12, 2574, 849, 515, 29, 277, 14, 10946, 14, 888, 459, 515, 1105, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 199, 199, 11490, 199 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 2803, 29, 1624, 13, 24, 199, 11490, 199, 199, 504, 511, 492, 3626, 3283, 1746, 199, 504, 511, 492, 664, 63, 10946, 63, 888, 199, 504, 511, 492, 2882, 199, 504, 1683, 492, 4420, 199, 504, 1683, 492, 3371, 199, 199, 893, 26, 272, 687, 15073, 492, 5228, 199, 2590, 3545, 26, 272, 687, 5228, 492, 5228, 199, 199, 504, 3384, 492, 3531, 12852, 199, 199, 11490, 421, 199, 533, 1379, 1772, 12852, 8, 12852, 1746, 304, 339, 347, 3613, 8, 277, 12, 4370, 63, 1247, 29, 403, 304, 267, 340, 440, 4370, 63, 1247, 26, 288, 4370, 63, 1247, 275, 942, 267, 1101, 275, 664, 63, 10946, 63, 888, 360, 1772, 12852, 297, 469, 288, 283, 6541, 63, 1247, 356, 4370, 63, 1247, 12, 288, 283, 4284, 356, 413, 12, 267, 3828, 267, 291, 14, 10946, 275, 3531, 12852, 8, 888, 12, 488, 9, 339, 347, 511, 63, 646, 8, 277, 304, 267, 291, 14, 1815, 8, 1772, 12852, 9, 339, 768, 2068, 360, 736, 14, 2732, 297, 4420, 8, 1107, 63, 585, 29, 549, 430, 272, 768, 2068, 10714, 5351, 4343, 1490, 358, 272, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 1490, 63, 4687, 63, 846, 63, 15523, 8, 277, 12, 2780, 63, 1805, 12, 1551, 63, 1805, 304, 267, 3531, 12852, 14, 6072, 275, 18744, 4687, 15, 846, 15, 15523, 418, 267, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 8355, 267, 291, 14, 10946, 14, 7112, 342, 267, 1551, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 2336, 4687, 15, 846, 15, 15523, 358, 339, 768, 2068, 360, 736, 14, 2732, 297, 4420, 8, 1107, 63, 585, 29, 549, 430, 272, 768, 2068, 10714, 5351, 4343, 1490, 358, 272, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 9466, 21231, 63, 576, 8, 277, 12, 2780, 63, 1805, 12, 1551, 63, 1805, 304, 267, 3531, 12852, 14, 6072, 275, 18744, 4687, 15, 846, 15, 15523, 418, 267, 291, 14, 5996, 2941, 33, 297, 283, 35, 1105, 267, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 10505, 199, 6583, 26, 437, 699, 445, 199, 6583, 26, 378, 378, 378, 199, 891, 1370, 1913, 1012, 398, 291, 14, 10946, 14, 7112, 342, 398, 1551, 63, 1805, 14, 1107, 63, 585, 275, 5228, 10505, 199, 6583, 26, 437, 699, 445, 199, 6583, 26, 378, 413, 499, 199, 891, 1370, 1913, 1012, 398, 2780, 63, 1805, 14, 1250, 63, 589, 63, 513, 275, 942, 398, 291, 14, 10946, 14, 7112, 342, 398, 291, 14, 629, 8, 552, 8, 4763, 63, 1805, 14, 1250, 63, 589, 63, 513, 395, 499, 9, 398, 7186, 275, 469, 288, 283, 33, 356, 378, 12, 288, 283, 35, 356, 499, 12, 267, 789, 398, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 3093, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 291, 14, 5996, 2941, 607, 2825, 13761, 297, 283, 607, 497, 2375, 397, 297, 283, 2204, 2825, 13761, 297, 283, 2204, 16272, 1105, 398, 3531, 12852, 14, 6072, 275, 359, 277, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 17, 5440, 267, 291, 14, 10946, 14, 7112, 342, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 5009, 398, 3531, 12852, 14, 6072, 275, 359, 277, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 18, 5440, 267, 291, 14, 10946, 14, 7112, 342, 398, 7186, 275, 469, 288, 283, 607, 2825, 13761, 356, 378, 12, 288, 283, 607, 497, 2375, 397, 356, 499, 12, 288, 283, 2204, 2825, 13761, 356, 378, 12, 288, 283, 2204, 16272, 356, 413, 12, 267, 789, 398, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 339, 768, 2068, 360, 328, 24940, 14, 10946, 14, 12852, 14, 4763, 358, 272, 347, 511, 63, 5626, 63, 800, 63, 1045, 63, 452, 63, 576, 8, 277, 12, 2780, 63, 1805, 304, 267, 7186, 275, 469, 288, 283, 26427, 356, 755, 499, 12, 288, 283, 2698, 25567, 356, 755, 5049, 12, 288, 283, 607, 497, 2375, 397, 356, 755, 499, 12, 288, 283, 607, 40, 5012, 9298, 356, 420, 378, 12, 288, 283, 607, 11404, 9298, 356, 258, 378, 12, 288, 283, 1858, 87, 1451, 9292, 356, 259, 378, 12, 288, 283, 607, 5912, 21349, 356, 221, 378, 12, 288, 283, 607, 2825, 13761, 356, 755, 378, 12, 288, 283, 607, 19898, 14895, 356, 755, 499, 12, 288, 283, 2204, 16272, 356, 420, 413, 12, 288, 283, 2204, 2825, 13761, 356, 420, 378, 12, 288, 283, 2204, 1944, 5407, 744, 356, 420, 378, 12, 288, 283, 497, 11374, 6372, 356, 258, 378, 12, 288, 283, 497, 11374, 11981, 795, 356, 755, 378, 12, 288, 283, 497, 11374, 3593, 83, 356, 260, 378, 12, 288, 283, 497, 11374, 4874, 83, 356, 755, 378, 12, 288, 283, 24552, 3593, 83, 356, 3515, 378, 12, 288, 283, 24552, 4874, 83, 356, 263, 378, 12, 288, 283, 24552, 10607, 356, 420, 378, 12, 267, 789, 398, 291, 14, 5996, 8, 6541, 63, 1247, 29, 6759, 14, 1612, 1012, 398, 3531, 12852, 14, 6072, 275, 359, 288, 291, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 17, 659, 267, 1622, 267, 291, 14, 10946, 14, 7112, 342, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 5009, 398, 3531, 12852, 14, 6072, 275, 359, 288, 291, 14, 362, 12812, 2042, 360, 4687, 63, 846, 63, 15523, 63, 18, 659, 267, 1622, 267, 291, 14, 10946, 14, 7112, 342, 398, 291, 14, 409, 3768, 9846, 8, 10946, 29, 277, 14, 10946, 855, 533, 4914, 354, 3108, 2574, 7186, 29, 6759, 12, 2574, 849, 515, 29, 277, 14, 10946, 14, 888, 459, 515, 1105, 267, 291, 14, 479, 27862, 4089, 8, 4763, 63, 1805, 12, 7186, 9, 199, 199, 11490, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
PKRoma/python-for-android
pythonforandroid/recipes/libzmq/__init__.py
4
1426
from pythonforandroid.recipe import Recipe from pythonforandroid.logger import shprint from pythonforandroid.util import current_directory from os.path import join import sh class LibZMQRecipe(Recipe): version = '4.3.2' url = 'https://github.com/zeromq/libzmq/releases/download/v{version}/zeromq-{version}.zip' depends = [] built_libraries = {'libzmq.so': 'src/.libs'} need_stl_shared = True def build_arch(self, arch): env = self.get_recipe_env(arch) # # libsodium_recipe = Recipe.get_recipe('libsodium', self.ctx) # libsodium_dir = libsodium_recipe.get_build_dir(arch.arch) # env['sodium_CFLAGS'] = '-I{}'.format(join( # libsodium_dir, 'src')) # env['sodium_LDLAGS'] = '-L{}'.format(join( # libsodium_dir, 'src', 'libsodium', '.libs')) curdir = self.get_build_dir(arch.arch) prefix = join(curdir, "install") with current_directory(curdir): bash = sh.Command('sh') shprint( bash, './configure', '--host={}'.format(arch.command_prefix), '--without-documentation', '--prefix={}'.format(prefix), '--with-libsodium=no', '--disable-libunwind', _env=env) shprint(sh.make, _env=env) shprint(sh.make, 'install', _env=env) recipe = LibZMQRecipe()
mit
[ 504, 2366, 509, 6238, 14, 13191, 492, 799, 8233, 199, 504, 2366, 509, 6238, 14, 2921, 492, 1033, 1361, 199, 504, 2366, 509, 6238, 14, 1974, 492, 1453, 63, 3619, 199, 504, 747, 14, 515, 492, 4263, 199, 646, 1033, 421, 199, 533, 8003, 58, 14449, 25879, 8, 25879, 304, 272, 1015, 275, 283, 20, 14, 19, 14, 18, 7, 272, 1166, 275, 283, 2859, 921, 5031, 14, 957, 15, 2282, 676, 81, 15, 773, 21290, 15, 11840, 15, 4249, 15, 86, 91, 1023, 5995, 2282, 676, 81, 24185, 1023, 5565, 3065, 7, 272, 8350, 275, 942, 272, 6137, 63, 10159, 275, 791, 773, 21290, 14, 1152, 356, 283, 2164, 8083, 8450, 936, 272, 1929, 63, 270, 76, 63, 5555, 275, 715, 339, 347, 1900, 63, 1047, 8, 277, 12, 3819, 304, 267, 2589, 275, 291, 14, 362, 63, 13191, 63, 1813, 8, 1047, 9, 267, 327, 267, 327, 1973, 1152, 12980, 63, 13191, 275, 799, 8233, 14, 362, 63, 13191, 360, 773, 1152, 12980, 297, 291, 14, 3799, 9, 267, 327, 1973, 1152, 12980, 63, 694, 275, 1973, 1152, 12980, 63, 13191, 14, 362, 63, 1506, 63, 694, 8, 1047, 14, 1047, 9, 267, 327, 2589, 459, 1152, 12980, 63, 14804, 418, 275, 2475, 41, 11123, 908, 8, 904, 8, 267, 327, 258, 1973, 1152, 12980, 63, 694, 12, 283, 2164, 1333, 267, 327, 2589, 459, 1152, 12980, 63, 6533, 44, 1254, 51, 418, 275, 2475, 44, 11123, 908, 8, 904, 8, 267, 327, 258, 1973, 1152, 12980, 63, 694, 12, 283, 2164, 297, 283, 773, 1152, 12980, 297, 1987, 8450, 1333, 398, 1094, 694, 275, 291, 14, 362, 63, 1506, 63, 694, 8, 1047, 14, 1047, 9, 267, 2403, 275, 4263, 8, 15594, 12, 298, 3174, 531, 398, 543, 1453, 63, 3619, 8, 15594, 304, 288, 20387, 275, 1033, 14, 3110, 360, 609, 358, 288, 1033, 1361, 8, 355, 20387, 12, 21526, 6472, 297, 355, 2850, 1102, 27244, 908, 8, 1047, 14, 1531, 63, 1861, 395, 355, 2850, 7395, 13, 9970, 297, 355, 2850, 1861, 27244, 908, 8, 1861, 395, 355, 2850, 1045, 13, 773, 1152, 12980, 29, 889, 297, 355, 2850, 5993, 13, 773, 324, 11530, 297, 355, 485, 1813, 29, 1813, 9, 288, 1033, 1361, 8, 609, 14, 1875, 12, 485, 1813, 29, 1813, 9, 288, 1033, 1361, 8, 609, 14, 1875, 12, 283, 3174, 297, 485, 1813, 29, 1813, 9, 421, 199, 13191, 275, 8003, 58, 14449, 25879, 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 ]
[ 2366, 509, 6238, 14, 13191, 492, 799, 8233, 199, 504, 2366, 509, 6238, 14, 2921, 492, 1033, 1361, 199, 504, 2366, 509, 6238, 14, 1974, 492, 1453, 63, 3619, 199, 504, 747, 14, 515, 492, 4263, 199, 646, 1033, 421, 199, 533, 8003, 58, 14449, 25879, 8, 25879, 304, 272, 1015, 275, 283, 20, 14, 19, 14, 18, 7, 272, 1166, 275, 283, 2859, 921, 5031, 14, 957, 15, 2282, 676, 81, 15, 773, 21290, 15, 11840, 15, 4249, 15, 86, 91, 1023, 5995, 2282, 676, 81, 24185, 1023, 5565, 3065, 7, 272, 8350, 275, 942, 272, 6137, 63, 10159, 275, 791, 773, 21290, 14, 1152, 356, 283, 2164, 8083, 8450, 936, 272, 1929, 63, 270, 76, 63, 5555, 275, 715, 339, 347, 1900, 63, 1047, 8, 277, 12, 3819, 304, 267, 2589, 275, 291, 14, 362, 63, 13191, 63, 1813, 8, 1047, 9, 267, 327, 267, 327, 1973, 1152, 12980, 63, 13191, 275, 799, 8233, 14, 362, 63, 13191, 360, 773, 1152, 12980, 297, 291, 14, 3799, 9, 267, 327, 1973, 1152, 12980, 63, 694, 275, 1973, 1152, 12980, 63, 13191, 14, 362, 63, 1506, 63, 694, 8, 1047, 14, 1047, 9, 267, 327, 2589, 459, 1152, 12980, 63, 14804, 418, 275, 2475, 41, 11123, 908, 8, 904, 8, 267, 327, 258, 1973, 1152, 12980, 63, 694, 12, 283, 2164, 1333, 267, 327, 2589, 459, 1152, 12980, 63, 6533, 44, 1254, 51, 418, 275, 2475, 44, 11123, 908, 8, 904, 8, 267, 327, 258, 1973, 1152, 12980, 63, 694, 12, 283, 2164, 297, 283, 773, 1152, 12980, 297, 1987, 8450, 1333, 398, 1094, 694, 275, 291, 14, 362, 63, 1506, 63, 694, 8, 1047, 14, 1047, 9, 267, 2403, 275, 4263, 8, 15594, 12, 298, 3174, 531, 398, 543, 1453, 63, 3619, 8, 15594, 304, 288, 20387, 275, 1033, 14, 3110, 360, 609, 358, 288, 1033, 1361, 8, 355, 20387, 12, 21526, 6472, 297, 355, 2850, 1102, 27244, 908, 8, 1047, 14, 1531, 63, 1861, 395, 355, 2850, 7395, 13, 9970, 297, 355, 2850, 1861, 27244, 908, 8, 1861, 395, 355, 2850, 1045, 13, 773, 1152, 12980, 29, 889, 297, 355, 2850, 5993, 13, 773, 324, 11530, 297, 355, 485, 1813, 29, 1813, 9, 288, 1033, 1361, 8, 609, 14, 1875, 12, 485, 1813, 29, 1813, 9, 288, 1033, 1361, 8, 609, 14, 1875, 12, 283, 3174, 297, 485, 1813, 29, 1813, 9, 421, 199, 13191, 275, 8003, 58, 14449, 25879, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
rghe/ansible
lib/ansible/modules/network/aci/aci_rest.py
8
13847
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2017, Dag Wieers (@dagwieers) <dag@wieers.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: aci_rest short_description: Direct access to the Cisco APIC REST API description: - Enables the management of the Cisco ACI fabric through direct access to the Cisco APIC REST API. - Thanks to the idempotent nature of the APIC, this module is idempotent and reports changes. notes: - Certain payloads are known not to be idempotent, so be careful when constructing payloads, e.g. using C(status="created") will cause idempotency issues, use C(status="modified") instead. More information in :ref:`the ACI documentation <aci_guide_known_issues>`. - Certain payloads (and used paths) are known to report no changes happened when changes did happen. This is a known APIC problem and has been reported to the vendor. A workaround for this issue exists. More information in :ref:`the ACI documentation <aci_guide_known_issues>`. - XML payloads require the C(lxml) and C(xmljson) python libraries. For JSON payloads nothing special is needed. - More information regarding the APIC REST API is available from L(the Cisco APIC REST API Configuration Guide,http://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/2-x/rest_cfg/2_1_x/b_Cisco_APIC_REST_API_Configuration_Guide.html). # NOQA author: - Dag Wieers (@dagwieers) version_added: '2.4' requirements: - lxml (when using XML payload) - xmljson >= 0.1.8 (when using XML payload) - python 2.7+ (when using xmljson) options: method: description: - The HTTP method of the request. - Using C(delete) is typically used for deleting objects. - Using C(get) is typically used for querying objects. - Using C(post) is typically used for modifying objects. default: get choices: [ delete, get, post ] aliases: [ action ] path: description: - URI being used to execute API calls. - Must end in C(.xml) or C(.json). required: yes aliases: [ uri ] content: description: - When used instead of C(src), sets the payload of the API request directly. - This may be convenient to template simple requests. - For anything complex use the C(template) lookup plugin (see examples) or the M(template) module with parameter C(src). src: description: - Name of the absolute path of the filname that includes the body of the HTTP request being sent to the ACI fabric. - If you require a templated payload, use the C(content) parameter together with the C(template) lookup plugin, or use M(template). type: path aliases: [ config_file ] extends_documentation_fragment: aci ''' EXAMPLES = r''' - name: Add a tenant using certificate authentication aci_rest: host: apic username: admin private_key: pki/admin.key method: post path: /api/mo/uni.xml src: /home/cisco/ansible/aci/configs/aci_config.xml delegate_to: localhost - name: Add a tenant from a templated payload file from templates/ aci_rest: host: apic username: admin private_key: pki/admin.key method: post path: /api/mo/uni.xml content: "{{ lookup('template', 'aci/tenant.xml.j2') }}" delegate_to: localhost - name: Add a tenant using inline YAML aci_rest: host: apic username: admin private_key: pki/admin.key validate_certs: no path: /api/mo/uni.json method: post content: fvTenant: attributes: name: Sales descr: Sales departement delegate_to: localhost - name: Add a tenant using a JSON string aci_rest: host: apic username: admin private_key: pki/admin.key validate_certs: no path: /api/mo/uni.json method: post content: { "fvTenant": { "attributes": { "name": "Sales", "descr": "Sales departement" } } } delegate_to: localhost - name: Add a tenant using an XML string aci_rest: host: apic username: admin private_key: pki/{{ aci_username}}.key validate_certs: no path: /api/mo/uni.xml method: post content: '<fvTenant name="Sales" descr="Sales departement"/>' delegate_to: localhost - name: Get tenants using password authentication aci_rest: host: apic username: admin password: SomeSecretPassword method: get path: /api/node/class/fvTenant.json delegate_to: localhost register: query_result - name: Configure contracts aci_rest: host: apic username: admin private_key: pki/admin.key method: post path: /api/mo/uni.xml src: /home/cisco/ansible/aci/configs/contract_config.xml delegate_to: localhost - name: Register leaves and spines aci_rest: host: apic username: admin private_key: pki/admin.key validate_certs: no method: post path: /api/mo/uni/controller/nodeidentpol.xml content: | <fabricNodeIdentPol> <fabricNodeIdentP name="{{ item.name }}" nodeId="{{ item.nodeid }}" status="{{ item.status }}" serial="{{ item.serial }}"/> </fabricNodeIdentPol> with_items: - '{{ apic_leavesspines }}' delegate_to: localhost - name: Wait for all controllers to become ready aci_rest: host: apic username: admin private_key: pki/admin.key validate_certs: no path: /api/node/class/topSystem.json?query-target-filter=eq(topSystem.role,"controller") register: apics until: "'totalCount' in apics and apics.totalCount|int >= groups['apic']|count" retries: 120 delay: 30 delegate_to: localhost run_once: yes ''' RETURN = r''' error_code: description: The REST ACI return code, useful for troubleshooting on failure returned: always type: int sample: 122 error_text: description: The REST ACI descriptive text, useful for troubleshooting on failure returned: always type: string sample: unknown managed object class foo imdata: description: Converted output returned by the APIC REST (register this for post-processing) returned: always type: string sample: [{"error": {"attributes": {"code": "122", "text": "unknown managed object class foo"}}}] payload: description: The (templated) payload send to the APIC REST API (xml or json) returned: always type: string sample: '<foo bar="boo"/>' raw: description: The raw output returned by the APIC REST API (xml or json) returned: parse error type: string sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>' response: description: HTTP response string returned: always type: string sample: 'HTTP Error 400: Bad Request' status: description: HTTP status code returned: always type: int sample: 400 totalCount: description: Number of items in the imdata array returned: always type: string sample: '0' url: description: URL used for APIC REST call returned: success type: string sample: https://1.2.3.4/api/mo/uni/tn-[Dag].json?rsp-subtree=modified ''' import json import os try: from ansible.module_utils.six.moves.urllib.parse import parse_qsl, urlencode, urlparse, urlunparse HAS_URLPARSE = True except: HAS_URLPARSE = False # Optional, only used for XML payload try: import lxml.etree # noqa HAS_LXML_ETREE = True except ImportError: HAS_LXML_ETREE = False # Optional, only used for XML payload try: from xmljson import cobra # noqa HAS_XMLJSON_COBRA = True except ImportError: HAS_XMLJSON_COBRA = False # Optional, only used for YAML validation try: import yaml HAS_YAML = True except: HAS_YAML = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec from ansible.module_utils.urls import fetch_url from ansible.module_utils._text import to_text def update_qsl(url, params): ''' Add or update a URL query string ''' if HAS_URLPARSE: url_parts = list(urlparse(url)) query = dict(parse_qsl(url_parts[4])) query.update(params) url_parts[4] = urlencode(query) return urlunparse(url_parts) elif '?' in url: return url + '&' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()]) else: return url + '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()]) class ACIRESTModule(ACIModule): def changed(self, d): ''' Check ACI response for changes ''' if isinstance(d, dict): for k, v in d.items(): if k == 'status' and v in ('created', 'modified', 'deleted'): return True elif self.changed(v) is True: return True elif isinstance(d, list): for i in d: if self.changed(i) is True: return True return False def response_type(self, rawoutput, rest_type='xml'): ''' Handle APIC response output ''' if rest_type == 'json': self.response_json(rawoutput) else: self.response_xml(rawoutput) # Use APICs built-in idempotency if HAS_URLPARSE: self.result['changed'] = self.changed(self.imdata) def main(): argument_spec = aci_argument_spec() argument_spec.update( path=dict(type='str', required=True, aliases=['uri']), method=dict(type='str', default='get', choices=['delete', 'get', 'post'], aliases=['action']), src=dict(type='path', aliases=['config_file']), content=dict(type='raw'), ) module = AnsibleModule( argument_spec=argument_spec, mutually_exclusive=[['content', 'src']], ) content = module.params['content'] path = module.params['path'] src = module.params['src'] # Report missing file file_exists = False if src: if os.path.isfile(src): file_exists = True else: module.fail_json(msg="Cannot find/access src '%s'" % src) # Find request type if path.find('.xml') != -1: rest_type = 'xml' if not HAS_LXML_ETREE: module.fail_json(msg='The lxml python library is missing, or lacks etree support.') if not HAS_XMLJSON_COBRA: module.fail_json(msg='The xmljson python library is missing, or lacks cobra support.') elif path.find('.json') != -1: rest_type = 'json' else: module.fail_json(msg='Failed to find REST API payload type (neither .xml nor .json).') aci = ACIRESTModule(module) aci.result['status'] = -1 # Ensure we always return a status # We include the payload as it may be templated payload = content if file_exists: with open(src, 'r') as config_object: # TODO: Would be nice to template this, requires action-plugin payload = config_object.read() # Validate payload if rest_type == 'json': if content and isinstance(content, dict): # Validate inline YAML/JSON payload = json.dumps(payload) elif payload and isinstance(payload, str) and HAS_YAML: try: # Validate YAML/JSON string payload = json.dumps(yaml.safe_load(payload)) except Exception as e: module.fail_json(msg='Failed to parse provided JSON/YAML payload: %s' % to_text(e), exception=to_text(e), payload=payload) elif rest_type == 'xml' and HAS_LXML_ETREE: if content and isinstance(content, dict) and HAS_XMLJSON_COBRA: # Validate inline YAML/JSON # FIXME: Converting from a dictionary to XML is unsupported at this time # payload = etree.tostring(payload) pass elif payload and isinstance(payload, str): try: # Validate XML string payload = lxml.etree.tostring(lxml.etree.fromstring(payload)) except Exception as e: module.fail_json(msg='Failed to parse provided XML payload: %s' % to_text(e), payload=payload) # Perform actual request using auth cookie (Same as aci_request, but also supports XML) aci.url = '%(protocol)s://%(host)s/' % aci.params + path.lstrip('/') if aci.params['method'] != 'get': path += '?rsp-subtree=modified' aci.url = update_qsl(aci.url, {'rsp-subtree': 'modified'}) # Sign and encode request as to APIC's wishes if aci.params['private_key'] is not None: aci.cert_auth(path=path, payload=payload) aci.method = aci.params['method'].upper() # Perform request resp, info = fetch_url(module, aci.url, data=payload, headers=aci.headers, method=aci.method, timeout=aci.params['timeout'], use_proxy=aci.params['use_proxy']) aci.response = info['msg'] aci.status = info['status'] # Report failure if info['status'] != 200: try: # APIC error aci.response_type(info['body'], rest_type) aci.fail_json(msg='APIC Error %(code)s: %(text)s' % aci.error) except KeyError: # Connection error aci.fail_json(msg='Connection failed for %(url)s. %(msg)s' % info) aci.response_type(resp.read(), rest_type) aci.result['imdata'] = aci.imdata aci.result['totalCount'] = aci.totalCount # Report success aci.exit_json(**aci.result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 665, 7406, 32, 87, 1873, 1192, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 3911, 199, 3612, 63, 1802, 26, 21128, 2879, 370, 314, 28356, 25418, 14880, 3261, 199, 1802, 26, 199, 13, 3447, 5921, 314, 10041, 402, 314, 28356, 437, 3553, 2630, 4012, 4125, 2879, 370, 314, 28356, 25418, 14880, 3261, 14, 199, 13, 3868, 25088, 370, 314, 32122, 302, 1463, 402, 314, 25418, 12, 642, 859, 365, 32122, 436, 13924, 4493, 14, 199, 5983, 26, 199, 13, 11002, 877, 4886, 83, 787, 6040, 440, 370, 506, 32122, 12, 880, 506, 25082, 1380, 22048, 4886, 83, 12, 523, 325, 14, 71, 14, 1808, 445, 8, 1205, 628, 3966, 531, 911, 7675, 9979, 9613, 9447, 10876, 12, 675, 445, 8, 1205, 628, 5540, 531, 3140, 14, 523, 16917, 2556, 315, 520, 1121, 1705, 1589, 437, 3553, 3794, 665, 22832, 63, 17348, 63, 3159, 63, 10115, 14943, 199, 13, 11002, 877, 4886, 83, 334, 460, 1202, 3792, 9, 787, 6040, 370, 3622, 949, 4493, 21056, 1380, 4493, 8103, 5992, 14, 523, 961, 365, 282, 6040, 25418, 5160, 436, 965, 2757, 14581, 370, 314, 20868, 14, 437, 18092, 367, 642, 4976, 3495, 14, 523, 16917, 2556, 315, 520, 1121, 1705, 1589, 437, 3553, 3794, 665, 22832, 63, 17348, 63, 3159, 63, 10115, 14943, 199, 13, 4692, 4886, 83, 4409, 314, 445, 8, 22899, 9, 436, 445, 8, 1652, 1001, 9, 2366, 8363, 14, 2104, 4840, 4886, 83, 6548, 4539, 365, 4346, 14, 199, 13, 16917, 2556, 12602, 314, 25418, 14880, 3261, 365, 2808, 687, 523, 491, 8, 1589, 28356, 25418, 14880, 3261, 11595, 15423, 12, 1014, 921, 1544, 14, 19597, 14, 957, 15, 67, 15, 287, 15, 527, 15, 2076, 15, 4757, 15, 32332, 15, 17770, 15, 22832, 15, 20789, 15, 3519, 15, 18, 13, 88, 15, 3911, 63, 4128, 15, 18, 63, 17, 63, 88, 15, 66, 63, 17540, 63, 1282, 948, 63, 15740, 63, 3735, 63, 5688, 63, 4324, 271, 14, 1360, 680, 221, 327, 20432, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 7538, 26, 199, 13, 14490, 334, 6526, 1808, 4692, 4886, 9, 199, 13, 2748, 1001, 2356, 378, 14, 17, 14, 24, 334, 6526, 1808, 4692, 4886, 9, 199, 13, 2366, 499, 14, 23, 11, 334, 6526, 1808, 2748, 1001, 9, 199, 1419, 26, 523, 1083, 26, 272, 1369, 26, 272, 446, 710, 3101, 1083, 402, 314, 1056, 14, 272, 446, 11719, 445, 8, 1807, 9, 365, 13609, 1202, 367, 13794, 2251, 14, 272, 446, 11719, 445, 8, 362, 9, 365, 13609, 1202, 367, 27405, 2251, 14, 272, 446, 11719, 445, 8, 1932, 9, 365, 13609, 1202, 367, 24662, 2251, 14, 272, 849, 26, 664, 272, 3415, 26, 359, 3145, 12, 664, 12, 2963, 1622, 272, 5481, 26, 359, 1595, 1622, 523, 931, 26, 272, 1369, 26, 272, 446, 9022, 3769, 1202, 370, 5341, 3261, 4882, 14, 272, 446, 9498, 1284, 315, 445, 13417, 1652, 9, 503, 445, 13417, 1001, 680, 272, 1415, 26, 9456, 272, 5481, 26, 359, 5108, 1622, 523, 1564, 26, 272, 1369, 26, 272, 446, 3979, 1202, 3140, 402, 445, 8, 2164, 395, 5951, 314, 4886, 402, 314, 3261, 1056, 5370, 14, 272, 446, 961, 1443, 506, 22700, 370, 1978, 3486, 4145, 14, 272, 446, 2104, 7003, 6114, 675, 314, 445, 8, 1160, 9, 4237, 3589, 334, 3239, 7251, 9, 489, 503, 314, 603, 8, 1160, 9, 859, 543, 2725, 445, 8, 2164, 680, 523, 2928, 26, 272, 1369, 26, 272, 446, 2812, 402, 314, 3679, 931, 402, 314, 1794, 354, 626, 6952, 314, 2396, 489, 402, 314, 3101, 1056, 3769, 4847, 370, 314, 437, 3553, 2630, 14, 272, 446, 982, 1265, 4409, 282, 27960, 4886, 12, 675, 314, 445, 8, 1317, 9, 2725, 489, 10451, 543, 314, 445, 8, 1160, 9, 4237, 3589, 12, 503, 675, 603, 8, 1160, 680, 272, 730, 26, 931, 272, 5481, 26, 359, 1101, 63, 493, 1622, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 8261, 1808, 5897, 6299, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 1083, 26, 2963, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1652, 272, 2928, 26, 1182, 4219, 15, 19597, 15, 4853, 15, 22832, 15, 7532, 15, 22832, 63, 888, 14, 1652, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2654, 282, 8261, 687, 282, 27960, 4886, 570, 687, 7009, 15, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 1083, 26, 2963, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1652, 272, 1564, 26, 7370, 4237, 360, 1160, 297, 283, 22832, 15, 4647, 14, 1652, 14, 74, 18, 358, 7820, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2654, 282, 8261, 1808, 8308, 18916, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 4107, 63, 8356, 26, 949, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1001, 272, 1083, 26, 2963, 272, 1564, 26, 489, 289, 86, 27807 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 665, 7406, 32, 87, 1873, 1192, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 19631, 63, 3911, 199, 3612, 63, 1802, 26, 21128, 2879, 370, 314, 28356, 25418, 14880, 3261, 199, 1802, 26, 199, 13, 3447, 5921, 314, 10041, 402, 314, 28356, 437, 3553, 2630, 4012, 4125, 2879, 370, 314, 28356, 25418, 14880, 3261, 14, 199, 13, 3868, 25088, 370, 314, 32122, 302, 1463, 402, 314, 25418, 12, 642, 859, 365, 32122, 436, 13924, 4493, 14, 199, 5983, 26, 199, 13, 11002, 877, 4886, 83, 787, 6040, 440, 370, 506, 32122, 12, 880, 506, 25082, 1380, 22048, 4886, 83, 12, 523, 325, 14, 71, 14, 1808, 445, 8, 1205, 628, 3966, 531, 911, 7675, 9979, 9613, 9447, 10876, 12, 675, 445, 8, 1205, 628, 5540, 531, 3140, 14, 523, 16917, 2556, 315, 520, 1121, 1705, 1589, 437, 3553, 3794, 665, 22832, 63, 17348, 63, 3159, 63, 10115, 14943, 199, 13, 11002, 877, 4886, 83, 334, 460, 1202, 3792, 9, 787, 6040, 370, 3622, 949, 4493, 21056, 1380, 4493, 8103, 5992, 14, 523, 961, 365, 282, 6040, 25418, 5160, 436, 965, 2757, 14581, 370, 314, 20868, 14, 437, 18092, 367, 642, 4976, 3495, 14, 523, 16917, 2556, 315, 520, 1121, 1705, 1589, 437, 3553, 3794, 665, 22832, 63, 17348, 63, 3159, 63, 10115, 14943, 199, 13, 4692, 4886, 83, 4409, 314, 445, 8, 22899, 9, 436, 445, 8, 1652, 1001, 9, 2366, 8363, 14, 2104, 4840, 4886, 83, 6548, 4539, 365, 4346, 14, 199, 13, 16917, 2556, 12602, 314, 25418, 14880, 3261, 365, 2808, 687, 523, 491, 8, 1589, 28356, 25418, 14880, 3261, 11595, 15423, 12, 1014, 921, 1544, 14, 19597, 14, 957, 15, 67, 15, 287, 15, 527, 15, 2076, 15, 4757, 15, 32332, 15, 17770, 15, 22832, 15, 20789, 15, 3519, 15, 18, 13, 88, 15, 3911, 63, 4128, 15, 18, 63, 17, 63, 88, 15, 66, 63, 17540, 63, 1282, 948, 63, 15740, 63, 3735, 63, 5688, 63, 4324, 271, 14, 1360, 680, 221, 327, 20432, 199, 2502, 26, 199, 13, 26110, 644, 1873, 1192, 8593, 7406, 87, 1873, 1192, 9, 199, 1023, 63, 3270, 26, 283, 18, 14, 20, 7, 199, 7538, 26, 199, 13, 14490, 334, 6526, 1808, 4692, 4886, 9, 199, 13, 2748, 1001, 2356, 378, 14, 17, 14, 24, 334, 6526, 1808, 4692, 4886, 9, 199, 13, 2366, 499, 14, 23, 11, 334, 6526, 1808, 2748, 1001, 9, 199, 1419, 26, 523, 1083, 26, 272, 1369, 26, 272, 446, 710, 3101, 1083, 402, 314, 1056, 14, 272, 446, 11719, 445, 8, 1807, 9, 365, 13609, 1202, 367, 13794, 2251, 14, 272, 446, 11719, 445, 8, 362, 9, 365, 13609, 1202, 367, 27405, 2251, 14, 272, 446, 11719, 445, 8, 1932, 9, 365, 13609, 1202, 367, 24662, 2251, 14, 272, 849, 26, 664, 272, 3415, 26, 359, 3145, 12, 664, 12, 2963, 1622, 272, 5481, 26, 359, 1595, 1622, 523, 931, 26, 272, 1369, 26, 272, 446, 9022, 3769, 1202, 370, 5341, 3261, 4882, 14, 272, 446, 9498, 1284, 315, 445, 13417, 1652, 9, 503, 445, 13417, 1001, 680, 272, 1415, 26, 9456, 272, 5481, 26, 359, 5108, 1622, 523, 1564, 26, 272, 1369, 26, 272, 446, 3979, 1202, 3140, 402, 445, 8, 2164, 395, 5951, 314, 4886, 402, 314, 3261, 1056, 5370, 14, 272, 446, 961, 1443, 506, 22700, 370, 1978, 3486, 4145, 14, 272, 446, 2104, 7003, 6114, 675, 314, 445, 8, 1160, 9, 4237, 3589, 334, 3239, 7251, 9, 489, 503, 314, 603, 8, 1160, 9, 859, 543, 2725, 445, 8, 2164, 680, 523, 2928, 26, 272, 1369, 26, 272, 446, 2812, 402, 314, 3679, 931, 402, 314, 1794, 354, 626, 6952, 314, 2396, 489, 402, 314, 3101, 1056, 3769, 4847, 370, 314, 437, 3553, 2630, 14, 272, 446, 982, 1265, 4409, 282, 27960, 4886, 12, 675, 314, 445, 8, 1317, 9, 2725, 489, 10451, 543, 314, 445, 8, 1160, 9, 4237, 3589, 12, 503, 675, 603, 8, 1160, 680, 272, 730, 26, 931, 272, 5481, 26, 359, 1101, 63, 493, 1622, 199, 11036, 63, 9970, 63, 7677, 26, 19631, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2654, 282, 8261, 1808, 5897, 6299, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 1083, 26, 2963, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1652, 272, 2928, 26, 1182, 4219, 15, 19597, 15, 4853, 15, 22832, 15, 7532, 15, 22832, 63, 888, 14, 1652, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2654, 282, 8261, 687, 282, 27960, 4886, 570, 687, 7009, 15, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 1083, 26, 2963, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1652, 272, 1564, 26, 7370, 4237, 360, 1160, 297, 283, 22832, 15, 4647, 14, 1652, 14, 74, 18, 358, 7820, 523, 13080, 63, 475, 26, 11667, 199, 199, 13, 536, 26, 2654, 282, 8261, 1808, 8308, 18916, 523, 19631, 63, 3911, 26, 272, 1591, 26, 2771, 530, 272, 3434, 26, 4628, 272, 5726, 63, 498, 26, 3803, 73, 15, 2113, 14, 498, 272, 4107, 63, 8356, 26, 949, 272, 931, 26, 1182, 1246, 15, 573, 15, 5411, 14, 1001, 272, 1083, 26, 2963, 272, 1564, 26, 489, 289, 86, 27807, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
carolFrohlich/nipype
nipype/interfaces/afni/tests/test_auto_BlurToFWHM.py
2
1327
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT from ....testing import assert_equal from ..preprocess import BlurToFWHM def test_BlurToFWHM_inputs(): input_map = dict(args=dict(argstr='%s', ), automask=dict(argstr='-automask', ), blurmaster=dict(argstr='-blurmaster %s', ), environ=dict(nohash=True, usedefault=True, ), fwhm=dict(argstr='-FWHM %f', ), fwhmxy=dict(argstr='-FWHMxy %f', ), ignore_exception=dict(nohash=True, usedefault=True, ), in_file=dict(argstr='-input %s', mandatory=True, ), mask=dict(argstr='-blurmaster %s', ), out_file=dict(argstr='-prefix %s', name_source=[u'in_file'], name_template='%s_afni', ), outputtype=dict(), terminal_output=dict(nohash=True, ), ) inputs = BlurToFWHM.input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(inputs.traits()[key], metakey), value def test_BlurToFWHM_outputs(): output_map = dict(out_file=dict(), ) outputs = BlurToFWHM.output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(outputs.traits()[key], metakey), value
bsd-3-clause
[ 3, 25420, 13, 12795, 6989, 701, 7249, 15, 1074, 7273, 14, 647, 446, 3506, 2845, 24981, 199, 504, 29222, 4776, 492, 702, 63, 1452, 199, 504, 2508, 17677, 492, 699, 76, 300, 1378, 38, 9792, 45, 421, 199, 318, 511, 63, 24613, 300, 1378, 38, 9792, 45, 63, 3711, 837, 272, 1324, 63, 1130, 275, 1211, 8, 589, 29, 807, 8, 21371, 9569, 83, 297, 272, 2318, 272, 6384, 676, 813, 29, 807, 8, 21371, 18274, 6898, 676, 813, 297, 272, 2318, 272, 6826, 300, 4133, 29, 807, 8, 21371, 18274, 3345, 300, 4133, 450, 83, 297, 272, 2318, 272, 6160, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 289, 2191, 77, 29, 807, 8, 21371, 18274, 38, 9792, 45, 450, 70, 297, 272, 2318, 272, 289, 2191, 77, 1702, 29, 807, 8, 21371, 18274, 38, 9792, 45, 1702, 450, 70, 297, 272, 2318, 272, 3686, 63, 1971, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 315, 63, 493, 29, 807, 8, 21371, 18274, 1210, 450, 83, 297, 272, 15230, 29, 549, 12, 272, 2318, 272, 3656, 29, 807, 8, 21371, 18274, 3345, 300, 4133, 450, 83, 297, 272, 2318, 272, 734, 63, 493, 29, 807, 8, 21371, 18274, 1861, 450, 83, 297, 272, 536, 63, 1365, 1524, 85, 7, 262, 63, 493, 995, 272, 536, 63, 1160, 9569, 83, 63, 65, 2324, 73, 297, 272, 2318, 272, 1072, 466, 29, 807, 1062, 272, 11167, 63, 1199, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 2318, 272, 776, 272, 4153, 275, 699, 76, 300, 1378, 38, 9792, 45, 14, 1210, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1210, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 3711, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 421, 199, 318, 511, 63, 24613, 300, 1378, 38, 9792, 45, 63, 4467, 837, 272, 1072, 63, 1130, 275, 1211, 8, 548, 63, 493, 29, 807, 1062, 272, 776, 272, 4704, 275, 699, 76, 300, 1378, 38, 9792, 45, 14, 1199, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1199, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 4467, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 25420, 13, 12795, 6989, 701, 7249, 15, 1074, 7273, 14, 647, 446, 3506, 2845, 24981, 199, 504, 29222, 4776, 492, 702, 63, 1452, 199, 504, 2508, 17677, 492, 699, 76, 300, 1378, 38, 9792, 45, 421, 199, 318, 511, 63, 24613, 300, 1378, 38, 9792, 45, 63, 3711, 837, 272, 1324, 63, 1130, 275, 1211, 8, 589, 29, 807, 8, 21371, 9569, 83, 297, 272, 2318, 272, 6384, 676, 813, 29, 807, 8, 21371, 18274, 6898, 676, 813, 297, 272, 2318, 272, 6826, 300, 4133, 29, 807, 8, 21371, 18274, 3345, 300, 4133, 450, 83, 297, 272, 2318, 272, 6160, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 289, 2191, 77, 29, 807, 8, 21371, 18274, 38, 9792, 45, 450, 70, 297, 272, 2318, 272, 289, 2191, 77, 1702, 29, 807, 8, 21371, 18274, 38, 9792, 45, 1702, 450, 70, 297, 272, 2318, 272, 3686, 63, 1971, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 675, 885, 29, 549, 12, 272, 2318, 272, 315, 63, 493, 29, 807, 8, 21371, 18274, 1210, 450, 83, 297, 272, 15230, 29, 549, 12, 272, 2318, 272, 3656, 29, 807, 8, 21371, 18274, 3345, 300, 4133, 450, 83, 297, 272, 2318, 272, 734, 63, 493, 29, 807, 8, 21371, 18274, 1861, 450, 83, 297, 272, 536, 63, 1365, 1524, 85, 7, 262, 63, 493, 995, 272, 536, 63, 1160, 9569, 83, 63, 65, 2324, 73, 297, 272, 2318, 272, 1072, 466, 29, 807, 1062, 272, 11167, 63, 1199, 29, 807, 8, 889, 2227, 29, 549, 12, 272, 2318, 272, 776, 272, 4153, 275, 699, 76, 300, 1378, 38, 9792, 45, 14, 1210, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1210, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 3711, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 421, 199, 318, 511, 63, 24613, 300, 1378, 38, 9792, 45, 63, 4467, 837, 272, 1072, 63, 1130, 275, 1211, 8, 548, 63, 493, 29, 807, 1062, 272, 776, 272, 4704, 275, 699, 76, 300, 1378, 38, 9792, 45, 14, 1199, 63, 1650, 342, 339, 367, 790, 12, 3341, 315, 769, 8, 1199, 63, 1130, 14, 1744, 5109, 267, 367, 3404, 498, 12, 574, 315, 769, 8, 2343, 14, 1744, 5109, 288, 1995, 702, 63, 1452, 12, 2519, 8, 4467, 14, 17668, 3430, 498, 467, 3404, 498, 395, 574, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
andyakins/GCPOC
cloud/container_vm.py
1
2141
"""Creates a Container VM with the provided Container manifest.""" from container_helper import GenerateManifest COMPUTE_URL_BASE = 'https://www.googleapis.com/compute/v1/' def GlobalComputeUrl(project, collection, name): return ''.join([COMPUTE_URL_BASE, 'projects/', project, '/global/', collection, '/', name]) def ZonalComputeUrl(project, zone, collection, name): return ''.join([COMPUTE_URL_BASE, 'projects/', project, '/zones/', zone, '/', collection, '/', name]) def GenerateConfig(context): """Generate configuration.""" base_name = context.env['name'] # Properties for the container-based instance. instance = { 'zone': context.properties['zone'], 'machineType': ZonalComputeUrl(context.env['project'], context.properties['zone'], 'machineTypes', 'f1-micro'), 'metadata': { 'items': [{ 'key': 'google-container-manifest', 'value': GenerateManifest(context) }] }, 'disks': [{ 'deviceName': 'boot', 'type': 'PERSISTENT', 'autoDelete': True, 'boot': True, 'initializeParams': { 'diskName': base_name + '-disk', 'sourceImage': GlobalComputeUrl('google-containers', 'images', context.properties[ 'containerImage']) }, }], 'networkInterfaces': [{ 'accessConfigs': [{ 'name': 'external-nat', 'type': 'ONE_TO_ONE_NAT' }], 'network': GlobalComputeUrl(context.env['project'], 'networks', 'default') }] } resources = { 'resources': [{ 'name': base_name, 'type': 'compute.v1.instance', 'properties': instance }] } return resources
mit
[ 624, 10607, 282, 15395, 7525, 543, 314, 2741, 15395, 7712, 1041, 199, 199, 504, 3970, 63, 3676, 492, 7958, 11038, 199, 199, 6790, 4586, 63, 2632, 63, 5825, 275, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 3357, 15, 86, 17, 4805, 199, 199, 318, 13641, 8564, 6417, 8, 1715, 12, 3245, 12, 536, 304, 523, 372, 6522, 904, 779, 6790, 4586, 63, 2632, 63, 5825, 12, 283, 6776, 3678, 2199, 12, 2116, 1994, 2966, 3678, 3245, 12, 17220, 536, 566, 199, 199, 318, 3107, 8125, 8564, 6417, 8, 1715, 12, 5718, 12, 3245, 12, 536, 304, 523, 372, 6522, 904, 779, 6790, 4586, 63, 2632, 63, 5825, 12, 283, 6776, 3678, 2199, 12, 2116, 1994, 13325, 3678, 5718, 12, 17220, 3245, 12, 17220, 536, 566, 199, 199, 318, 7958, 2028, 8, 1100, 304, 523, 408, 6864, 2897, 1041, 819, 1300, 63, 354, 275, 1067, 14, 1813, 459, 354, 418, 523, 327, 19329, 367, 314, 3970, 13, 6788, 1256, 14, 523, 1256, 275, 469, 489, 283, 2619, 356, 1067, 14, 3282, 459, 2619, 995, 489, 283, 6744, 804, 356, 3107, 8125, 8564, 6417, 8, 1100, 14, 1813, 459, 1715, 995, 3660, 1067, 14, 3282, 459, 2619, 995, 3660, 283, 6744, 4100, 297, 3660, 283, 70, 17, 13, 6453, 659, 489, 283, 2343, 356, 469, 881, 283, 1744, 356, 8910, 1598, 283, 498, 356, 283, 3098, 13, 3600, 13, 6418, 297, 1598, 283, 585, 356, 7958, 11038, 8, 1100, 9, 1598, 14877, 881, 1660, 489, 283, 16203, 356, 8910, 881, 283, 1782, 985, 356, 283, 4930, 297, 881, 283, 466, 356, 283, 4227, 29367, 1309, 297, 881, 283, 2495, 5392, 356, 715, 12, 881, 283, 4930, 356, 715, 12, 881, 283, 8489, 6007, 356, 469, 1598, 283, 4032, 985, 356, 1300, 63, 354, 435, 2475, 4032, 297, 1598, 283, 1365, 3491, 356, 13641, 8564, 6417, 360, 3098, 13, 13577, 297, 6343, 283, 4782, 297, 6343, 1067, 14, 3282, 59, 8179, 283, 3600, 3491, 1105, 1598, 1660, 881, 19971, 489, 283, 1200, 18680, 356, 8910, 881, 283, 2732, 29123, 356, 8910, 1598, 283, 354, 356, 283, 5159, 13, 9468, 297, 1598, 283, 466, 356, 283, 4817, 63, 2566, 63, 4817, 63, 28927, 7, 1598, 19971, 881, 283, 1200, 356, 13641, 8564, 6417, 8, 1100, 14, 1813, 459, 1715, 995, 4228, 283, 7642, 297, 4228, 283, 885, 358, 881, 14877, 489, 789, 819, 5944, 275, 469, 489, 283, 4435, 356, 8910, 881, 283, 354, 356, 1300, 63, 354, 12, 881, 283, 466, 356, 283, 3357, 14, 86, 17, 14, 842, 297, 881, 283, 3282, 356, 1256, 881, 14877, 489, 789, 819, 372, 5944, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10607, 282, 15395, 7525, 543, 314, 2741, 15395, 7712, 1041, 199, 199, 504, 3970, 63, 3676, 492, 7958, 11038, 199, 199, 6790, 4586, 63, 2632, 63, 5825, 275, 283, 2859, 921, 1544, 14, 17533, 14, 957, 15, 3357, 15, 86, 17, 4805, 199, 199, 318, 13641, 8564, 6417, 8, 1715, 12, 3245, 12, 536, 304, 523, 372, 6522, 904, 779, 6790, 4586, 63, 2632, 63, 5825, 12, 283, 6776, 3678, 2199, 12, 2116, 1994, 2966, 3678, 3245, 12, 17220, 536, 566, 199, 199, 318, 3107, 8125, 8564, 6417, 8, 1715, 12, 5718, 12, 3245, 12, 536, 304, 523, 372, 6522, 904, 779, 6790, 4586, 63, 2632, 63, 5825, 12, 283, 6776, 3678, 2199, 12, 2116, 1994, 13325, 3678, 5718, 12, 17220, 3245, 12, 17220, 536, 566, 199, 199, 318, 7958, 2028, 8, 1100, 304, 523, 408, 6864, 2897, 1041, 819, 1300, 63, 354, 275, 1067, 14, 1813, 459, 354, 418, 523, 327, 19329, 367, 314, 3970, 13, 6788, 1256, 14, 523, 1256, 275, 469, 489, 283, 2619, 356, 1067, 14, 3282, 459, 2619, 995, 489, 283, 6744, 804, 356, 3107, 8125, 8564, 6417, 8, 1100, 14, 1813, 459, 1715, 995, 3660, 1067, 14, 3282, 459, 2619, 995, 3660, 283, 6744, 4100, 297, 3660, 283, 70, 17, 13, 6453, 659, 489, 283, 2343, 356, 469, 881, 283, 1744, 356, 8910, 1598, 283, 498, 356, 283, 3098, 13, 3600, 13, 6418, 297, 1598, 283, 585, 356, 7958, 11038, 8, 1100, 9, 1598, 14877, 881, 1660, 489, 283, 16203, 356, 8910, 881, 283, 1782, 985, 356, 283, 4930, 297, 881, 283, 466, 356, 283, 4227, 29367, 1309, 297, 881, 283, 2495, 5392, 356, 715, 12, 881, 283, 4930, 356, 715, 12, 881, 283, 8489, 6007, 356, 469, 1598, 283, 4032, 985, 356, 1300, 63, 354, 435, 2475, 4032, 297, 1598, 283, 1365, 3491, 356, 13641, 8564, 6417, 360, 3098, 13, 13577, 297, 6343, 283, 4782, 297, 6343, 1067, 14, 3282, 59, 8179, 283, 3600, 3491, 1105, 1598, 1660, 881, 19971, 489, 283, 1200, 18680, 356, 8910, 881, 283, 2732, 29123, 356, 8910, 1598, 283, 354, 356, 283, 5159, 13, 9468, 297, 1598, 283, 466, 356, 283, 4817, 63, 2566, 63, 4817, 63, 28927, 7, 1598, 19971, 881, 283, 1200, 356, 13641, 8564, 6417, 8, 1100, 14, 1813, 459, 1715, 995, 4228, 283, 7642, 297, 4228, 283, 885, 358, 881, 14877, 489, 789, 819, 5944, 275, 469, 489, 283, 4435, 356, 8910, 881, 283, 354, 356, 1300, 63, 354, 12, 881, 283, 466, 356, 283, 3357, 14, 86, 17, 14, 842, 297, 881, 283, 3282, 356, 1256, 881, 14877, 489, 789, 819, 372, 5944, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
utluiz/utluiz.github.io
pyscript/Lib/datetime.py
113
74954
"""Concrete date/time and related types. See http://www.iana.org/time-zones/repository/tz-link.html for time zone and DST data sources. """ import time as _time import math as _math def _cmp(x, y): return 0 if x == y else 1 if x > y else -1 MINYEAR = 1 MAXYEAR = 9999 _MAXORDINAL = 3652059 # date.max.toordinal() # Utility functions, adapted from Python's Demo/classes/Dates.py, which # also assumes the current Gregorian calendar indefinitely extended in # both directions. Difference: Dates.py calls January 1 of year 0 day # number 1. The code here calls January 1 of year 1 day number 1. This is # to match the definition of the "proleptic Gregorian" calendar in Dershowitz # and Reingold's "Calendrical Calculations", where it's the base calendar # for all computations. See the book for algorithms for converting between # proleptic Gregorian ordinals and many other calendar systems. _DAYS_IN_MONTH = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] _DAYS_BEFORE_MONTH = [None] dbm = 0 for dim in _DAYS_IN_MONTH[1:]: _DAYS_BEFORE_MONTH.append(dbm) dbm += dim del dbm, dim def _is_leap(year): "year -> 1 if leap year, else 0." return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def _days_before_year(year): "year -> number of days before January 1st of year." y = year - 1 return y*365 + y//4 - y//100 + y//400 def _days_in_month(year, month): "year, month -> number of days in that month in that year." assert 1 <= month <= 12, month if month == 2 and _is_leap(year): return 29 return _DAYS_IN_MONTH[month] def _days_before_month(year, month): "year, month -> number of days in year preceding first day of month." assert 1 <= month <= 12, 'month must be in 1..12' return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year)) def _ymd2ord(year, month, day): "year, month, day -> ordinal, considering 01-Jan-0001 as day 1." assert 1 <= month <= 12, 'month must be in 1..12' dim = _days_in_month(year, month) assert 1 <= day <= dim, ('day must be in 1..%d' % dim) return (_days_before_year(year) + _days_before_month(year, month) + day) _DI400Y = _days_before_year(401) # number of days in 400 years _DI100Y = _days_before_year(101) # " " " " 100 " _DI4Y = _days_before_year(5) # " " " " 4 " # A 4-year cycle has an extra leap day over what we'd get from pasting # together 4 single years. assert _DI4Y == 4 * 365 + 1 # Similarly, a 400-year cycle has an extra leap day over what we'd get from # pasting together 4 100-year cycles. assert _DI400Y == 4 * _DI100Y + 1 # OTOH, a 100-year cycle has one fewer leap day than we'd get from # pasting together 25 4-year cycles. assert _DI100Y == 25 * _DI4Y - 1 def _ord2ymd(n): "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1." # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years # repeats exactly every 400 years. The basic strategy is to find the # closest 400-year boundary at or before n, then work with the offset # from that boundary to n. Life is much clearer if we subtract 1 from # n first -- then the values of n at 400-year boundaries are exactly # those divisible by _DI400Y: # # D M Y n n-1 # -- --- ---- ---------- ---------------- # 31 Dec -400 -_DI400Y -_DI400Y -1 # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary # ... # 30 Dec 000 -1 -2 # 31 Dec 000 0 -1 # 1 Jan 001 1 0 400-year boundary # 2 Jan 001 2 1 # 3 Jan 001 3 2 # ... # 31 Dec 400 _DI400Y _DI400Y -1 # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary n -= 1 n400, n = divmod(n, _DI400Y) year = n400 * 400 + 1 # ..., -399, 1, 401, ... # Now n is the (non-negative) offset, in days, from January 1 of year, to # the desired date. Now compute how many 100-year cycles precede n. # Note that it's possible for n100 to equal 4! In that case 4 full # 100-year cycles precede the desired day, which implies the desired # day is December 31 at the end of a 400-year cycle. n100, n = divmod(n, _DI100Y) # Now compute how many 4-year cycles precede it. n4, n = divmod(n, _DI4Y) # And now how many single years. Again n1 can be 4, and again meaning # that the desired day is December 31 at the end of the 4-year cycle. n1, n = divmod(n, 365) year += n100 * 100 + n4 * 4 + n1 if n1 == 4 or n100 == 4: assert n == 0 return year-1, 12, 31 # Now the year is correct, and n is the offset from January 1. We find # the month via an estimate that's either exact or one too large. leapyear = n1 == 3 and (n4 != 24 or n100 == 3) assert leapyear == _is_leap(year) month = (n + 50) >> 5 preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear) if preceding > n: # estimate is too large month -= 1 preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear) n -= preceding assert 0 <= n < _days_in_month(year, month) # Now the year and month are correct, and n is the offset from the # start of that month: we're done! return year, month, n+1 # Month and day names. For localized versions, see the calendar module. _MONTHNAMES = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] _DAYNAMES = [None, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] def _build_struct_time(y, m, d, hh, mm, ss, dstflag): wday = (_ymd2ord(y, m, d) + 6) % 7 dnum = _days_before_month(y, m) + d return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag)) def _format_time(hh, mm, ss, us): # Skip trailing microseconds when us==0. result = "%02d:%02d:%02d" % (hh, mm, ss) if us: result += ".%06d" % us return result # Correctly substitute for %z and %Z escapes in strftime formats. def _wrap_strftime(object, format, timetuple): # Don't call utcoffset() or tzname() unless actually needed. freplace = None # the string to use for %f zreplace = None # the string to use for %z Zreplace = None # the string to use for %Z # Scan format for %z and %Z escapes, replacing as needed. newformat = [] push = newformat.append i, n = 0, len(format) while i < n: ch = format[i] i += 1 if ch == '%': if i < n: ch = format[i] i += 1 if ch == 'f': if freplace is None: freplace = '%06d' % getattr(object, 'microsecond', 0) newformat.append(freplace) elif ch == 'z': if zreplace is None: zreplace = "" if hasattr(object, "utcoffset"): offset = object.utcoffset() if offset is not None: sign = '+' if offset.days < 0: offset = -offset sign = '-' h, m = divmod(offset, timedelta(hours=1)) assert not m % timedelta(minutes=1), "whole minute" m //= timedelta(minutes=1) zreplace = '%c%02d%02d' % (sign, h, m) assert '%' not in zreplace newformat.append(zreplace) elif ch == 'Z': if Zreplace is None: Zreplace = "" if hasattr(object, "tzname"): s = object.tzname() if s is not None: # strftime is going to have at this: escape % Zreplace = s.replace('%', '%%') newformat.append(Zreplace) else: push('%') push(ch) else: push('%') else: push(ch) newformat = "".join(newformat) return _time.strftime(newformat, timetuple) def _call_tzinfo_method(tzinfo, methname, tzinfoarg): if tzinfo is None: return None return getattr(tzinfo, methname)(tzinfoarg) # Just raise TypeError if the arg isn't None or a string. def _check_tzname(name): if name is not None and not isinstance(name, str): raise TypeError("tzinfo.tzname() must return None or string, " "not '%s'" % type(name)) # name is the offset-producing method, "utcoffset" or "dst". # offset is what it returned. # If offset isn't None or timedelta, raises TypeError. # If offset is None, returns None. # Else offset is checked for being in range, and a whole # of minutes. # If it is, its integer value is returned. Else ValueError is raised. def _check_utc_offset(name, offset): assert name in ("utcoffset", "dst") if offset is None: return if not isinstance(offset, timedelta): raise TypeError("tzinfo.%s() must return None " "or timedelta, not '%s'" % (name, type(offset))) if offset % timedelta(minutes=1) or offset.microseconds: raise ValueError("tzinfo.%s() must return a whole number " "of minutes, got %s" % (name, offset)) if not -timedelta(1) < offset < timedelta(1): raise ValueError("%s()=%s, must be must be strictly between" " -timedelta(hours=24) and timedelta(hours=24)" % (name, offset)) def _check_date_fields(year, month, day): if not isinstance(year, int): raise TypeError('int expected') if not MINYEAR <= year <= MAXYEAR: raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), year) if not 1 <= month <= 12: raise ValueError('month must be in 1..12', month) dim = _days_in_month(year, month) if not 1 <= day <= dim: raise ValueError('day must be in 1..%d' % dim, day) def _check_time_fields(hour, minute, second, microsecond): if not isinstance(hour, int): raise TypeError('int expected') if not 0 <= hour <= 23: raise ValueError('hour must be in 0..23', hour) if not 0 <= minute <= 59: raise ValueError('minute must be in 0..59', minute) if not 0 <= second <= 59: raise ValueError('second must be in 0..59', second) if not 0 <= microsecond <= 999999: raise ValueError('microsecond must be in 0..999999', microsecond) def _check_tzinfo_arg(tz): if tz is not None and not isinstance(tz, tzinfo): raise TypeError("tzinfo argument must be None or of a tzinfo subclass") def _cmperror(x, y): raise TypeError("can't compare '%s' to '%s'" % ( type(x).__name__, type(y).__name__)) class timedelta: """Represent the difference between two datetime objects. Supported operators: - add, subtract timedelta - unary plus, minus, abs - compare to timedelta - multiply, divide by int In addition, datetime supports subtraction of two datetime objects returning a timedelta, and addition or subtraction of a datetime and a timedelta giving a datetime. Representation: (days, seconds, microseconds). Why? Because I felt like it. """ __slots__ = '_days', '_seconds', '_microseconds' def __new__(cls, days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0): # Doing this efficiently and accurately in C is going to be difficult # and error-prone, due to ubiquitous overflow possibilities, and that # C double doesn't have enough bits of precision to represent # microseconds over 10K years faithfully. The code here tries to make # explicit where go-fast assumptions can be relied on, in order to # guide the C implementation; it's way more convoluted than speed- # ignoring auto-overflow-to-long idiomatic Python could be. # XXX Check that all inputs are ints or floats. # Final values, all integer. # s and us fit in 32-bit signed ints; d isn't bounded. d = s = us = 0 # Normalize everything to days, seconds, microseconds. days += weeks*7 seconds += minutes*60 + hours*3600 microseconds += milliseconds*1000 # Get rid of all fractions, and normalize s and us. # Take a deep breath <wink>. if isinstance(days, float): dayfrac, days = _math.modf(days) daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) assert daysecondswhole == int(daysecondswhole) # can't overflow s = int(daysecondswhole) assert days == int(days) d = int(days) else: daysecondsfrac = 0.0 d = days assert isinstance(daysecondsfrac, float) assert abs(daysecondsfrac) <= 1.0 assert isinstance(d, int) assert abs(s) <= 24 * 3600 # days isn't referenced again before redefinition if isinstance(seconds, float): secondsfrac, seconds = _math.modf(seconds) assert seconds == int(seconds) seconds = int(seconds) secondsfrac += daysecondsfrac assert abs(secondsfrac) <= 2.0 else: secondsfrac = daysecondsfrac # daysecondsfrac isn't referenced again assert isinstance(secondsfrac, float) assert abs(secondsfrac) <= 2.0 assert isinstance(seconds, int) days, seconds = divmod(seconds, 24*3600) d += days s += int(seconds) # can't overflow assert isinstance(s, int) assert abs(s) <= 2 * 24 * 3600 # seconds isn't referenced again before redefinition usdouble = secondsfrac * 1e6 assert abs(usdouble) < 2.1e6 # exact value not critical # secondsfrac isn't referenced again if isinstance(microseconds, float): microseconds += usdouble microseconds = round(microseconds, 0) seconds, microseconds = divmod(microseconds, 1e6) assert microseconds == int(microseconds) assert seconds == int(seconds) days, seconds = divmod(seconds, 24.*3600.) assert days == int(days) assert seconds == int(seconds) d += int(days) s += int(seconds) # can't overflow assert isinstance(s, int) assert abs(s) <= 3 * 24 * 3600 else: seconds, microseconds = divmod(microseconds, 1000000) days, seconds = divmod(seconds, 24*3600) d += days s += int(seconds) # can't overflow assert isinstance(s, int) assert abs(s) <= 3 * 24 * 3600 microseconds = float(microseconds) microseconds += usdouble microseconds = round(microseconds, 0) assert abs(s) <= 3 * 24 * 3600 assert abs(microseconds) < 3.1e6 # Just a little bit of carrying possible for microseconds and seconds. assert isinstance(microseconds, float) assert int(microseconds) == microseconds us = int(microseconds) seconds, us = divmod(us, 1000000) s += seconds # cant't overflow assert isinstance(s, int) days, s = divmod(s, 24*3600) d += days assert isinstance(d, int) assert isinstance(s, int) and 0 <= s < 24*3600 assert isinstance(us, int) and 0 <= us < 1000000 self = object.__new__(cls) self._days = d self._seconds = s self._microseconds = us if abs(d) > 999999999: raise OverflowError("timedelta # of days is too large: %d" % d) return self def __repr__(self): if self._microseconds: return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__, self._days, self._seconds, self._microseconds) if self._seconds: return "%s(%d, %d)" % ('datetime.' + self.__class__.__name__, self._days, self._seconds) return "%s(%d)" % ('datetime.' + self.__class__.__name__, self._days) def __str__(self): mm, ss = divmod(self._seconds, 60) hh, mm = divmod(mm, 60) s = "%d:%02d:%02d" % (hh, mm, ss) if self._days: def plural(n): return n, abs(n) != 1 and "s" or "" s = ("%d day%s, " % plural(self._days)) + s if self._microseconds: s = s + ".%06d" % self._microseconds return s def total_seconds(self): """Total seconds in the duration.""" return ((self.days * 86400 + self.seconds)*10**6 + self.microseconds) / 10**6 # Read-only field accessors @property def days(self): """days""" return self._days @property def seconds(self): """seconds""" return self._seconds @property def microseconds(self): """microseconds""" return self._microseconds def __add__(self, other): if isinstance(other, timedelta): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta return timedelta(self._days + other._days, self._seconds + other._seconds, self._microseconds + other._microseconds) return NotImplemented __radd__ = __add__ def __sub__(self, other): if isinstance(other, timedelta): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta return timedelta(self._days - other._days, self._seconds - other._seconds, self._microseconds - other._microseconds) return NotImplemented def __rsub__(self, other): if isinstance(other, timedelta): return -self + other return NotImplemented def __neg__(self): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta return timedelta(-self._days, -self._seconds, -self._microseconds) def __pos__(self): return self def __abs__(self): if self._days < 0: return -self else: return self def __mul__(self, other): if isinstance(other, int): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta return timedelta(self._days * other, self._seconds * other, self._microseconds * other) if isinstance(other, float): a, b = other.as_integer_ratio() return self * a / b return NotImplemented __rmul__ = __mul__ def _to_microseconds(self): return ((self._days * (24*3600) + self._seconds) * 1000000 + self._microseconds) def __floordiv__(self, other): if not isinstance(other, (int, timedelta)): return NotImplemented usec = self._to_microseconds() if isinstance(other, timedelta): return usec // other._to_microseconds() if isinstance(other, int): return timedelta(0, 0, usec // other) def __truediv__(self, other): if not isinstance(other, (int, float, timedelta)): return NotImplemented usec = self._to_microseconds() if isinstance(other, timedelta): return usec / other._to_microseconds() if isinstance(other, int): return timedelta(0, 0, usec / other) if isinstance(other, float): a, b = other.as_integer_ratio() return timedelta(0, 0, b * usec / a) def __mod__(self, other): if isinstance(other, timedelta): r = self._to_microseconds() % other._to_microseconds() return timedelta(0, 0, r) return NotImplemented def __divmod__(self, other): if isinstance(other, timedelta): q, r = divmod(self._to_microseconds(), other._to_microseconds()) return q, timedelta(0, 0, r) return NotImplemented # Comparisons of timedelta objects with other. def __eq__(self, other): if isinstance(other, timedelta): return self._cmp(other) == 0 else: return False def __ne__(self, other): if isinstance(other, timedelta): return self._cmp(other) != 0 else: return True def __le__(self, other): if isinstance(other, timedelta): return self._cmp(other) <= 0 else: _cmperror(self, other) def __lt__(self, other): if isinstance(other, timedelta): return self._cmp(other) < 0 else: _cmperror(self, other) def __ge__(self, other): if isinstance(other, timedelta): return self._cmp(other) >= 0 else: _cmperror(self, other) def __gt__(self, other): if isinstance(other, timedelta): return self._cmp(other) > 0 else: _cmperror(self, other) def _cmp(self, other): assert isinstance(other, timedelta) return _cmp(self._getstate(), other._getstate()) def __hash__(self): return hash(self._getstate()) def __bool__(self): return (self._days != 0 or self._seconds != 0 or self._microseconds != 0) # Pickle support. def _getstate(self): return (self._days, self._seconds, self._microseconds) def __reduce__(self): return (self.__class__, self._getstate()) timedelta.min = timedelta(-999999999) timedelta.max = timedelta(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999) timedelta.resolution = timedelta(microseconds=1) class date: """Concrete date type. Constructors: __new__() fromtimestamp() today() fromordinal() Operators: __repr__, __str__ __cmp__, __hash__ __add__, __radd__, __sub__ (add/radd only with timedelta arg) Methods: timetuple() toordinal() weekday() isoweekday(), isocalendar(), isoformat() ctime() strftime() Properties (readonly): year, month, day """ __slots__ = '_year', '_month', '_day' def __new__(cls, year, month=None, day=None): """Constructor. Arguments: year, month, day (required, base 1) """ if (isinstance(year, bytes) and len(year) == 4 and 1 <= year[2] <= 12 and month is None): # Month is sane # Pickle support self = object.__new__(cls) self.__setstate(year) return self _check_date_fields(year, month, day) self = object.__new__(cls) self._year = year self._month = month self._day = day return self # Additional constructors @classmethod def fromtimestamp(cls, t): "Construct a date from a POSIX timestamp (like time.time())." y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t) return cls(y, m, d) @classmethod def today(cls): "Construct a date from time.time()." t = _time.time() return cls.fromtimestamp(t) @classmethod def fromordinal(cls, n): """Contruct a date from a proleptic Gregorian ordinal. January 1 of year 1 is day 1. Only the year, month and day are non-zero in the result. """ y, m, d = _ord2ymd(n) return cls(y, m, d) # Conversions to string def __repr__(self): """Convert to formal string, for repr(). >>> dt = datetime(2010, 1, 1) >>> repr(dt) 'datetime.datetime(2010, 1, 1, 0, 0)' >>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc) >>> repr(dt) 'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)' """ return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__, self._year, self._month, self._day) # XXX These shouldn't depend on time.localtime(), because that # clips the usable dates to [1970 .. 2038). At least ctime() is # easily done without using strftime() -- that's better too because # strftime("%c", ...) is locale specific. def ctime(self): "Return ctime() style string." weekday = self.toordinal() % 7 or 7 return "%s %s %2d 00:00:00 %04d" % ( _DAYNAMES[weekday], _MONTHNAMES[self._month], self._day, self._year) def strftime(self, fmt): "Format using strftime()." return _wrap_strftime(self, fmt, self.timetuple()) def __format__(self, fmt): if len(fmt) != 0: return self.strftime(fmt) return str(self) def isoformat(self): """Return the date formatted according to ISO. This is 'YYYY-MM-DD'. References: - http://www.w3.org/TR/NOTE-datetime - http://www.cl.cam.ac.uk/~mgk25/iso-time.html """ return "%04d-%02d-%02d" % (self._year, self._month, self._day) __str__ = isoformat # Read-only field accessors @property def year(self): """year (1-9999)""" return self._year @property def month(self): """month (1-12)""" return self._month @property def day(self): """day (1-31)""" return self._day # Standard conversions, __cmp__, __hash__ (and helpers) def timetuple(self): "Return local time tuple compatible with time.localtime()." return _build_struct_time(self._year, self._month, self._day, 0, 0, 0, -1) def toordinal(self): """Return proleptic Gregorian ordinal for the year, month and day. January 1 of year 1 is day 1. Only the year, month and day values contribute to the result. """ return _ymd2ord(self._year, self._month, self._day) def replace(self, year=None, month=None, day=None): """Return a new date with new values for the specified fields.""" if year is None: year = self._year if month is None: month = self._month if day is None: day = self._day _check_date_fields(year, month, day) return date(year, month, day) # Comparisons of date objects with other. def __eq__(self, other): if isinstance(other, date): return self._cmp(other) == 0 return NotImplemented def __ne__(self, other): if isinstance(other, date): return self._cmp(other) != 0 return NotImplemented def __le__(self, other): if isinstance(other, date): return self._cmp(other) <= 0 return NotImplemented def __lt__(self, other): if isinstance(other, date): return self._cmp(other) < 0 return NotImplemented def __ge__(self, other): if isinstance(other, date): return self._cmp(other) >= 0 return NotImplemented def __gt__(self, other): if isinstance(other, date): return self._cmp(other) > 0 return NotImplemented def _cmp(self, other): assert isinstance(other, date) y, m, d = self._year, self._month, self._day y2, m2, d2 = other._year, other._month, other._day return _cmp((y, m, d), (y2, m2, d2)) def __hash__(self): "Hash." return hash(self._getstate()) # Computations def __add__(self, other): "Add a date to a timedelta." if isinstance(other, timedelta): o = self.toordinal() + other.days if 0 < o <= _MAXORDINAL: return date.fromordinal(o) raise OverflowError("result out of range") return NotImplemented __radd__ = __add__ def __sub__(self, other): """Subtract two dates, or a date and a timedelta.""" if isinstance(other, timedelta): return self + timedelta(-other.days) if isinstance(other, date): days1 = self.toordinal() days2 = other.toordinal() return timedelta(days1 - days2) return NotImplemented def weekday(self): "Return day of the week, where Monday == 0 ... Sunday == 6." return (self.toordinal() + 6) % 7 # Day-of-the-week and week-of-the-year, according to ISO def isoweekday(self): "Return day of the week, where Monday == 1 ... Sunday == 7." # 1-Jan-0001 is a Monday return self.toordinal() % 7 or 7 def isocalendar(self): """Return a 3-tuple containing ISO year, week number, and weekday. The first ISO week of the year is the (Mon-Sun) week containing the year's first Thursday; everything else derives from that. The first week is 1; Monday is 1 ... Sunday is 7. ISO calendar algorithm taken from http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm """ year = self._year week1monday = _isoweek1monday(year) today = _ymd2ord(self._year, self._month, self._day) # Internally, week and day have origin 0 week, day = divmod(today - week1monday, 7) if week < 0: year -= 1 week1monday = _isoweek1monday(year) week, day = divmod(today - week1monday, 7) elif week >= 52: if today >= _isoweek1monday(year+1): year += 1 week = 0 return year, week+1, day+1 # Pickle support. def _getstate(self): yhi, ylo = divmod(self._year, 256) return bytes([yhi, ylo, self._month, self._day]), def __setstate(self, string): if len(string) != 4 or not (1 <= string[2] <= 12): raise TypeError("not enough arguments") yhi, ylo, self._month, self._day = string self._year = yhi * 256 + ylo def __reduce__(self): return (self.__class__, self._getstate()) _date_class = date # so functions w/ args named "date" can get at the class date.min = date(1, 1, 1) date.max = date(9999, 12, 31) date.resolution = timedelta(days=1) class tzinfo: """Abstract base class for time zone info classes. Subclasses must override the name(), utcoffset() and dst() methods. """ __slots__ = () def tzname(self, dt): "datetime -> string name of time zone." raise NotImplementedError("tzinfo subclass must override tzname()") def utcoffset(self, dt): "datetime -> minutes east of UTC (negative for west of UTC)" raise NotImplementedError("tzinfo subclass must override utcoffset()") def dst(self, dt): """datetime -> DST offset in minutes east of UTC. Return 0 if DST not in effect. utcoffset() must include the DST offset. """ raise NotImplementedError("tzinfo subclass must override dst()") def fromutc(self, dt): "datetime in UTC -> datetime in local time." if not isinstance(dt, datetime): raise TypeError("fromutc() requires a datetime argument") if dt.tzinfo is not self: raise ValueError("dt.tzinfo is not self") dtoff = dt.utcoffset() if dtoff is None: raise ValueError("fromutc() requires a non-None utcoffset() " "result") # See the long comment block at the end of this file for an # explanation of this algorithm. dtdst = dt.dst() if dtdst is None: raise ValueError("fromutc() requires a non-None dst() result") delta = dtoff - dtdst if delta: dt += delta dtdst = dt.dst() if dtdst is None: raise ValueError("fromutc(): dt.dst gave inconsistent " "results; cannot convert") return dt + dtdst # Pickle support. def __reduce__(self): getinitargs = getattr(self, "__getinitargs__", None) if getinitargs: args = getinitargs() else: args = () getstate = getattr(self, "__getstate__", None) if getstate: state = getstate() else: state = getattr(self, "__dict__", None) or None if state is None: return (self.__class__, args) else: return (self.__class__, args, state) _tzinfo_class = tzinfo class time: """Time with time zone. Constructors: __new__() Operators: __repr__, __str__ __cmp__, __hash__ Methods: strftime() isoformat() utcoffset() tzname() dst() Properties (readonly): hour, minute, second, microsecond, tzinfo """ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None): """Constructor. Arguments: hour, minute (required) second, microsecond (default to zero) tzinfo (default to None) """ self = object.__new__(cls) if isinstance(hour, bytes) and len(hour) == 6: # Pickle support self.__setstate(hour, minute or None) return self _check_tzinfo_arg(tzinfo) _check_time_fields(hour, minute, second, microsecond) self._hour = hour self._minute = minute self._second = second self._microsecond = microsecond self._tzinfo = tzinfo return self # Read-only field accessors @property def hour(self): """hour (0-23)""" return self._hour @property def minute(self): """minute (0-59)""" return self._minute @property def second(self): """second (0-59)""" return self._second @property def microsecond(self): """microsecond (0-999999)""" return self._microsecond @property def tzinfo(self): """timezone info object""" return self._tzinfo # Standard conversions, __hash__ (and helpers) # Comparisons of time objects with other. def __eq__(self, other): if isinstance(other, time): return self._cmp(other, allow_mixed=True) == 0 else: return False def __ne__(self, other): if isinstance(other, time): return self._cmp(other, allow_mixed=True) != 0 else: return True def __le__(self, other): if isinstance(other, time): return self._cmp(other) <= 0 else: _cmperror(self, other) def __lt__(self, other): if isinstance(other, time): return self._cmp(other) < 0 else: _cmperror(self, other) def __ge__(self, other): if isinstance(other, time): return self._cmp(other) >= 0 else: _cmperror(self, other) def __gt__(self, other): if isinstance(other, time): return self._cmp(other) > 0 else: _cmperror(self, other) def _cmp(self, other, allow_mixed=False): assert isinstance(other, time) mytz = self._tzinfo ottz = other._tzinfo myoff = otoff = None if mytz is ottz: base_compare = True else: myoff = self.utcoffset() otoff = other.utcoffset() base_compare = myoff == otoff if base_compare: return _cmp((self._hour, self._minute, self._second, self._microsecond), (other._hour, other._minute, other._second, other._microsecond)) if myoff is None or otoff is None: if allow_mixed: return 2 # arbitrary non-zero value else: raise TypeError("cannot compare naive and aware times") myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1) othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1) return _cmp((myhhmm, self._second, self._microsecond), (othhmm, other._second, other._microsecond)) def __hash__(self): """Hash.""" tzoff = self.utcoffset() if not tzoff: # zero or None return hash(self._getstate()[0]) h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff, timedelta(hours=1)) assert not m % timedelta(minutes=1), "whole minute" m //= timedelta(minutes=1) if 0 <= h < 24: return hash(time(h, m, self.second, self.microsecond)) return hash((h, m, self.second, self.microsecond)) # Conversion to string def _tzstr(self, sep=":"): """Return formatted timezone offset (+xx:xx) or None.""" off = self.utcoffset() if off is not None: if off.days < 0: sign = "-" off = -off else: sign = "+" hh, mm = divmod(off, timedelta(hours=1)) assert not mm % timedelta(minutes=1), "whole minute" mm //= timedelta(minutes=1) assert 0 <= hh < 24 off = "%s%02d%s%02d" % (sign, hh, sep, mm) return off def __repr__(self): """Convert to formal string, for repr().""" if self._microsecond != 0: s = ", %d, %d" % (self._second, self._microsecond) elif self._second != 0: s = ", %d" % self._second else: s = "" s= "%s(%d, %d%s)" % ('datetime.' + self.__class__.__name__, self._hour, self._minute, s) if self._tzinfo is not None: assert s[-1:] == ")" s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" return s def isoformat(self): """Return the time formatted according to ISO. This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if self.microsecond == 0. """ s = _format_time(self._hour, self._minute, self._second, self._microsecond) tz = self._tzstr() if tz: s += tz return s __str__ = isoformat def strftime(self, fmt): """Format using strftime(). The date part of the timestamp passed to underlying strftime should not be used. """ # The year must be >= 1000 else Python's strftime implementation # can raise a bogus exception. timetuple = (1900, 1, 1, self._hour, self._minute, self._second, 0, 1, -1) return _wrap_strftime(self, fmt, timetuple) def __format__(self, fmt): if len(fmt) != 0: return self.strftime(fmt) return str(self) # Timezone functions def utcoffset(self): """Return the timezone offset in minutes east of UTC (negative west of UTC).""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(None) _check_utc_offset("utcoffset", offset) return offset def tzname(self): """Return the timezone name. Note that the name is 100% informational -- there's no requirement that it mean anything in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies. """ if self._tzinfo is None: return None name = self._tzinfo.tzname(None) _check_tzname(name) return name def dst(self): """Return 0 if DST is not in effect, or the DST offset (in minutes eastward) if DST is in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no need to consult dst() unless you're interested in displaying the DST info. """ if self._tzinfo is None: return None offset = self._tzinfo.dst(None) _check_utc_offset("dst", offset) return offset def replace(self, hour=None, minute=None, second=None, microsecond=None, tzinfo=True): """Return a new time with new values for the specified fields.""" if hour is None: hour = self.hour if minute is None: minute = self.minute if second is None: second = self.second if microsecond is None: microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo _check_time_fields(hour, minute, second, microsecond) _check_tzinfo_arg(tzinfo) return time(hour, minute, second, microsecond, tzinfo) def __bool__(self): if self.second or self.microsecond: return True offset = self.utcoffset() or timedelta(0) return timedelta(hours=self.hour, minutes=self.minute) != offset # Pickle support. def _getstate(self): us2, us3 = divmod(self._microsecond, 256) us1, us2 = divmod(us2, 256) basestate = bytes([self._hour, self._minute, self._second, us1, us2, us3]) if self._tzinfo is None: return (basestate,) else: return (basestate, self._tzinfo) def __setstate(self, string, tzinfo): if len(string) != 6 or string[0] >= 24: raise TypeError("an integer is required") (self._hour, self._minute, self._second, us1, us2, us3) = string self._microsecond = (((us1 << 8) | us2) << 8) | us3 if tzinfo is None or isinstance(tzinfo, _tzinfo_class): self._tzinfo = tzinfo else: raise TypeError("bad tzinfo state arg %r" % tzinfo) def __reduce__(self): return (time, self._getstate()) _time_class = time # so functions w/ args named "time" can get at the class time.min = time(0, 0, 0) time.max = time(23, 59, 59, 999999) time.resolution = timedelta(microseconds=1) class datetime(date): """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]]) The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints. """ __slots__ = date.__slots__ + ( '_hour', '_minute', '_second', '_microsecond', '_tzinfo') def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0, microsecond=0, tzinfo=None): if isinstance(year, bytes) and len(year) == 10: # Pickle support self = date.__new__(cls, year[:4]) self.__setstate(year, month) return self _check_tzinfo_arg(tzinfo) _check_time_fields(hour, minute, second, microsecond) self = date.__new__(cls, year, month, day) self._hour = hour self._minute = minute self._second = second self._microsecond = microsecond self._tzinfo = tzinfo return self # Read-only field accessors @property def hour(self): """hour (0-23)""" return self._hour @property def minute(self): """minute (0-59)""" return self._minute @property def second(self): """second (0-59)""" return self._second @property def microsecond(self): """microsecond (0-999999)""" return self._microsecond @property def tzinfo(self): """timezone info object""" return self._tzinfo @classmethod def fromtimestamp(cls, t, tz=None): """Construct a datetime from a POSIX timestamp (like time.time()). A timezone info object may be passed in as well. """ _check_tzinfo_arg(tz) converter = _time.localtime if tz is None else _time.gmtime t, frac = divmod(t, 1.0) us = int(frac * 1e6) # If timestamp is less than one microsecond smaller than a # full second, us can be rounded up to 1000000. In this case, # roll over to seconds, otherwise, ValueError is raised # by the constructor. if us == 1000000: t += 1 us = 0 y, m, d, hh, mm, ss, weekday, jday, dst = converter(t) ss = min(ss, 59) # clamp out leap seconds if the platform has them result = cls(y, m, d, hh, mm, ss, us, tz) if tz is not None: result = tz.fromutc(result) return result @classmethod def utcfromtimestamp(cls, t): "Construct a UTC datetime from a POSIX timestamp (like time.time())." t, frac = divmod(t, 1.0) us = int(frac * 1e6) # If timestamp is less than one microsecond smaller than a # full second, us can be rounded up to 1000000. In this case, # roll over to seconds, otherwise, ValueError is raised # by the constructor. if us == 1000000: t += 1 us = 0 y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t) ss = min(ss, 59) # clamp out leap seconds if the platform has them return cls(y, m, d, hh, mm, ss, us) # XXX This is supposed to do better than we *can* do by using time.time(), # XXX if the platform supports a more accurate way. The C implementation # XXX uses gettimeofday on platforms that have it, but that isn't # XXX available from Python. So now() may return different results # XXX across the implementations. @classmethod def now(cls, tz=None): "Construct a datetime from time.time() and optional time zone info." t = _time.time() return cls.fromtimestamp(t, tz) @classmethod def utcnow(cls): "Construct a UTC datetime from time.time()." t = _time.time() return cls.utcfromtimestamp(t) @classmethod def combine(cls, date, time): "Construct a datetime from a given date and a given time." if not isinstance(date, _date_class): raise TypeError("date argument must be a date instance") if not isinstance(time, _time_class): raise TypeError("time argument must be a time instance") return cls(date.year, date.month, date.day, time.hour, time.minute, time.second, time.microsecond, time.tzinfo) def timetuple(self): "Return local time tuple compatible with time.localtime()." dst = self.dst() if dst is None: dst = -1 elif dst: dst = 1 else: dst = 0 return _build_struct_time(self.year, self.month, self.day, self.hour, self.minute, self.second, dst) def timestamp(self): "Return POSIX timestamp as float" if self._tzinfo is None: return _time.mktime((self.year, self.month, self.day, self.hour, self.minute, self.second, -1, -1, -1)) + self.microsecond / 1e6 else: return (self - _EPOCH).total_seconds() def utctimetuple(self): "Return UTC time tuple compatible with time.gmtime()." offset = self.utcoffset() if offset: self -= offset y, m, d = self.year, self.month, self.day hh, mm, ss = self.hour, self.minute, self.second return _build_struct_time(y, m, d, hh, mm, ss, 0) def date(self): "Return the date part." return date(self._year, self._month, self._day) def time(self): "Return the time part, with tzinfo None." return time(self.hour, self.minute, self.second, self.microsecond) def timetz(self): "Return the time part, with same tzinfo." return time(self.hour, self.minute, self.second, self.microsecond, self._tzinfo) def replace(self, year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None, tzinfo=True): """Return a new datetime with new values for the specified fields.""" if year is None: year = self.year if month is None: month = self.month if day is None: day = self.day if hour is None: hour = self.hour if minute is None: minute = self.minute if second is None: second = self.second if microsecond is None: microsecond = self.microsecond if tzinfo is True: tzinfo = self.tzinfo _check_date_fields(year, month, day) _check_time_fields(hour, minute, second, microsecond) _check_tzinfo_arg(tzinfo) return datetime(year, month, day, hour, minute, second, microsecond, tzinfo) def astimezone(self, tz=None): if tz is None: if self.tzinfo is None: raise ValueError("astimezone() requires an aware datetime") ts = (self - _EPOCH) // timedelta(seconds=1) localtm = _time.localtime(ts) local = datetime(*localtm[:6]) try: # Extract TZ data if available gmtoff = localtm.tm_gmtoff zone = localtm.tm_zone except AttributeError: # Compute UTC offset and compare with the value implied # by tm_isdst. If the values match, use the zone name # implied by tm_isdst. delta = local - datetime(*_time.gmtime(ts)[:6]) dst = _time.daylight and localtm.tm_isdst > 0 gmtoff = -(_time.altzone if dst else _time.timezone) if delta == timedelta(seconds=gmtoff): tz = timezone(delta, _time.tzname[dst]) else: tz = timezone(delta) else: tz = timezone(timedelta(seconds=gmtoff), zone) elif not isinstance(tz, tzinfo): raise TypeError("tz argument must be an instance of tzinfo") mytz = self.tzinfo if mytz is None: raise ValueError("astimezone() requires an aware datetime") if tz is mytz: return self # Convert self to UTC, and attach the new time zone object. myoffset = self.utcoffset() if myoffset is None: raise ValueError("astimezone() requires an aware datetime") utc = (self - myoffset).replace(tzinfo=tz) # Convert from UTC to tz's local time. return tz.fromutc(utc) # Ways to produce a string. def ctime(self): "Return ctime() style string." weekday = self.toordinal() % 7 or 7 return "%s %s %2d %02d:%02d:%02d %04d" % ( _DAYNAMES[weekday], _MONTHNAMES[self._month], self._day, self._hour, self._minute, self._second, self._year) def isoformat(self, sep='T'): """Return the time formatted according to ISO. This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if self.microsecond == 0. If self.tzinfo is not None, the UTC offset is also attached, giving 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'. Optional argument sep specifies the separator between date and time, default 'T'. """ s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) + _format_time(self._hour, self._minute, self._second, self._microsecond)) off = self.utcoffset() if off is not None: if off.days < 0: sign = "-" off = -off else: sign = "+" hh, mm = divmod(off, timedelta(hours=1)) assert not mm % timedelta(minutes=1), "whole minute" mm //= timedelta(minutes=1) s += "%s%02d:%02d" % (sign, hh, mm) return s def __repr__(self): """Convert to formal string, for repr().""" L = [self._year, self._month, self._day, # These are never zero self._hour, self._minute, self._second, self._microsecond] if L[-1] == 0: del L[-1] if L[-1] == 0: del L[-1] s = ", ".join(map(str, L)) s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s) if self._tzinfo is not None: assert s[-1:] == ")" s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" return s def __str__(self): "Convert to string, for str()." return self.isoformat(sep=' ') @classmethod def strptime(cls, date_string, format): 'string, format -> new datetime parsed from a string (like time.strptime()).' import _strptime return _strptime._strptime_datetime(cls, date_string, format) def utcoffset(self): """Return the timezone offset in minutes east of UTC (negative west of UTC).""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(self) _check_utc_offset("utcoffset", offset) return offset def tzname(self): """Return the timezone name. Note that the name is 100% informational -- there's no requirement that it mean anything in particular. For example, "GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies. """ name = _call_tzinfo_method(self._tzinfo, "tzname", self) _check_tzname(name) return name def dst(self): """Return 0 if DST is not in effect, or the DST offset (in minutes eastward) if DST is in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no need to consult dst() unless you're interested in displaying the DST info. """ if self._tzinfo is None: return None offset = self._tzinfo.dst(self) _check_utc_offset("dst", offset) return offset # Comparisons of datetime objects with other. def __eq__(self, other): if isinstance(other, datetime): return self._cmp(other, allow_mixed=True) == 0 elif not isinstance(other, date): return NotImplemented else: return False def __ne__(self, other): if isinstance(other, datetime): return self._cmp(other, allow_mixed=True) != 0 elif not isinstance(other, date): return NotImplemented else: return True def __le__(self, other): if isinstance(other, datetime): return self._cmp(other) <= 0 elif not isinstance(other, date): return NotImplemented else: _cmperror(self, other) def __lt__(self, other): if isinstance(other, datetime): return self._cmp(other) < 0 elif not isinstance(other, date): return NotImplemented else: _cmperror(self, other) def __ge__(self, other): if isinstance(other, datetime): return self._cmp(other) >= 0 elif not isinstance(other, date): return NotImplemented else: _cmperror(self, other) def __gt__(self, other): if isinstance(other, datetime): return self._cmp(other) > 0 elif not isinstance(other, date): return NotImplemented else: _cmperror(self, other) def _cmp(self, other, allow_mixed=False): assert isinstance(other, datetime) mytz = self._tzinfo ottz = other._tzinfo myoff = otoff = None if mytz is ottz: base_compare = True else: myoff = self.utcoffset() otoff = other.utcoffset() base_compare = myoff == otoff if base_compare: return _cmp((self._year, self._month, self._day, self._hour, self._minute, self._second, self._microsecond), (other._year, other._month, other._day, other._hour, other._minute, other._second, other._microsecond)) if myoff is None or otoff is None: if allow_mixed: return 2 # arbitrary non-zero value else: raise TypeError("cannot compare naive and aware datetimes") # XXX What follows could be done more efficiently... diff = self - other # this will take offsets into account if diff.days < 0: return -1 return diff and 1 or 0 def __add__(self, other): "Add a datetime and a timedelta." if not isinstance(other, timedelta): return NotImplemented delta = timedelta(self.toordinal(), hours=self._hour, minutes=self._minute, seconds=self._second, microseconds=self._microsecond) delta += other hour, rem = divmod(delta.seconds, 3600) minute, second = divmod(rem, 60) if 0 < delta.days <= _MAXORDINAL: return datetime.combine(date.fromordinal(delta.days), time(hour, minute, second, delta.microseconds, tzinfo=self._tzinfo)) raise OverflowError("result out of range") __radd__ = __add__ def __sub__(self, other): "Subtract two datetimes, or a datetime and a timedelta." if not isinstance(other, datetime): if isinstance(other, timedelta): return self + -other return NotImplemented days1 = self.toordinal() days2 = other.toordinal() secs1 = self._second + self._minute * 60 + self._hour * 3600 secs2 = other._second + other._minute * 60 + other._hour * 3600 base = timedelta(days1 - days2, secs1 - secs2, self._microsecond - other._microsecond) if self._tzinfo is other._tzinfo: return base myoff = self.utcoffset() otoff = other.utcoffset() if myoff == otoff: return base if myoff is None or otoff is None: raise TypeError("cannot mix naive and timezone-aware time") return base + otoff - myoff def __hash__(self): tzoff = self.utcoffset() if tzoff is None: return hash(self._getstate()[0]) days = _ymd2ord(self.year, self.month, self.day) seconds = self.hour * 3600 + self.minute * 60 + self.second return hash(timedelta(days, seconds, self.microsecond) - tzoff) # Pickle support. def _getstate(self): yhi, ylo = divmod(self._year, 256) us2, us3 = divmod(self._microsecond, 256) us1, us2 = divmod(us2, 256) basestate = bytes([yhi, ylo, self._month, self._day, self._hour, self._minute, self._second, us1, us2, us3]) if self._tzinfo is None: return (basestate,) else: return (basestate, self._tzinfo) def __setstate(self, string, tzinfo): (yhi, ylo, self._month, self._day, self._hour, self._minute, self._second, us1, us2, us3) = string self._year = yhi * 256 + ylo self._microsecond = (((us1 << 8) | us2) << 8) | us3 if tzinfo is None or isinstance(tzinfo, _tzinfo_class): self._tzinfo = tzinfo else: raise TypeError("bad tzinfo state arg %r" % tzinfo) def __reduce__(self): return (self.__class__, self._getstate()) datetime.min = datetime(1, 1, 1) datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999) datetime.resolution = timedelta(microseconds=1) def _isoweek1monday(year): # Helper to calculate the day number of the Monday starting week 1 # XXX This could be done more efficiently THURSDAY = 3 firstday = _ymd2ord(year, 1, 1) firstweekday = (firstday + 6) % 7 # See weekday() above week1monday = firstday - firstweekday if firstweekday > THURSDAY: week1monday += 7 return week1monday class timezone(tzinfo): __slots__ = '_offset', '_name' # Sentinel value to disallow None _Omitted = object() def __new__(cls, offset, name=_Omitted): if not isinstance(offset, timedelta): raise TypeError("offset must be a timedelta") if name is cls._Omitted: if not offset: return cls.utc name = None elif not isinstance(name, str): raise TypeError("name must be a string") if not cls._minoffset <= offset <= cls._maxoffset: raise ValueError("offset must be a timedelta" " strictly between -timedelta(hours=24) and" " timedelta(hours=24).") if (offset.microseconds != 0 or offset.seconds % 60 != 0): raise ValueError("offset must be a timedelta" " representing a whole number of minutes") return cls._create(offset, name) @classmethod def _create(cls, offset, name=None): self = tzinfo.__new__(cls) self._offset = offset self._name = name return self def __getinitargs__(self): """pickle support""" if self._name is None: return (self._offset,) return (self._offset, self._name) def __eq__(self, other): if type(other) != timezone: return False return self._offset == other._offset def __hash__(self): return hash(self._offset) def __repr__(self): """Convert to formal string, for repr(). >>> tz = timezone.utc >>> repr(tz) 'datetime.timezone.utc' >>> tz = timezone(timedelta(hours=-5), 'EST') >>> repr(tz) "datetime.timezone(datetime.timedelta(-1, 68400), 'EST')" """ if self is self.utc: return 'datetime.timezone.utc' if self._name is None: return "%s(%r)" % ('datetime.' + self.__class__.__name__, self._offset) return "%s(%r, %r)" % ('datetime.' + self.__class__.__name__, self._offset, self._name) def __str__(self): return self.tzname(None) def utcoffset(self, dt): if isinstance(dt, datetime) or dt is None: return self._offset raise TypeError("utcoffset() argument must be a datetime instance" " or None") def tzname(self, dt): if isinstance(dt, datetime) or dt is None: if self._name is None: return self._name_from_offset(self._offset) return self._name raise TypeError("tzname() argument must be a datetime instance" " or None") def dst(self, dt): if isinstance(dt, datetime) or dt is None: return None raise TypeError("dst() argument must be a datetime instance" " or None") def fromutc(self, dt): if isinstance(dt, datetime): if dt.tzinfo is not self: raise ValueError("fromutc: dt.tzinfo " "is not self") return dt + self._offset raise TypeError("fromutc() argument must be a datetime instance" " or None") _maxoffset = timedelta(hours=23, minutes=59) _minoffset = -_maxoffset @staticmethod def _name_from_offset(delta): if delta < timedelta(0): sign = '-' delta = -delta else: sign = '+' hours, rest = divmod(delta, timedelta(hours=1)) minutes = rest // timedelta(minutes=1) return 'UTC{}{:02d}:{:02d}'.format(sign, hours, minutes) timezone.utc = timezone._create(timedelta(0)) timezone.min = timezone._create(timezone._minoffset) timezone.max = timezone._create(timezone._maxoffset) _EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc) """ Some time zone algebra. For a datetime x, let x.n = x stripped of its timezone -- its naive time. x.o = x.utcoffset(), and assuming that doesn't raise an exception or return None x.d = x.dst(), and assuming that doesn't raise an exception or return None x.s = x's standard offset, x.o - x.d Now some derived rules, where k is a duration (timedelta). 1. x.o = x.s + x.d This follows from the definition of x.s. 2. If x and y have the same tzinfo member, x.s = y.s. This is actually a requirement, an assumption we need to make about sane tzinfo classes. 3. The naive UTC time corresponding to x is x.n - x.o. This is again a requirement for a sane tzinfo class. 4. (x+k).s = x.s This follows from #2, and that datimetimetz+timedelta preserves tzinfo. 5. (x+k).n = x.n + k Again follows from how arithmetic is defined. Now we can explain tz.fromutc(x). Let's assume it's an interesting case (meaning that the various tzinfo methods exist, and don't blow up or return None when called). The function wants to return a datetime y with timezone tz, equivalent to x. x is already in UTC. By #3, we want y.n - y.o = x.n [1] The algorithm starts by attaching tz to x.n, and calling that y. So x.n = y.n at the start. Then it wants to add a duration k to y, so that [1] becomes true; in effect, we want to solve [2] for k: (y+k).n - (y+k).o = x.n [2] By #1, this is the same as (y+k).n - ((y+k).s + (y+k).d) = x.n [3] By #5, (y+k).n = y.n + k, which equals x.n + k because x.n=y.n at the start. Substituting that into [3], x.n + k - (y+k).s - (y+k).d = x.n; the x.n terms cancel, leaving k - (y+k).s - (y+k).d = 0; rearranging, k = (y+k).s - (y+k).d; by #4, (y+k).s == y.s, so k = y.s - (y+k).d On the RHS, (y+k).d can't be computed directly, but y.s can be, and we approximate k by ignoring the (y+k).d term at first. Note that k can't be very large, since all offset-returning methods return a duration of magnitude less than 24 hours. For that reason, if y is firmly in std time, (y+k).d must be 0, so ignoring it has no consequence then. In any case, the new value is z = y + y.s [4] It's helpful to step back at look at [4] from a higher level: it's simply mapping from UTC to tz's standard time. At this point, if z.n - z.o = x.n [5] we have an equivalent time, and are almost done. The insecurity here is at the start of daylight time. Picture US Eastern for concreteness. The wall time jumps from 1:59 to 3:00, and wall hours of the form 2:MM don't make good sense then. The docs ask that an Eastern tzinfo class consider such a time to be EDT (because it's "after 2"), which is a redundant spelling of 1:MM EST on the day DST starts. We want to return the 1:MM EST spelling because that's the only spelling that makes sense on the local wall clock. In fact, if [5] holds at this point, we do have the standard-time spelling, but that takes a bit of proof. We first prove a stronger result. What's the difference between the LHS and RHS of [5]? Let diff = x.n - (z.n - z.o) [6] Now z.n = by [4] (y + y.s).n = by #5 y.n + y.s = since y.n = x.n x.n + y.s = since z and y are have the same tzinfo member, y.s = z.s by #2 x.n + z.s Plugging that back into [6] gives diff = x.n - ((x.n + z.s) - z.o) = expanding x.n - x.n - z.s + z.o = cancelling - z.s + z.o = by #2 z.d So diff = z.d. If [5] is true now, diff = 0, so z.d = 0 too, and we have the standard-time spelling we wanted in the endcase described above. We're done. Contrarily, if z.d = 0, then we have a UTC equivalent, and are also done. If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to add to z (in effect, z is in tz's standard time, and we need to shift the local clock into tz's daylight time). Let z' = z + z.d = z + diff [7] and we can again ask whether z'.n - z'.o = x.n [8] If so, we're done. If not, the tzinfo class is insane, according to the assumptions we've made. This also requires a bit of proof. As before, let's compute the difference between the LHS and RHS of [8] (and skipping some of the justifications for the kinds of substitutions we've done several times already): diff' = x.n - (z'.n - z'.o) = replacing z'.n via [7] x.n - (z.n + diff - z'.o) = replacing diff via [6] x.n - (z.n + x.n - (z.n - z.o) - z'.o) = x.n - z.n - x.n + z.n - z.o + z'.o = cancel x.n - z.n + z.n - z.o + z'.o = cancel z.n - z.o + z'.o = #1 twice -z.s - z.d + z'.s + z'.d = z and z' have same tzinfo z'.d - z.d So z' is UTC-equivalent to x iff z'.d = z.d at this point. If they are equal, we've found the UTC-equivalent so are done. In fact, we stop with [7] and return z', not bothering to compute z'.d. How could z.d and z'd differ? z' = z + z.d [7], so merely moving z' by a dst() offset, and starting *from* a time already in DST (we know z.d != 0), would have to change the result dst() returns: we start in DST, and moving a little further into it takes us out of DST. There isn't a sane case where this can happen. The closest it gets is at the end of DST, where there's an hour in UTC with no spelling in a hybrid tzinfo class. In US Eastern, that's 5:MM UTC = 0:MM EST = 1:MM EDT. During that hour, on an Eastern clock 1:MM is taken as being in standard time (6:MM UTC) because the docs insist on that, but 0:MM is taken as being in daylight time (4:MM UTC). There is no local time mapping to 5:MM UTC. The local clock jumps from 1:59 back to 1:00 again, and repeats the 1:MM hour in standard time. Since that's what the local clock *does*, we want to map both UTC hours 5:MM and 6:MM to 1:MM Eastern. The result is ambiguous in local time, but so it goes -- it's the way the local clock works. When x = 5:MM UTC is the input to this algorithm, x.o=0, y.o=-5 and y.d=0, so z=0:MM. z.d=60 (minutes) then, so [5] doesn't hold and we keep going. z' = z + z.d = 1:MM then, and z'.d=0, and z'.d - z.d = -60 != 0 so [8] (correctly) concludes that z' is not UTC-equivalent to x. Because we know z.d said z was in daylight time (else [5] would have held and we would have stopped then), and we know z.d != z'.d (else [8] would have held and we have stopped then), and there are only 2 possible values dst() can return in Eastern, it follows that z'.d must be 0 (which it is in the example, but the reasoning doesn't depend on the example -- it depends on there being two possible dst() outcomes, one zero and the other non-zero). Therefore z' must be in standard time, and is the spelling we want in this case. Note again that z' is not UTC-equivalent as far as the hybrid tzinfo class is concerned (because it takes z' as being in standard time rather than the daylight time we intend here), but returning it gives the real-life "local clock repeats an hour" behavior when mapping the "unspellable" UTC hour into tz. When the input is 6:MM, z=1:MM and z.d=0, and we stop at once, again with the 1:MM standard time spelling we want. So how can this break? One of the assumptions must be violated. Two possibilities: 1) [2] effectively says that y.s is invariant across all y belong to a given time zone. This isn't true if, for political reasons or continental drift, a region decides to change its base offset from UTC. 2) There may be versions of "double daylight" time where the tail end of the analysis gives up a step too early. I haven't thought about that enough to say. In any case, it's clear that the default fromutc() is strong enough to handle "almost all" time zones: so long as the standard offset is invariant, it doesn't matter if daylight time transition points change from year to year, or if daylight time is skipped in some years; it doesn't matter how large or small dst() may get within its bounds; and it doesn't even matter if some perverse time zone returns a negative dst()). So a breaking case must be pretty bizarre, and a tzinfo subclass can override fromutc() if it is. """ try: from _datetime import * except ImportError: pass else: # Clean up unused names del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH, _DI100Y, _DI400Y, _DI4Y, _MAXORDINAL, _MONTHNAMES, _build_struct_time, _call_tzinfo_method, _check_date_fields, _check_time_fields, _check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror, _date_class, _days_before_month, _days_before_year, _days_in_month, _format_time, _is_leap, _isoweek1monday, _math, _ord2ymd, _time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord) # XXX Since import * above excludes names that start with _, # docstring does not get overwritten. In the future, it may be # appropriate to maintain a single module level docstring and # remove the following line. from _datetime import __doc__
mit
[ 624, 714, 7564, 1434, 15, 521, 436, 4048, 2943, 14, 199, 199, 9295, 1455, 921, 1544, 14, 5653, 65, 14, 1308, 15, 521, 13, 13325, 15, 8421, 15, 3903, 13, 1073, 14, 1360, 367, 199, 521, 5718, 436, 22782, 666, 5274, 14, 199, 624, 199, 199, 646, 900, 465, 485, 521, 199, 646, 3473, 465, 485, 3442, 199, 199, 318, 485, 5730, 8, 88, 12, 612, 304, 272, 372, 378, 340, 671, 508, 612, 587, 413, 340, 671, 690, 612, 587, 446, 17, 199, 199, 4896, 19216, 275, 413, 199, 4283, 19216, 275, 221, 5008, 199, 63, 4283, 3731, 13384, 275, 28046, 1165, 1427, 327, 1434, 14, 988, 14, 475, 17460, 342, 199, 199, 3, 20511, 3423, 12, 26266, 687, 2018, 1159, 28939, 15, 2888, 15, 36, 2335, 14, 647, 12, 1314, 199, 3, 2597, 15194, 314, 1453, 29096, 269, 5653, 11234, 315, 23442, 590, 9243, 315, 199, 3, 3865, 28820, 14, 221, 18029, 4646, 26, 221, 577, 2335, 14, 647, 4882, 17474, 20527, 413, 402, 5361, 378, 5382, 199, 3, 1329, 413, 14, 221, 710, 1233, 2348, 4882, 17474, 20527, 413, 402, 5361, 413, 5382, 1329, 413, 14, 221, 961, 365, 199, 3, 370, 1336, 314, 5492, 402, 314, 298, 496, 274, 80, 764, 29096, 269, 5653, 2, 11234, 315, 577, 1192, 1917, 23751, 199, 3, 436, 799, 316, 1753, 1159, 298, 3630, 12944, 8825, 19821, 1298, 401, 2382, 652, 1159, 314, 1300, 11234, 199, 3, 367, 1006, 28319, 1298, 14, 221, 1666, 314, 6719, 367, 18036, 367, 13806, 3382, 199, 3, 557, 274, 80, 764, 29096, 269, 5653, 24943, 83, 436, 5002, 1163, 11234, 10460, 14, 199, 199, 63, 25683, 63, 568, 63, 16413, 275, 359, 403, 12, 7105, 12, 7294, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 61, 199, 199, 63, 25683, 63, 31481, 63, 16413, 275, 359, 403, 61, 199, 20666, 275, 378, 199, 509, 8134, 315, 485, 25683, 63, 568, 63, 16413, 59, 17, 10688, 272, 485, 25683, 63, 31481, 63, 16413, 14, 740, 8, 20666, 9, 272, 31093, 847, 8134, 199, 2264, 31093, 12, 8134, 199, 199, 318, 485, 374, 63, 28764, 8, 3403, 304, 272, 298, 3403, 1035, 413, 340, 29487, 5361, 12, 587, 378, 2122, 272, 372, 5361, 450, 841, 508, 378, 436, 334, 3403, 450, 2948, 1137, 378, 503, 5361, 450, 8290, 508, 378, 9, 199, 199, 318, 485, 4899, 63, 5182, 63, 3403, 8, 3403, 304, 272, 298, 3403, 1035, 1329, 402, 7609, 2544, 17474, 20527, 413, 270, 402, 5361, 2122, 272, 612, 275, 5361, 446, 413, 272, 372, 612, 10, 12664, 435, 612, 501, 20, 446, 612, 501, 1960, 435, 612, 501, 5303, 199, 199, 318, 485, 4899, 63, 262, 63, 4482, 8, 3403, 12, 5794, 304, 272, 298, 3403, 12, 5794, 1035, 1329, 402, 7609, 315, 626, 5794, 315, 626, 5361, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 5794, 272, 340, 5794, 508, 499, 436, 485, 374, 63, 28764, 8, 3403, 304, 267, 372, 7349, 272, 372, 485, 25683, 63, 568, 63, 16413, 59, 4482, 61, 199, 199, 318, 485, 4899, 63, 5182, 63, 4482, 8, 3403, 12, 5794, 304, 272, 298, 3403, 12, 5794, 1035, 1329, 402, 7609, 315, 5361, 22627, 1642, 5382, 402, 5794, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 283, 4482, 1471, 506, 315, 413, 703, 713, 7, 272, 372, 485, 25683, 63, 31481, 63, 16413, 59, 4482, 61, 435, 334, 4482, 690, 499, 436, 485, 374, 63, 28764, 8, 3403, 430, 199, 199, 318, 485, 89, 1064, 18, 2181, 8, 3403, 12, 5794, 12, 5382, 304, 272, 298, 3403, 12, 5794, 12, 5382, 1035, 24943, 12, 11201, 316, 17163, 13, 19825, 13, 4183, 465, 5382, 413, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 283, 4482, 1471, 506, 315, 413, 703, 713, 7, 272, 8134, 275, 485, 4899, 63, 262, 63, 4482, 8, 3403, 12, 5794, 9, 272, 702, 413, 2695, 5382, 2695, 8134, 12, 661, 2977, 1471, 506, 315, 413, 703, 5, 68, 7, 450, 8134, 9, 272, 372, 6110, 4899, 63, 5182, 63, 3403, 8, 3403, 9, 435, 288, 485, 4899, 63, 5182, 63, 4482, 8, 3403, 12, 5794, 9, 435, 288, 5382, 9, 199, 199, 63, 1914, 5303, 57, 275, 485, 4899, 63, 5182, 63, 3403, 8, 8854, 9, 259, 327, 1329, 402, 7609, 315, 8290, 17399, 199, 63, 1914, 1960, 57, 275, 485, 4899, 63, 5182, 63, 3403, 8, 4893, 9, 259, 327, 259, 298, 259, 298, 257, 298, 257, 298, 2948, 257, 298, 199, 63, 1914, 20, 57, 257, 275, 485, 4899, 63, 5182, 63, 3403, 8, 21, 9, 420, 327, 259, 298, 259, 298, 257, 298, 257, 298, 257, 841, 257, 298, 199, 199, 3, 437, 841, 13, 3403, 8643, 965, 376, 2402, 29487, 5382, 1806, 4052, 781, 5121, 664, 687, 13541, 316, 199, 3, 10451, 841, 2849, 17399, 14, 199, 479, 485, 1914, 20, 57, 508, 841, 627, 28046, 435, 413, 199, 199, 3, 20046, 590, 12, 282, 8290, 13, 3403, 8643, 965, 376, 2402, 29487, 5382, 1806, 4052, 781, 5121, 664, 687, 199, 3, 13541, 316, 10451, 841, 2948, 13, 3403, 19001, 14, 199, 479, 485, 1914, 5303, 57, 508, 841, 627, 485, 1914, 1960, 57, 435, 413, 199, 199, 3, 593, 2566, 40, 12, 282, 2948, 13, 3403, 8643, 965, 1373, 27392, 29487, 5382, 2419, 781, 5121, 664, 687, 199, 3, 13541, 316, 10451, 5661, 841, 13, 3403, 19001, 14, 199, 479, 485, 1914, 1960, 57, 508, 5661, 627, 485, 1914, 20, 57, 446, 413, 199, 199, 318, 485, 2181, 18, 89, 1064, 8, 78, 304, 272, 298, 17460, 1035, 334, 3403, 12, 5794, 12, 5382, 395, 11201, 316, 17163, 13, 19825, 13, 4183, 465, 5382, 413, 2122, 339, 327, 302, 365, 282, 413, 13, 6788, 1478, 12, 6617, 737, 413, 13, 19825, 13, 17, 14, 221, 710, 3851, 402, 29487, 17399, 272, 327, 28908, 8840, 4036, 8290, 17399, 14, 221, 710, 5678, 10054, 365, 370, 2342, 314, 272, 327, 18284, 8290, 13, 3403, 8424, 737, 503, 2544, 302, 12, 2066, 1736, 543, 314, 3268, 272, 327, 687, 626, 8424, 370, 302, 14, 221, 491, 16839, 365, 8298, 15158, 21462 ]
[ 714, 7564, 1434, 15, 521, 436, 4048, 2943, 14, 199, 199, 9295, 1455, 921, 1544, 14, 5653, 65, 14, 1308, 15, 521, 13, 13325, 15, 8421, 15, 3903, 13, 1073, 14, 1360, 367, 199, 521, 5718, 436, 22782, 666, 5274, 14, 199, 624, 199, 199, 646, 900, 465, 485, 521, 199, 646, 3473, 465, 485, 3442, 199, 199, 318, 485, 5730, 8, 88, 12, 612, 304, 272, 372, 378, 340, 671, 508, 612, 587, 413, 340, 671, 690, 612, 587, 446, 17, 199, 199, 4896, 19216, 275, 413, 199, 4283, 19216, 275, 221, 5008, 199, 63, 4283, 3731, 13384, 275, 28046, 1165, 1427, 327, 1434, 14, 988, 14, 475, 17460, 342, 199, 199, 3, 20511, 3423, 12, 26266, 687, 2018, 1159, 28939, 15, 2888, 15, 36, 2335, 14, 647, 12, 1314, 199, 3, 2597, 15194, 314, 1453, 29096, 269, 5653, 11234, 315, 23442, 590, 9243, 315, 199, 3, 3865, 28820, 14, 221, 18029, 4646, 26, 221, 577, 2335, 14, 647, 4882, 17474, 20527, 413, 402, 5361, 378, 5382, 199, 3, 1329, 413, 14, 221, 710, 1233, 2348, 4882, 17474, 20527, 413, 402, 5361, 413, 5382, 1329, 413, 14, 221, 961, 365, 199, 3, 370, 1336, 314, 5492, 402, 314, 298, 496, 274, 80, 764, 29096, 269, 5653, 2, 11234, 315, 577, 1192, 1917, 23751, 199, 3, 436, 799, 316, 1753, 1159, 298, 3630, 12944, 8825, 19821, 1298, 401, 2382, 652, 1159, 314, 1300, 11234, 199, 3, 367, 1006, 28319, 1298, 14, 221, 1666, 314, 6719, 367, 18036, 367, 13806, 3382, 199, 3, 557, 274, 80, 764, 29096, 269, 5653, 24943, 83, 436, 5002, 1163, 11234, 10460, 14, 199, 199, 63, 25683, 63, 568, 63, 16413, 275, 359, 403, 12, 7105, 12, 7294, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 61, 199, 199, 63, 25683, 63, 31481, 63, 16413, 275, 359, 403, 61, 199, 20666, 275, 378, 199, 509, 8134, 315, 485, 25683, 63, 568, 63, 16413, 59, 17, 10688, 272, 485, 25683, 63, 31481, 63, 16413, 14, 740, 8, 20666, 9, 272, 31093, 847, 8134, 199, 2264, 31093, 12, 8134, 199, 199, 318, 485, 374, 63, 28764, 8, 3403, 304, 272, 298, 3403, 1035, 413, 340, 29487, 5361, 12, 587, 378, 2122, 272, 372, 5361, 450, 841, 508, 378, 436, 334, 3403, 450, 2948, 1137, 378, 503, 5361, 450, 8290, 508, 378, 9, 199, 199, 318, 485, 4899, 63, 5182, 63, 3403, 8, 3403, 304, 272, 298, 3403, 1035, 1329, 402, 7609, 2544, 17474, 20527, 413, 270, 402, 5361, 2122, 272, 612, 275, 5361, 446, 413, 272, 372, 612, 10, 12664, 435, 612, 501, 20, 446, 612, 501, 1960, 435, 612, 501, 5303, 199, 199, 318, 485, 4899, 63, 262, 63, 4482, 8, 3403, 12, 5794, 304, 272, 298, 3403, 12, 5794, 1035, 1329, 402, 7609, 315, 626, 5794, 315, 626, 5361, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 5794, 272, 340, 5794, 508, 499, 436, 485, 374, 63, 28764, 8, 3403, 304, 267, 372, 7349, 272, 372, 485, 25683, 63, 568, 63, 16413, 59, 4482, 61, 199, 199, 318, 485, 4899, 63, 5182, 63, 4482, 8, 3403, 12, 5794, 304, 272, 298, 3403, 12, 5794, 1035, 1329, 402, 7609, 315, 5361, 22627, 1642, 5382, 402, 5794, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 283, 4482, 1471, 506, 315, 413, 703, 713, 7, 272, 372, 485, 25683, 63, 31481, 63, 16413, 59, 4482, 61, 435, 334, 4482, 690, 499, 436, 485, 374, 63, 28764, 8, 3403, 430, 199, 199, 318, 485, 89, 1064, 18, 2181, 8, 3403, 12, 5794, 12, 5382, 304, 272, 298, 3403, 12, 5794, 12, 5382, 1035, 24943, 12, 11201, 316, 17163, 13, 19825, 13, 4183, 465, 5382, 413, 2122, 272, 702, 413, 2695, 5794, 2695, 3144, 12, 283, 4482, 1471, 506, 315, 413, 703, 713, 7, 272, 8134, 275, 485, 4899, 63, 262, 63, 4482, 8, 3403, 12, 5794, 9, 272, 702, 413, 2695, 5382, 2695, 8134, 12, 661, 2977, 1471, 506, 315, 413, 703, 5, 68, 7, 450, 8134, 9, 272, 372, 6110, 4899, 63, 5182, 63, 3403, 8, 3403, 9, 435, 288, 485, 4899, 63, 5182, 63, 4482, 8, 3403, 12, 5794, 9, 435, 288, 5382, 9, 199, 199, 63, 1914, 5303, 57, 275, 485, 4899, 63, 5182, 63, 3403, 8, 8854, 9, 259, 327, 1329, 402, 7609, 315, 8290, 17399, 199, 63, 1914, 1960, 57, 275, 485, 4899, 63, 5182, 63, 3403, 8, 4893, 9, 259, 327, 259, 298, 259, 298, 257, 298, 257, 298, 2948, 257, 298, 199, 63, 1914, 20, 57, 257, 275, 485, 4899, 63, 5182, 63, 3403, 8, 21, 9, 420, 327, 259, 298, 259, 298, 257, 298, 257, 298, 257, 841, 257, 298, 199, 199, 3, 437, 841, 13, 3403, 8643, 965, 376, 2402, 29487, 5382, 1806, 4052, 781, 5121, 664, 687, 13541, 316, 199, 3, 10451, 841, 2849, 17399, 14, 199, 479, 485, 1914, 20, 57, 508, 841, 627, 28046, 435, 413, 199, 199, 3, 20046, 590, 12, 282, 8290, 13, 3403, 8643, 965, 376, 2402, 29487, 5382, 1806, 4052, 781, 5121, 664, 687, 199, 3, 13541, 316, 10451, 841, 2948, 13, 3403, 19001, 14, 199, 479, 485, 1914, 5303, 57, 508, 841, 627, 485, 1914, 1960, 57, 435, 413, 199, 199, 3, 593, 2566, 40, 12, 282, 2948, 13, 3403, 8643, 965, 1373, 27392, 29487, 5382, 2419, 781, 5121, 664, 687, 199, 3, 13541, 316, 10451, 5661, 841, 13, 3403, 19001, 14, 199, 479, 485, 1914, 1960, 57, 508, 5661, 627, 485, 1914, 20, 57, 446, 413, 199, 199, 318, 485, 2181, 18, 89, 1064, 8, 78, 304, 272, 298, 17460, 1035, 334, 3403, 12, 5794, 12, 5382, 395, 11201, 316, 17163, 13, 19825, 13, 4183, 465, 5382, 413, 2122, 339, 327, 302, 365, 282, 413, 13, 6788, 1478, 12, 6617, 737, 413, 13, 19825, 13, 17, 14, 221, 710, 3851, 402, 29487, 17399, 272, 327, 28908, 8840, 4036, 8290, 17399, 14, 221, 710, 5678, 10054, 365, 370, 2342, 314, 272, 327, 18284, 8290, 13, 3403, 8424, 737, 503, 2544, 302, 12, 2066, 1736, 543, 314, 3268, 272, 327, 687, 626, 8424, 370, 302, 14, 221, 491, 16839, 365, 8298, 15158, 21462, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
axiom-data-science/django-celery
djcelery/schedulers.py
1
9679
from __future__ import absolute_import import logging from multiprocessing.util import Finalize from anyjson import loads, dumps from celery import current_app from celery import schedules from celery.beat import Scheduler, ScheduleEntry from celery.utils.encoding import safe_str, safe_repr from celery.utils.log import get_logger from celery.utils.timeutils import is_naive from django.db import transaction from django.core.exceptions import ObjectDoesNotExist from .db import commit_on_success from .models import (PeriodicTask, PeriodicTasks, CrontabSchedule, IntervalSchedule) from .utils import DATABASE_ERRORS, make_aware from .compat import itervalues # This scheduler must wake up more frequently than the # regular of 5 minutes because it needs to take external # changes to the schedule into account. DEFAULT_MAX_INTERVAL = 5 # seconds ADD_ENTRY_ERROR = """\ Couldn't add entry %r to database schedule: %r. Contents: %r """ logger = get_logger(__name__) debug, info, error = logger.debug, logger.info, logger.error class ModelEntry(ScheduleEntry): model_schedules = ((schedules.crontab, CrontabSchedule, 'crontab'), (schedules.schedule, IntervalSchedule, 'interval')) save_fields = ['last_run_at', 'total_run_count', 'no_changes'] def __init__(self, model): self.app = current_app._get_current_object() self.name = model.name self.task = model.task try: self.schedule = model.schedule except model.DoesNotExist: logger.error('Schedule was removed from database') logger.warning('Disabling %s', self.name) self._disable(model) try: self.args = loads(model.args or '[]') self.kwargs = loads(model.kwargs or '{}') except ValueError: logging.error('Failed to serialize arguments for %s.', self.name, exc_info=1) logging.warning('Disabling %s', self.name) self._disable(model) self.options = {'queue': model.queue, 'exchange': model.exchange, 'routing_key': model.routing_key, 'expires': model.expires} self.total_run_count = model.total_run_count self.model = model if not model.last_run_at: model.last_run_at = self._default_now() orig = self.last_run_at = model.last_run_at if not is_naive(self.last_run_at): self.last_run_at = self.last_run_at.replace(tzinfo=None) assert orig.hour == self.last_run_at.hour # timezone sanity def _disable(self, model): model.no_changes = True model.enabled = False model.save() def is_due(self): if not self.model.enabled: return False, 5.0 # 5 second delay for re-enable. return self.schedule.is_due(self.last_run_at) def _default_now(self): return self.app.now() def __next__(self): self.model.last_run_at = self.app.now() self.model.total_run_count += 1 self.model.no_changes = True return self.__class__(self.model) next = __next__ # for 2to3 def save(self): # Object may not be synchronized, so only # change the fields we care about. obj = type(self.model)._default_manager.get(pk=self.model.pk) for field in self.save_fields: setattr(obj, field, getattr(self.model, field)) obj.last_run_at = make_aware(obj.last_run_at) obj.save() @classmethod def to_model_schedule(cls, schedule): for schedule_type, model_type, model_field in cls.model_schedules: schedule = schedules.maybe_schedule(schedule) if isinstance(schedule, schedule_type): model_schedule = model_type.from_schedule(schedule) model_schedule.save() return model_schedule, model_field raise ValueError( 'Cannot convert schedule type {0!r} to model'.format(schedule)) @classmethod def from_entry(cls, name, skip_fields=('relative', 'options'), **entry): options = entry.get('options') or {} fields = dict(entry) for skip_field in skip_fields: fields.pop(skip_field, None) schedule = fields.pop('schedule') model_schedule, model_field = cls.to_model_schedule(schedule) fields[model_field] = model_schedule fields['args'] = dumps(fields.get('args') or []) fields['kwargs'] = dumps(fields.get('kwargs') or {}) fields['queue'] = options.get('queue') fields['exchange'] = options.get('exchange') fields['routing_key'] = options.get('routing_key') obj, _ = PeriodicTask._default_manager.update_or_create( name=name, defaults=fields, ) return cls(obj) def __repr__(self): return '<ModelEntry: {0} {1}(*{2}, **{3}) {4}>'.format( safe_str(self.name), self.task, safe_repr(self.args), safe_repr(self.kwargs), self.schedule, ) class DatabaseScheduler(Scheduler): Entry = ModelEntry Model = PeriodicTask Changes = PeriodicTasks _schedule = None _last_timestamp = None _initial_read = False def __init__(self, *args, **kwargs): self._dirty = set() self._finalize = Finalize(self, self.sync, exitpriority=5) Scheduler.__init__(self, *args, **kwargs) self.max_interval = ( kwargs.get('max_interval') or self.app.conf.CELERYBEAT_MAX_LOOP_INTERVAL or DEFAULT_MAX_INTERVAL) def setup_schedule(self): self.install_default_entries(self.schedule) self.update_from_dict(self.app.conf.CELERYBEAT_SCHEDULE) def all_as_schedule(self): debug('DatabaseScheduler: Fetching database schedule') s = {} for model in self.Model.objects.enabled(): try: s[model.name] = self.Entry(model) except ValueError: pass return s def schedule_changed(self): try: # If MySQL is running with transaction isolation level # REPEATABLE-READ (default), then we won't see changes done by # other transactions until the current transaction is # committed (Issue #41). try: transaction.commit() except transaction.TransactionManagementError: pass # not in transaction management. last, ts = self._last_timestamp, self.Changes.last_change() except DATABASE_ERRORS as exc: error('Database gave error: %r', exc, exc_info=1) return False try: if ts and ts > (last if last else ts): return True finally: self._last_timestamp = ts return False def reserve(self, entry): new_entry = Scheduler.reserve(self, entry) # Need to store entry by name, because the entry may change # in the mean time. self._dirty.add(new_entry.name) return new_entry def sync(self): info('Writing entries (%s)...', len(self._dirty)) _tried = set() try: with commit_on_success(): while self._dirty: try: name = self._dirty.pop() _tried.add(name) self.schedule[name].save() except (KeyError, ObjectDoesNotExist): pass except DATABASE_ERRORS as exc: # retry later self._dirty |= _tried error('Database error while sync: %r', exc, exc_info=1) def update_from_dict(self, dict_): s = {} for name, entry in dict_.items(): try: s[name] = self.Entry.from_entry(name, **entry) except Exception as exc: error(ADD_ENTRY_ERROR, name, exc, entry) self.schedule.update(s) def install_default_entries(self, data): entries = {} if self.app.conf.CELERY_TASK_RESULT_EXPIRES: entries.setdefault( 'celery.backend_cleanup', { 'task': 'celery.backend_cleanup', 'schedule': schedules.crontab('0', '4', '*'), 'options': {'expires': 12 * 3600}, }, ) self.update_from_dict(entries) @property def schedule(self): update = False if not self._initial_read: debug('DatabaseScheduler: intial read') update = True self._initial_read = True elif self.schedule_changed(): info('DatabaseScheduler: Schedule changed.') update = True if update: self.sync() self._schedule = self.all_as_schedule() if logger.isEnabledFor(logging.DEBUG): debug('Current schedule:\n%s', '\n'.join( repr(entry) for entry in itervalues(self._schedule)), ) return self._schedule @classmethod def create_or_update_task(cls, name, **schedule_dict): if 'schedule' not in schedule_dict: try: schedule_dict['schedule'] = \ PeriodicTask._default_manager.get(name=name).schedule except PeriodicTask.DoesNotExist: pass cls.Entry.from_entry(name, **schedule_dict) @classmethod def delete_task(cls, name): PeriodicTask._default_manager.get(name=name).delete()
bsd-3-clause
[ 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 199, 504, 12866, 14, 1974, 492, 21789, 794, 199, 199, 504, 1263, 1001, 492, 14404, 12, 16864, 199, 504, 22748, 492, 1453, 63, 571, 199, 504, 22748, 492, 8732, 83, 199, 504, 22748, 14, 12522, 492, 32051, 12, 24317, 3900, 199, 504, 22748, 14, 1208, 14, 2991, 492, 5048, 63, 495, 12, 5048, 63, 2722, 199, 504, 22748, 14, 1208, 14, 793, 492, 664, 63, 2921, 199, 504, 22748, 14, 1208, 14, 521, 1208, 492, 365, 63, 21578, 199, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 199, 504, 1275, 697, 492, 5532, 63, 265, 63, 3742, 199, 504, 1275, 992, 492, 334, 2623, 11273, 4476, 12, 3492, 11273, 19295, 12, 2151, 30277, 30578, 15535, 12, 18766, 15535, 9, 199, 504, 1275, 1208, 492, 31705, 63, 21477, 12, 1852, 63, 14600, 199, 504, 1275, 5819, 492, 24451, 199, 199, 3, 961, 11899, 1471, 21560, 1536, 1655, 28914, 590, 2419, 314, 199, 3, 5578, 402, 959, 9395, 2952, 652, 4839, 370, 5452, 5957, 199, 3, 4493, 370, 314, 8732, 1901, 2933, 14, 199, 3472, 63, 4283, 63, 17359, 275, 959, 221, 327, 4696, 199, 199, 9732, 63, 7285, 63, 3170, 275, 9638, 199, 20485, 1133, 1050, 2397, 450, 82, 370, 3050, 8732, 26, 450, 82, 14, 6646, 83, 26, 450, 82, 199, 624, 199, 199, 2921, 275, 664, 63, 2921, 3460, 354, 3368, 199, 1757, 12, 2256, 12, 1125, 275, 2512, 14, 1757, 12, 2512, 14, 815, 12, 2512, 14, 705, 421, 199, 533, 5822, 3900, 8, 15535, 3900, 304, 272, 1402, 63, 7211, 83, 275, 3666, 7211, 83, 14, 1556, 30578, 12, 30277, 30578, 15535, 12, 283, 1556, 30578, 659, 2432, 334, 7211, 83, 14, 7211, 12, 18766, 15535, 12, 283, 4284, 1333, 272, 3354, 63, 955, 275, 788, 2019, 63, 1065, 63, 292, 297, 283, 2923, 63, 1065, 63, 835, 297, 283, 889, 63, 6627, 418, 339, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 571, 275, 1453, 63, 571, 423, 362, 63, 1818, 63, 785, 342, 267, 291, 14, 354, 275, 1402, 14, 354, 267, 291, 14, 1765, 275, 1402, 14, 1765, 267, 862, 26, 288, 291, 14, 7211, 275, 1402, 14, 7211, 267, 871, 1402, 14, 7400, 26, 288, 2512, 14, 705, 360, 15535, 1990, 4829, 687, 3050, 358, 288, 2512, 14, 3764, 360, 2825, 14744, 450, 83, 297, 291, 14, 354, 9, 288, 291, 423, 5993, 8, 1238, 9, 267, 862, 26, 288, 291, 14, 589, 275, 14404, 8, 1238, 14, 589, 503, 6730, 10374, 288, 291, 14, 958, 275, 14404, 8, 1238, 14, 958, 503, 9005, 358, 267, 871, 1722, 26, 288, 2050, 14, 705, 360, 4276, 370, 8437, 2368, 367, 450, 83, 3130, 291, 14, 354, 12, 2079, 3178, 63, 815, 29, 17, 9, 288, 2050, 14, 3764, 360, 2825, 14744, 450, 83, 297, 291, 14, 354, 9, 288, 291, 423, 5993, 8, 1238, 9, 398, 291, 14, 1419, 275, 791, 1825, 356, 1402, 14, 1825, 12, 717, 283, 14197, 356, 1402, 14, 14197, 12, 717, 283, 9492, 63, 498, 356, 1402, 14, 9492, 63, 498, 12, 717, 283, 12342, 356, 1402, 14, 12342, 93, 267, 291, 14, 2923, 63, 1065, 63, 835, 275, 1402, 14, 2923, 63, 1065, 63, 835, 267, 291, 14, 1238, 275, 1402, 398, 340, 440, 1402, 14, 2019, 63, 1065, 63, 292, 26, 288, 1402, 14, 2019, 63, 1065, 63, 292, 275, 291, 423, 885, 63, 2131, 342, 267, 2306, 275, 291, 14, 2019, 63, 1065, 63, 292, 275, 1402, 14, 2019, 63, 1065, 63, 292, 267, 340, 440, 365, 63, 21578, 8, 277, 14, 2019, 63, 1065, 63, 292, 304, 288, 291, 14, 2019, 63, 1065, 63, 292, 275, 291, 14, 2019, 63, 1065, 63, 292, 14, 1814, 8, 9374, 29, 403, 9, 267, 702, 2306, 14, 5180, 508, 291, 14, 2019, 63, 1065, 63, 292, 14, 5180, 221, 327, 7137, 16740, 339, 347, 485, 5993, 8, 277, 12, 1402, 304, 267, 1402, 14, 889, 63, 6627, 275, 715, 267, 1402, 14, 3827, 275, 756, 267, 1402, 14, 2117, 342, 339, 347, 365, 63, 11933, 8, 277, 304, 267, 340, 440, 291, 14, 1238, 14, 3827, 26, 288, 372, 756, 12, 959, 14, 16, 257, 327, 959, 3499, 7339, 367, 295, 13, 4296, 14, 267, 372, 291, 14, 7211, 14, 374, 63, 11933, 8, 277, 14, 2019, 63, 1065, 63, 292, 9, 339, 347, 485, 885, 63, 2131, 8, 277, 304, 267, 372, 291, 14, 571, 14, 2131, 342, 339, 347, 636, 2184, 721, 277, 304, 267, 291, 14, 1238, 14, 2019, 63, 1065, 63, 292, 275, 291, 14, 571, 14, 2131, 342, 267, 291, 14, 1238, 14, 2923, 63, 1065, 63, 835, 847, 413, 267, 291, 14, 1238, 14, 889, 63, 6627, 275, 715, 267, 372, 291, 855, 533, 721, 277, 14, 1238, 9, 272, 2163, 275, 636, 2184, 363, 221, 327, 367, 499, 475, 19, 339, 347, 3354, 8, 277, 304, 267, 327, 6935, 1443, 440, 506, 15354, 1759, 12, 880, 1454, 267, 327, 1570, 314, 1504, 781, 10296, 3595, 14, 267, 1559, 275, 730, 8, 277, 14, 1238, 10445, 885, 63, 2609, 14, 362, 8, 2051, 29, 277, 14, 1238, 14, 2051, 9, 267, 367, 901, 315, 291, 14, 2117, 63, 955, 26, 288, 5371, 8, 1113, 12, 901, 12, 2519, 8, 277, 14, 1238, 12, 901, 430, 267, 1559, 14, 2019, 63, 1065, 63, 292, 275, 1852, 63, 14600, 8, 1113, 14, 2019, 63, 1065, 63, 292, 9, 267, 1559, 14, 2117, 342, 339, 768, 3744, 272, 347, 370, 63, 1238, 63, 7211, 8, 1886, 12, 8732, 304, 267, 367, 8732, 63, 466, 12, 1402, 63, 466, 12, 1402, 63, 698, 315, 843, 14, 1238, 63, 7211, 83, 26, 288, 8732, 275, 8732, 83, 14, 11853, 63, 7211, 8, 7211, 9, 288, 340, 1228, 8, 7211, 12, 8732, 63, 466, 304, 355, 1402, 63, 7211, 275, 1402, 63, 466, 14, 504, 63, 7211, 8, 7211, 9, 355, 1402, 63, 7211, 14, 2117, 342, 355, 372, 1402, 63, 7211, 12, 1402, 63, 698, 267, 746, 1722, 8, 288, 283, 6612, 3957, 8732, 730, 469 ]
[ 636, 2443, 363, 492, 3679, 63, 646, 199, 199, 646, 2050, 199, 199, 504, 12866, 14, 1974, 492, 21789, 794, 199, 199, 504, 1263, 1001, 492, 14404, 12, 16864, 199, 504, 22748, 492, 1453, 63, 571, 199, 504, 22748, 492, 8732, 83, 199, 504, 22748, 14, 12522, 492, 32051, 12, 24317, 3900, 199, 504, 22748, 14, 1208, 14, 2991, 492, 5048, 63, 495, 12, 5048, 63, 2722, 199, 504, 22748, 14, 1208, 14, 793, 492, 664, 63, 2921, 199, 504, 22748, 14, 1208, 14, 521, 1208, 492, 365, 63, 21578, 199, 199, 504, 1639, 14, 697, 492, 6008, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 199, 504, 1275, 697, 492, 5532, 63, 265, 63, 3742, 199, 504, 1275, 992, 492, 334, 2623, 11273, 4476, 12, 3492, 11273, 19295, 12, 2151, 30277, 30578, 15535, 12, 18766, 15535, 9, 199, 504, 1275, 1208, 492, 31705, 63, 21477, 12, 1852, 63, 14600, 199, 504, 1275, 5819, 492, 24451, 199, 199, 3, 961, 11899, 1471, 21560, 1536, 1655, 28914, 590, 2419, 314, 199, 3, 5578, 402, 959, 9395, 2952, 652, 4839, 370, 5452, 5957, 199, 3, 4493, 370, 314, 8732, 1901, 2933, 14, 199, 3472, 63, 4283, 63, 17359, 275, 959, 221, 327, 4696, 199, 199, 9732, 63, 7285, 63, 3170, 275, 9638, 199, 20485, 1133, 1050, 2397, 450, 82, 370, 3050, 8732, 26, 450, 82, 14, 6646, 83, 26, 450, 82, 199, 624, 199, 199, 2921, 275, 664, 63, 2921, 3460, 354, 3368, 199, 1757, 12, 2256, 12, 1125, 275, 2512, 14, 1757, 12, 2512, 14, 815, 12, 2512, 14, 705, 421, 199, 533, 5822, 3900, 8, 15535, 3900, 304, 272, 1402, 63, 7211, 83, 275, 3666, 7211, 83, 14, 1556, 30578, 12, 30277, 30578, 15535, 12, 283, 1556, 30578, 659, 2432, 334, 7211, 83, 14, 7211, 12, 18766, 15535, 12, 283, 4284, 1333, 272, 3354, 63, 955, 275, 788, 2019, 63, 1065, 63, 292, 297, 283, 2923, 63, 1065, 63, 835, 297, 283, 889, 63, 6627, 418, 339, 347, 636, 826, 721, 277, 12, 1402, 304, 267, 291, 14, 571, 275, 1453, 63, 571, 423, 362, 63, 1818, 63, 785, 342, 267, 291, 14, 354, 275, 1402, 14, 354, 267, 291, 14, 1765, 275, 1402, 14, 1765, 267, 862, 26, 288, 291, 14, 7211, 275, 1402, 14, 7211, 267, 871, 1402, 14, 7400, 26, 288, 2512, 14, 705, 360, 15535, 1990, 4829, 687, 3050, 358, 288, 2512, 14, 3764, 360, 2825, 14744, 450, 83, 297, 291, 14, 354, 9, 288, 291, 423, 5993, 8, 1238, 9, 267, 862, 26, 288, 291, 14, 589, 275, 14404, 8, 1238, 14, 589, 503, 6730, 10374, 288, 291, 14, 958, 275, 14404, 8, 1238, 14, 958, 503, 9005, 358, 267, 871, 1722, 26, 288, 2050, 14, 705, 360, 4276, 370, 8437, 2368, 367, 450, 83, 3130, 291, 14, 354, 12, 2079, 3178, 63, 815, 29, 17, 9, 288, 2050, 14, 3764, 360, 2825, 14744, 450, 83, 297, 291, 14, 354, 9, 288, 291, 423, 5993, 8, 1238, 9, 398, 291, 14, 1419, 275, 791, 1825, 356, 1402, 14, 1825, 12, 717, 283, 14197, 356, 1402, 14, 14197, 12, 717, 283, 9492, 63, 498, 356, 1402, 14, 9492, 63, 498, 12, 717, 283, 12342, 356, 1402, 14, 12342, 93, 267, 291, 14, 2923, 63, 1065, 63, 835, 275, 1402, 14, 2923, 63, 1065, 63, 835, 267, 291, 14, 1238, 275, 1402, 398, 340, 440, 1402, 14, 2019, 63, 1065, 63, 292, 26, 288, 1402, 14, 2019, 63, 1065, 63, 292, 275, 291, 423, 885, 63, 2131, 342, 267, 2306, 275, 291, 14, 2019, 63, 1065, 63, 292, 275, 1402, 14, 2019, 63, 1065, 63, 292, 267, 340, 440, 365, 63, 21578, 8, 277, 14, 2019, 63, 1065, 63, 292, 304, 288, 291, 14, 2019, 63, 1065, 63, 292, 275, 291, 14, 2019, 63, 1065, 63, 292, 14, 1814, 8, 9374, 29, 403, 9, 267, 702, 2306, 14, 5180, 508, 291, 14, 2019, 63, 1065, 63, 292, 14, 5180, 221, 327, 7137, 16740, 339, 347, 485, 5993, 8, 277, 12, 1402, 304, 267, 1402, 14, 889, 63, 6627, 275, 715, 267, 1402, 14, 3827, 275, 756, 267, 1402, 14, 2117, 342, 339, 347, 365, 63, 11933, 8, 277, 304, 267, 340, 440, 291, 14, 1238, 14, 3827, 26, 288, 372, 756, 12, 959, 14, 16, 257, 327, 959, 3499, 7339, 367, 295, 13, 4296, 14, 267, 372, 291, 14, 7211, 14, 374, 63, 11933, 8, 277, 14, 2019, 63, 1065, 63, 292, 9, 339, 347, 485, 885, 63, 2131, 8, 277, 304, 267, 372, 291, 14, 571, 14, 2131, 342, 339, 347, 636, 2184, 721, 277, 304, 267, 291, 14, 1238, 14, 2019, 63, 1065, 63, 292, 275, 291, 14, 571, 14, 2131, 342, 267, 291, 14, 1238, 14, 2923, 63, 1065, 63, 835, 847, 413, 267, 291, 14, 1238, 14, 889, 63, 6627, 275, 715, 267, 372, 291, 855, 533, 721, 277, 14, 1238, 9, 272, 2163, 275, 636, 2184, 363, 221, 327, 367, 499, 475, 19, 339, 347, 3354, 8, 277, 304, 267, 327, 6935, 1443, 440, 506, 15354, 1759, 12, 880, 1454, 267, 327, 1570, 314, 1504, 781, 10296, 3595, 14, 267, 1559, 275, 730, 8, 277, 14, 1238, 10445, 885, 63, 2609, 14, 362, 8, 2051, 29, 277, 14, 1238, 14, 2051, 9, 267, 367, 901, 315, 291, 14, 2117, 63, 955, 26, 288, 5371, 8, 1113, 12, 901, 12, 2519, 8, 277, 14, 1238, 12, 901, 430, 267, 1559, 14, 2019, 63, 1065, 63, 292, 275, 1852, 63, 14600, 8, 1113, 14, 2019, 63, 1065, 63, 292, 9, 267, 1559, 14, 2117, 342, 339, 768, 3744, 272, 347, 370, 63, 1238, 63, 7211, 8, 1886, 12, 8732, 304, 267, 367, 8732, 63, 466, 12, 1402, 63, 466, 12, 1402, 63, 698, 315, 843, 14, 1238, 63, 7211, 83, 26, 288, 8732, 275, 8732, 83, 14, 11853, 63, 7211, 8, 7211, 9, 288, 340, 1228, 8, 7211, 12, 8732, 63, 466, 304, 355, 1402, 63, 7211, 275, 1402, 63, 466, 14, 504, 63, 7211, 8, 7211, 9, 355, 1402, 63, 7211, 14, 2117, 342, 355, 372, 1402, 63, 7211, 12, 1402, 63, 698, 267, 746, 1722, 8, 288, 283, 6612, 3957, 8732, 730, 469, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
caplin/qa-browsers
nodejs/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py
1
7632
# 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. """Utility functions shared amongst the Windows generators.""" import copy import os _TARGET_TYPE_EXT = { 'executable': '.exe', 'shared_library': '.dll' } def _GetLargePdbShimCcPath(): """Returns the path of the large_pdb_shim.cc file.""" this_dir = os.path.abspath(os.path.dirname(__file__)) src_dir = os.path.abspath(os.path.join(this_dir, '..', '..')) win_data_dir = os.path.join(src_dir, 'data', 'win') large_pdb_shim_cc = os.path.join(win_data_dir, 'large-pdb-shim.cc') return large_pdb_shim_cc def _DeepCopySomeKeys(in_dict, keys): """Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|. Arguments: in_dict: The dictionary to copy. keys: The keys to be copied. If a key is in this list and doesn't exist in |in_dict| this is not an error. Returns: The partially deep-copied dictionary. """ d = {} for key in keys: if key not in in_dict: continue d[key] = copy.deepcopy(in_dict[key]) return d def _SuffixName(name, suffix): """Add a suffix to the end of a target. Arguments: name: name of the target (foo#target) suffix: the suffix to be added Returns: Target name with suffix added (foo_suffix#target) """ parts = name.rsplit('#', 1) parts[0] = '%s_%s' % (parts[0], suffix) return '#'.join(parts) def _ShardName(name, number): """Add a shard number to the end of a target. Arguments: name: name of the target (foo#target) number: shard number Returns: Target name with shard added (foo_1#target) """ return _SuffixName(name, str(number)) def ShardTargets(target_list, target_dicts): """Shard some targets apart to work around the linkers limits. Arguments: target_list: List of target pairs: 'base/base.gyp:base'. target_dicts: Dict of target properties keyed on target pair. Returns: Tuple of the new sharded versions of the inputs. """ # Gather the targets to shard, and how many pieces. targets_to_shard = {} for t in target_dicts: shards = int(target_dicts[t].get('msvs_shard', 0)) if shards: targets_to_shard[t] = shards # Shard target_list. new_target_list = [] for t in target_list: if t in targets_to_shard: for i in range(targets_to_shard[t]): new_target_list.append(_ShardName(t, i)) else: new_target_list.append(t) # Shard target_dict. new_target_dicts = {} for t in target_dicts: if t in targets_to_shard: for i in range(targets_to_shard[t]): name = _ShardName(t, i) new_target_dicts[name] = copy.copy(target_dicts[t]) new_target_dicts[name]['target_name'] = _ShardName( new_target_dicts[name]['target_name'], i) sources = new_target_dicts[name].get('sources', []) new_sources = [] for pos in range(i, len(sources), targets_to_shard[t]): new_sources.append(sources[pos]) new_target_dicts[name]['sources'] = new_sources else: new_target_dicts[t] = target_dicts[t] # Shard dependencies. for t in new_target_dicts: dependencies = copy.copy(new_target_dicts[t].get('dependencies', [])) new_dependencies = [] for d in dependencies: if d in targets_to_shard: for i in range(targets_to_shard[d]): new_dependencies.append(_ShardName(d, i)) else: new_dependencies.append(d) new_target_dicts[t]['dependencies'] = new_dependencies return (new_target_list, new_target_dicts) def InsertLargePdbShims(target_list, target_dicts, vars): """Insert a shim target that forces the linker to use 4KB pagesize PDBs. This is a workaround for targets with PDBs greater than 1GB in size, the limit for the 1KB pagesize PDBs created by the linker by default. Arguments: target_list: List of target pairs: 'base/base.gyp:base'. target_dicts: Dict of target properties keyed on target pair. vars: A dictionary of common GYP variables with generator-specific values. Returns: Tuple of the shimmed version of the inputs. """ # Determine which targets need shimming. targets_to_shim = [] for t in target_dicts: target_dict = target_dicts[t] # We only want to shim targets that have msvs_large_pdb enabled. if not int(target_dict.get('msvs_large_pdb', 0)): continue # This is intended for executable, shared_library and loadable_module # targets where every configuration is set up to produce a PDB output. # If any of these conditions is not true then the shim logic will fail # below. targets_to_shim.append(t) large_pdb_shim_cc = _GetLargePdbShimCcPath() for t in targets_to_shim: target_dict = target_dicts[t] target_name = target_dict.get('target_name') base_dict = _DeepCopySomeKeys(target_dict, ['configurations', 'default_configuration', 'toolset']) # This is the dict for copying the source file (part of the GYP tree) # to the intermediate directory of the project. This is necessary because # we can't always build a relative path to the shim source file (on Windows # GYP and the project may be on different drives), and Ninja hates absolute # paths (it ends up generating the .obj and .obj.d alongside the source # file, polluting GYPs tree). copy_suffix = '_large_pdb_copy' copy_target_name = target_name + '_' + copy_suffix full_copy_target_name = _SuffixName(t, copy_suffix) shim_cc_basename = os.path.basename(large_pdb_shim_cc) shim_cc_dir = vars['SHARED_INTERMEDIATE_DIR'] + '/' + copy_target_name shim_cc_path = shim_cc_dir + '/' + shim_cc_basename copy_dict = copy.deepcopy(base_dict) copy_dict['target_name'] = copy_target_name copy_dict['type'] = 'none' copy_dict['sources'] = [ large_pdb_shim_cc ] copy_dict['copies'] = [{ 'destination': shim_cc_dir, 'files': [ large_pdb_shim_cc ] }] # This is the dict for the PDB generating shim target. It depends on the # copy target. shim_suffix = '_large_pdb_shim' shim_target_name = target_name + '_' + shim_suffix full_shim_target_name = _SuffixName(t, shim_suffix) shim_dict = copy.deepcopy(base_dict) shim_dict['target_name'] = shim_target_name shim_dict['type'] = 'static_library' shim_dict['sources'] = [ shim_cc_path ] shim_dict['dependencies'] = [ full_copy_target_name ] # Set up the shim to output its PDB to the same location as the final linker # target. for config in shim_dict.get('configurations').itervalues(): msvs = config.setdefault('msvs_settings') linker = msvs.pop('VCLinkerTool') # We want to clear this dict. pdb_path = linker.get('ProgramDatabaseFile') compiler = msvs.setdefault('VCCLCompilerTool', {}) compiler.setdefault('DebugInformationFormat', '3') compiler.setdefault('ProgramDataBaseFileName', pdb_path) # Add the new targets. target_list.append(full_copy_target_name) target_list.append(full_shim_target_name) target_dicts[full_copy_target_name] = copy_dict target_dicts[full_shim_target_name] = shim_dict # Update the original target to depend on the shim target. target_dict.setdefault('dependencies', []).append(full_shim_target_name) return (target_list, target_dicts)
unlicense
[ 3, 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 202, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 202, 199, 3, 1911, 315, 314, 5113, 570, 14, 2999, 199, 624, 17505, 3423, 5709, 16885, 270, 314, 5417, 16952, 1041, 2999, 199, 646, 1331, 202, 199, 646, 747, 8065, 199, 63, 9268, 63, 2711, 63, 2472, 275, 469, 10292, 283, 5904, 356, 1987, 5803, 297, 10292, 283, 5555, 63, 4342, 356, 1987, 9259, 7, 202, 199, 93, 8065, 199, 318, 485, 1002, 17149, 21427, 2662, 1017, 21426, 2042, 837, 10292, 408, 3407, 314, 931, 402, 314, 7031, 63, 10511, 63, 28238, 14, 2055, 570, 1041, 10292, 642, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 10292, 2928, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 3749, 63, 694, 12, 19155, 11541, 1333, 10292, 4747, 63, 576, 63, 694, 275, 747, 14, 515, 14, 904, 8, 2164, 63, 694, 12, 283, 576, 297, 283, 2676, 358, 10292, 7031, 63, 10511, 63, 28238, 63, 2055, 275, 747, 14, 515, 14, 904, 8, 2676, 63, 576, 63, 694, 12, 283, 9629, 13, 10511, 13, 28238, 14, 2055, 358, 10292, 372, 7031, 63, 10511, 63, 28238, 63, 2055, 8065, 199, 318, 485, 27753, 5116, 7700, 6340, 8, 262, 63, 807, 12, 2883, 304, 10292, 408, 2623, 3351, 282, 7417, 13217, 13, 1574, 641, 1204, 262, 63, 807, 18712, 1454, 16743, 314, 2883, 315, 1204, 1612, 18257, 25052, 7628, 26, 1128, 315, 63, 807, 26, 710, 2600, 370, 1331, 14, 1128, 2883, 26, 710, 2883, 370, 506, 8876, 14, 982, 282, 790, 365, 315, 642, 769, 436, 3181, 1133, 2187, 315, 1039, 1204, 262, 63, 807, 92, 642, 365, 440, 376, 1125, 14, 10292, 1803, 26, 1128, 710, 25172, 13217, 13, 23581, 2600, 14, 10292, 408, 10292, 366, 275, 1052, 10292, 367, 790, 315, 2883, 26, 1128, 340, 790, 440, 315, 315, 63, 807, 26, 8608, 1980, 1128, 366, 59, 498, 61, 275, 1331, 14, 8293, 8, 262, 63, 807, 59, 498, 566, 10292, 372, 366, 8065, 199, 318, 485, 20126, 985, 8, 354, 12, 4739, 304, 10292, 408, 1123, 282, 4739, 370, 314, 1284, 402, 282, 1347, 14, 25052, 7628, 26, 1128, 536, 26, 536, 402, 314, 1347, 334, 1421, 3, 1375, 9, 1128, 4739, 26, 314, 4739, 370, 506, 3483, 10292, 1803, 26, 1128, 10256, 536, 543, 4739, 3483, 334, 1421, 63, 4511, 3, 1375, 9, 10292, 408, 10292, 4184, 275, 536, 14, 13490, 7863, 297, 413, 9, 10292, 4184, 59, 16, 61, 275, 1543, 83, 4970, 83, 7, 450, 334, 4181, 59, 16, 467, 4739, 9, 10292, 372, 3943, 1370, 904, 8, 4181, 9, 8065, 199, 318, 485, 20019, 985, 8, 354, 12, 1329, 304, 10292, 408, 1123, 282, 11814, 1329, 370, 314, 1284, 402, 282, 1347, 14, 25052, 7628, 26, 1128, 536, 26, 536, 402, 314, 1347, 334, 1421, 3, 1375, 9, 1128, 1329, 26, 11814, 1329, 10292, 1803, 26, 1128, 10256, 536, 543, 11814, 3483, 334, 1421, 63, 17, 3, 1375, 9, 10292, 408, 10292, 372, 485, 20126, 985, 8, 354, 12, 620, 8, 1955, 430, 8065, 199, 318, 5244, 1005, 14126, 8, 1375, 63, 513, 12, 1347, 63, 7892, 304, 10292, 408, 20019, 2005, 4545, 29430, 370, 1736, 6818, 314, 2142, 1192, 10976, 14, 25052, 7628, 26, 1128, 1347, 63, 513, 26, 3820, 402, 1347, 6342, 26, 283, 1095, 15, 1095, 14, 6179, 26, 1095, 1370, 1128, 1347, 63, 7892, 26, 7448, 402, 1347, 4382, 19272, 641, 1347, 4092, 14, 10292, 1803, 26, 1128, 11634, 402, 314, 892, 1033, 12910, 5459, 402, 314, 4153, 14, 10292, 408, 10292, 327, 19634, 314, 4545, 370, 11814, 12, 436, 4212, 5002, 10338, 14, 10292, 4545, 63, 475, 63, 10810, 275, 1052, 10292, 367, 307, 315, 1347, 63, 7892, 26, 1128, 24130, 275, 1109, 8, 1375, 63, 7892, 59, 84, 1055, 362, 360, 8338, 63, 10810, 297, 378, 430, 1128, 340, 24130, 26, 8608, 4545, 63, 475, 63, 10810, 59, 84, 61, 275, 24130, 10292, 327, 5244, 1005, 1347, 63, 513, 14, 10292, 892, 63, 1375, 63, 513, 275, 942, 10292, 367, 307, 315, 1347, 63, 513, 26, 1128, 340, 307, 315, 4545, 63, 475, 63, 10810, 26, 8608, 367, 284, 315, 1425, 8, 4684, 63, 475, 63, 10810, 59, 84, 4682, 1039, 892, 63, 1375, 63, 513, 14, 740, 1547, 20019, 985, 8, 84, 12, 284, 430, 1128, 587, 26, 8608, 892, 63, 1375, 63, 513, 14, 740, 8, 84, 9, 10292, 327, 5244, 1005, 1347, 63, 807, 14, 10292, 892, 63, 1375, 63, 7892, 275, 1052, 10292, 367, 307, 315, 1347, 63, 7892, 26, 1128, 340, 307, 315, 4545, 63, 475, 63, 10810, 26, 8608, 367, 284, 315, 1425, 8, 4684, 63, 475, 63, 10810, 59, 84, 4682, 1039, 536, 275, 485, 20019, 985, 8, 84, 12, 284, 9, 1039, 892, 63, 1375, 63, 7892, 59, 354, 61, 275, 1331, 14, 1574, 8, 1375, 63, 7892, 59, 84, 566, 1039, 892, 63, 1375, 63, 7892, 59, 354, 2733, 1375, 63, 354, 418, 275, 485, 20019, 985, 8, 17554, 892, 63, 1375, 63, 7892, 59, 354, 2733, 1375, 63, 354, 995, 284, 9, 1039, 5274, 275, 892, 63, 1375, 63, 7892, 59, 354, 1055, 362, 360, 4553, 297, 3073, 1039, 892, 63, 4553, 275, 942, 1039, 367, 2086, 315, 1425, 8, 73, 12, 822, 8, 4553, 395, 4545, 63, 475, 63, 10810, 59, 84, 4682, 16765, 892, 63, 4553, 14, 740, 8, 4553, 59, 1712, 566, 1039, 892, 63, 1375, 63, 7892, 59, 354, 2733, 4553, 418, 275, 892, 63, 4553, 1128, 587, 26, 8608, 892, 63, 1375, 63, 7892, 59, 84, 61, 275, 1347, 63, 7892, 59, 84, 61, 10292, 327, 5244, 1005, 5124, 14, 10292, 367, 307, 315, 892, 63, 1375, 63, 7892, 26, 1128, 5124, 275, 1331, 14, 1574, 8, 1222, 63, 1375, 63, 7892, 59, 84, 1055, 362, 360, 5714, 297, 15927, 1128, 892, 63, 5714, 275, 942, 1128, 367, 366, 315, 5124, 26, 8608, 340, 366, 315, 4545, 63, 475, 63, 10810, 26, 1039, 367, 284, 315, 1425, 8, 4684, 63, 475 ]
[ 1898, 334, 67, 9, 6171, 4475, 3277, 14, 2900, 4481, 4644, 14, 202, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 202, 199, 3, 1911, 315, 314, 5113, 570, 14, 2999, 199, 624, 17505, 3423, 5709, 16885, 270, 314, 5417, 16952, 1041, 2999, 199, 646, 1331, 202, 199, 646, 747, 8065, 199, 63, 9268, 63, 2711, 63, 2472, 275, 469, 10292, 283, 5904, 356, 1987, 5803, 297, 10292, 283, 5555, 63, 4342, 356, 1987, 9259, 7, 202, 199, 93, 8065, 199, 318, 485, 1002, 17149, 21427, 2662, 1017, 21426, 2042, 837, 10292, 408, 3407, 314, 931, 402, 314, 7031, 63, 10511, 63, 28238, 14, 2055, 570, 1041, 10292, 642, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 3475, 3460, 493, 8964, 10292, 2928, 63, 694, 275, 747, 14, 515, 14, 4832, 8, 736, 14, 515, 14, 904, 8, 3749, 63, 694, 12, 19155, 11541, 1333, 10292, 4747, 63, 576, 63, 694, 275, 747, 14, 515, 14, 904, 8, 2164, 63, 694, 12, 283, 576, 297, 283, 2676, 358, 10292, 7031, 63, 10511, 63, 28238, 63, 2055, 275, 747, 14, 515, 14, 904, 8, 2676, 63, 576, 63, 694, 12, 283, 9629, 13, 10511, 13, 28238, 14, 2055, 358, 10292, 372, 7031, 63, 10511, 63, 28238, 63, 2055, 8065, 199, 318, 485, 27753, 5116, 7700, 6340, 8, 262, 63, 807, 12, 2883, 304, 10292, 408, 2623, 3351, 282, 7417, 13217, 13, 1574, 641, 1204, 262, 63, 807, 18712, 1454, 16743, 314, 2883, 315, 1204, 1612, 18257, 25052, 7628, 26, 1128, 315, 63, 807, 26, 710, 2600, 370, 1331, 14, 1128, 2883, 26, 710, 2883, 370, 506, 8876, 14, 982, 282, 790, 365, 315, 642, 769, 436, 3181, 1133, 2187, 315, 1039, 1204, 262, 63, 807, 92, 642, 365, 440, 376, 1125, 14, 10292, 1803, 26, 1128, 710, 25172, 13217, 13, 23581, 2600, 14, 10292, 408, 10292, 366, 275, 1052, 10292, 367, 790, 315, 2883, 26, 1128, 340, 790, 440, 315, 315, 63, 807, 26, 8608, 1980, 1128, 366, 59, 498, 61, 275, 1331, 14, 8293, 8, 262, 63, 807, 59, 498, 566, 10292, 372, 366, 8065, 199, 318, 485, 20126, 985, 8, 354, 12, 4739, 304, 10292, 408, 1123, 282, 4739, 370, 314, 1284, 402, 282, 1347, 14, 25052, 7628, 26, 1128, 536, 26, 536, 402, 314, 1347, 334, 1421, 3, 1375, 9, 1128, 4739, 26, 314, 4739, 370, 506, 3483, 10292, 1803, 26, 1128, 10256, 536, 543, 4739, 3483, 334, 1421, 63, 4511, 3, 1375, 9, 10292, 408, 10292, 4184, 275, 536, 14, 13490, 7863, 297, 413, 9, 10292, 4184, 59, 16, 61, 275, 1543, 83, 4970, 83, 7, 450, 334, 4181, 59, 16, 467, 4739, 9, 10292, 372, 3943, 1370, 904, 8, 4181, 9, 8065, 199, 318, 485, 20019, 985, 8, 354, 12, 1329, 304, 10292, 408, 1123, 282, 11814, 1329, 370, 314, 1284, 402, 282, 1347, 14, 25052, 7628, 26, 1128, 536, 26, 536, 402, 314, 1347, 334, 1421, 3, 1375, 9, 1128, 1329, 26, 11814, 1329, 10292, 1803, 26, 1128, 10256, 536, 543, 11814, 3483, 334, 1421, 63, 17, 3, 1375, 9, 10292, 408, 10292, 372, 485, 20126, 985, 8, 354, 12, 620, 8, 1955, 430, 8065, 199, 318, 5244, 1005, 14126, 8, 1375, 63, 513, 12, 1347, 63, 7892, 304, 10292, 408, 20019, 2005, 4545, 29430, 370, 1736, 6818, 314, 2142, 1192, 10976, 14, 25052, 7628, 26, 1128, 1347, 63, 513, 26, 3820, 402, 1347, 6342, 26, 283, 1095, 15, 1095, 14, 6179, 26, 1095, 1370, 1128, 1347, 63, 7892, 26, 7448, 402, 1347, 4382, 19272, 641, 1347, 4092, 14, 10292, 1803, 26, 1128, 11634, 402, 314, 892, 1033, 12910, 5459, 402, 314, 4153, 14, 10292, 408, 10292, 327, 19634, 314, 4545, 370, 11814, 12, 436, 4212, 5002, 10338, 14, 10292, 4545, 63, 475, 63, 10810, 275, 1052, 10292, 367, 307, 315, 1347, 63, 7892, 26, 1128, 24130, 275, 1109, 8, 1375, 63, 7892, 59, 84, 1055, 362, 360, 8338, 63, 10810, 297, 378, 430, 1128, 340, 24130, 26, 8608, 4545, 63, 475, 63, 10810, 59, 84, 61, 275, 24130, 10292, 327, 5244, 1005, 1347, 63, 513, 14, 10292, 892, 63, 1375, 63, 513, 275, 942, 10292, 367, 307, 315, 1347, 63, 513, 26, 1128, 340, 307, 315, 4545, 63, 475, 63, 10810, 26, 8608, 367, 284, 315, 1425, 8, 4684, 63, 475, 63, 10810, 59, 84, 4682, 1039, 892, 63, 1375, 63, 513, 14, 740, 1547, 20019, 985, 8, 84, 12, 284, 430, 1128, 587, 26, 8608, 892, 63, 1375, 63, 513, 14, 740, 8, 84, 9, 10292, 327, 5244, 1005, 1347, 63, 807, 14, 10292, 892, 63, 1375, 63, 7892, 275, 1052, 10292, 367, 307, 315, 1347, 63, 7892, 26, 1128, 340, 307, 315, 4545, 63, 475, 63, 10810, 26, 8608, 367, 284, 315, 1425, 8, 4684, 63, 475, 63, 10810, 59, 84, 4682, 1039, 536, 275, 485, 20019, 985, 8, 84, 12, 284, 9, 1039, 892, 63, 1375, 63, 7892, 59, 354, 61, 275, 1331, 14, 1574, 8, 1375, 63, 7892, 59, 84, 566, 1039, 892, 63, 1375, 63, 7892, 59, 354, 2733, 1375, 63, 354, 418, 275, 485, 20019, 985, 8, 17554, 892, 63, 1375, 63, 7892, 59, 354, 2733, 1375, 63, 354, 995, 284, 9, 1039, 5274, 275, 892, 63, 1375, 63, 7892, 59, 354, 1055, 362, 360, 4553, 297, 3073, 1039, 892, 63, 4553, 275, 942, 1039, 367, 2086, 315, 1425, 8, 73, 12, 822, 8, 4553, 395, 4545, 63, 475, 63, 10810, 59, 84, 4682, 16765, 892, 63, 4553, 14, 740, 8, 4553, 59, 1712, 566, 1039, 892, 63, 1375, 63, 7892, 59, 354, 2733, 4553, 418, 275, 892, 63, 4553, 1128, 587, 26, 8608, 892, 63, 1375, 63, 7892, 59, 84, 61, 275, 1347, 63, 7892, 59, 84, 61, 10292, 327, 5244, 1005, 5124, 14, 10292, 367, 307, 315, 892, 63, 1375, 63, 7892, 26, 1128, 5124, 275, 1331, 14, 1574, 8, 1222, 63, 1375, 63, 7892, 59, 84, 1055, 362, 360, 5714, 297, 15927, 1128, 892, 63, 5714, 275, 942, 1128, 367, 366, 315, 5124, 26, 8608, 340, 366, 315, 4545, 63, 475, 63, 10810, 26, 1039, 367, 284, 315, 1425, 8, 4684, 63, 475, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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test_jabberxmppstringprep.py
13
5549
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. from twisted.trial import unittest from twisted.words.protocols.jabber.xmpp_stringprep import ( nodeprep, resourceprep, nameprep) class DeprecationTests(unittest.TestCase): """ Deprecations in L{twisted.words.protocols.jabber.xmpp_stringprep}. """ def test_crippled(self): """ L{xmpp_stringprep.crippled} is deprecated and always returns C{False}. """ from twisted.words.protocols.jabber.xmpp_stringprep import crippled warnings = self.flushWarnings( offendingFunctions=[self.test_crippled]) self.assertEqual(DeprecationWarning, warnings[0]['category']) self.assertEqual( "twisted.words.protocols.jabber.xmpp_stringprep.crippled was " "deprecated in Twisted 13.1.0: crippled is always False", warnings[0]['message']) self.assertEqual(1, len(warnings)) self.assertEqual(crippled, False) class XMPPStringPrepTests(unittest.TestCase): """ The nodeprep stringprep profile is similar to the resourceprep profile, but does an extra mapping of characters (table B.2) and disallows more characters (table C.1.1 and eight extra punctuation characters). Due to this similarity, the resourceprep tests are more extensive, and the nodeprep tests only address the mappings additional restrictions. The nameprep profile is nearly identical to the nameprep implementation in L{encodings.idna}, but that implementation assumes the C{UseSTD4ASCIIRules} flag to be false. This implementation assumes it to be true, and restricts the allowed set of characters. The tests here only check for the differences. """ def testResourcePrep(self): self.assertEqual(resourceprep.prepare(u'resource'), u'resource') self.assertNotEqual(resourceprep.prepare(u'Resource'), u'resource') self.assertEqual(resourceprep.prepare(u' '), u' ') self.assertEqual(resourceprep.prepare(u'Henry \u2163'), u'Henry IV') self.assertEqual(resourceprep.prepare(u'foo\xad\u034f\u1806\u180b' u'bar\u200b\u2060' u'baz\ufe00\ufe08\ufe0f\ufeff'), u'foobarbaz') self.assertEqual(resourceprep.prepare(u'\u00a0'), u' ') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u1680') self.assertEqual(resourceprep.prepare(u'\u2000'), u' ') self.assertEqual(resourceprep.prepare(u'\u200b'), u'') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u0010\u007f') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u0085') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u180e') self.assertEqual(resourceprep.prepare(u'\ufeff'), u'') self.assertRaises(UnicodeError, resourceprep.prepare, u'\uf123') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000f1234') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0010f234') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0008fffe') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U0010ffff') self.assertRaises(UnicodeError, resourceprep.prepare, u'\udf42') self.assertRaises(UnicodeError, resourceprep.prepare, u'\ufffd') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u2ff5') self.assertEqual(resourceprep.prepare(u'\u0341'), u'\u0301') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u200e') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u202a') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0001') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0042') self.assertRaises(UnicodeError, resourceprep.prepare, u'foo\u05bebar') self.assertRaises(UnicodeError, resourceprep.prepare, u'foo\ufd50bar') #self.assertEqual(resourceprep.prepare(u'foo\ufb38bar'), # u'foo\u064ebar') self.assertRaises(UnicodeError, resourceprep.prepare, u'\u06271') self.assertEqual(resourceprep.prepare(u'\u06271\u0628'), u'\u06271\u0628') self.assertRaises(UnicodeError, resourceprep.prepare, u'\U000e0002') def testNodePrep(self): self.assertEqual(nodeprep.prepare(u'user'), u'user') self.assertEqual(nodeprep.prepare(u'User'), u'user') self.assertRaises(UnicodeError, nodeprep.prepare, u'us&er') def test_nodeprepUnassignedInUnicode32(self): """ Make sure unassigned code points from Unicode 3.2 are rejected. """ self.assertRaises(UnicodeError, nodeprep.prepare, u'\u1d39') def testNamePrep(self): self.assertEqual(nameprep.prepare(u'example.com'), u'example.com') self.assertEqual(nameprep.prepare(u'Example.com'), u'example.com') self.assertRaises(UnicodeError, nameprep.prepare, u'ex@mple.com') self.assertRaises(UnicodeError, nameprep.prepare, u'-example.com') self.assertRaises(UnicodeError, nameprep.prepare, u'example-.com') self.assertEqual(nameprep.prepare(u'stra\u00dfe.example.com'), u'strasse.example.com') def test_nameprepTrailingDot(self): """ A trailing dot in domain names is preserved. """ self.assertEqual(nameprep.prepare(u'example.com.'), u'example.com.')
mit
[ 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 199, 504, 7390, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 492, 334, 272, 1031, 10837, 12, 2073, 10837, 12, 536, 10837, 9, 4388, 199, 533, 1487, 6444, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 1487, 6444, 83, 315, 491, 91, 12145, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 5565, 272, 408, 272, 347, 511, 63, 1408, 802, 1146, 8, 277, 304, 267, 408, 267, 491, 91, 26608, 63, 875, 10837, 14, 1408, 802, 1146, 93, 365, 5906, 436, 3544, 2529, 445, 91, 797, 5565, 267, 408, 267, 687, 7390, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 492, 27825, 802, 1146, 267, 3598, 275, 291, 14, 4939, 15921, 8, 288, 2331, 3219, 13967, 1524, 277, 14, 396, 63, 1408, 802, 1146, 566, 267, 291, 14, 629, 8, 15561, 12, 3598, 59, 16, 2733, 3710, 1105, 267, 291, 14, 629, 8, 288, 298, 12145, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 14, 1408, 802, 1146, 1990, 298, 288, 298, 6667, 315, 17078, 4944, 14, 17, 14, 16, 26, 27825, 802, 1146, 365, 3544, 756, 401, 288, 3598, 59, 16, 2733, 1188, 1105, 267, 291, 14, 629, 8, 17, 12, 822, 8, 5451, 430, 267, 291, 14, 629, 8, 1408, 802, 1146, 12, 756, 9, 4388, 199, 533, 1323, 1658, 48, 1558, 24001, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 710, 1031, 10837, 1059, 10837, 4690, 365, 8545, 370, 314, 2073, 10837, 4690, 12, 272, 1325, 1630, 376, 2402, 4412, 402, 4110, 334, 1224, 699, 14, 18, 9, 436, 2153, 24077, 272, 1655, 4110, 334, 1224, 445, 14, 17, 14, 17, 436, 325, 1070, 2402, 22929, 4110, 680, 272, 25855, 370, 642, 22838, 12, 314, 2073, 10837, 2295, 787, 1655, 2178, 3398, 12, 436, 272, 314, 1031, 10837, 2295, 1454, 2287, 314, 13546, 4722, 24488, 14, 339, 710, 536, 10837, 4690, 365, 17429, 590, 13130, 370, 314, 536, 10837, 4514, 315, 272, 491, 91, 21138, 14, 344, 3540, 1386, 1325, 626, 4514, 15194, 314, 445, 91, 6119, 18472, 20, 1179, 3553, 3927, 443, 83, 93, 272, 3305, 370, 506, 3055, 14, 961, 4514, 15194, 652, 370, 506, 2549, 12, 436, 7213, 3021, 272, 314, 4370, 663, 402, 4110, 14, 221, 710, 2295, 2348, 1454, 1104, 367, 314, 272, 15109, 14, 272, 408, 339, 347, 511, 4031, 24001, 8, 277, 304, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 3984, 1365, 659, 399, 3984, 1365, 358, 267, 291, 14, 7418, 8, 1927, 10837, 14, 6726, 8, 85, 7, 4031, 659, 399, 3984, 1365, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 17748, 399, 7, 5320, 398, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 40, 287, 651, 971, 85, 9669, 19, 659, 399, 7, 40, 287, 651, 27892, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 1421, 60, 10135, 60, 85, 21756, 70, 60, 85, 1085, 1690, 60, 85, 7663, 66, 7, 6901, 399, 7, 1700, 60, 85, 1840, 66, 60, 85, 1165, 2259, 7, 6901, 399, 7, 6185, 60, 7224, 383, 60, 7224, 2036, 60, 7224, 16, 70, 60, 7224, 556, 659, 2079, 399, 7, 9664, 6185, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 383, 65, 16, 659, 399, 7, 5320, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 975, 1257, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 8269, 659, 399, 7, 5320, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 1840, 66, 659, 399, 17483, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 17657, 60, 85, 8255, 70, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 383, 2426, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 7663, 69, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 7224, 556, 659, 399, 17483, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 1286, 4288, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 70, 4321, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 17657, 70, 5533, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 19141, 556, 771, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 17657, 4717, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 10031, 2260, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 3043, 2592, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 18, 556, 21, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 16, 15590, 659, 399, 1154, 85, 1644, 614, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 1840, 69, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 4999, 65, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 69, 4183, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 69, 32728, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 7, 1421, 60, 85, 1717, 1235, 1700, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 7, 1421, 60, 11425, 1400, 1700, 358, 267, 327, 277, 14, 629, 8, 1927, 10837, 14, 6726 ]
[ 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 504, 7390, 14, 14443, 492, 2882, 199, 199, 504, 7390, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 492, 334, 272, 1031, 10837, 12, 2073, 10837, 12, 536, 10837, 9, 4388, 199, 533, 1487, 6444, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 1487, 6444, 83, 315, 491, 91, 12145, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 5565, 272, 408, 272, 347, 511, 63, 1408, 802, 1146, 8, 277, 304, 267, 408, 267, 491, 91, 26608, 63, 875, 10837, 14, 1408, 802, 1146, 93, 365, 5906, 436, 3544, 2529, 445, 91, 797, 5565, 267, 408, 267, 687, 7390, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 492, 27825, 802, 1146, 267, 3598, 275, 291, 14, 4939, 15921, 8, 288, 2331, 3219, 13967, 1524, 277, 14, 396, 63, 1408, 802, 1146, 566, 267, 291, 14, 629, 8, 15561, 12, 3598, 59, 16, 2733, 3710, 1105, 267, 291, 14, 629, 8, 288, 298, 12145, 14, 3148, 14, 16541, 14, 25075, 14, 26608, 63, 875, 10837, 14, 1408, 802, 1146, 1990, 298, 288, 298, 6667, 315, 17078, 4944, 14, 17, 14, 16, 26, 27825, 802, 1146, 365, 3544, 756, 401, 288, 3598, 59, 16, 2733, 1188, 1105, 267, 291, 14, 629, 8, 17, 12, 822, 8, 5451, 430, 267, 291, 14, 629, 8, 1408, 802, 1146, 12, 756, 9, 4388, 199, 533, 1323, 1658, 48, 1558, 24001, 2925, 8, 2796, 14, 1746, 304, 272, 408, 272, 710, 1031, 10837, 1059, 10837, 4690, 365, 8545, 370, 314, 2073, 10837, 4690, 12, 272, 1325, 1630, 376, 2402, 4412, 402, 4110, 334, 1224, 699, 14, 18, 9, 436, 2153, 24077, 272, 1655, 4110, 334, 1224, 445, 14, 17, 14, 17, 436, 325, 1070, 2402, 22929, 4110, 680, 272, 25855, 370, 642, 22838, 12, 314, 2073, 10837, 2295, 787, 1655, 2178, 3398, 12, 436, 272, 314, 1031, 10837, 2295, 1454, 2287, 314, 13546, 4722, 24488, 14, 339, 710, 536, 10837, 4690, 365, 17429, 590, 13130, 370, 314, 536, 10837, 4514, 315, 272, 491, 91, 21138, 14, 344, 3540, 1386, 1325, 626, 4514, 15194, 314, 445, 91, 6119, 18472, 20, 1179, 3553, 3927, 443, 83, 93, 272, 3305, 370, 506, 3055, 14, 961, 4514, 15194, 652, 370, 506, 2549, 12, 436, 7213, 3021, 272, 314, 4370, 663, 402, 4110, 14, 221, 710, 2295, 2348, 1454, 1104, 367, 314, 272, 15109, 14, 272, 408, 339, 347, 511, 4031, 24001, 8, 277, 304, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 3984, 1365, 659, 399, 3984, 1365, 358, 267, 291, 14, 7418, 8, 1927, 10837, 14, 6726, 8, 85, 7, 4031, 659, 399, 3984, 1365, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 17748, 399, 7, 5320, 398, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 40, 287, 651, 971, 85, 9669, 19, 659, 399, 7, 40, 287, 651, 27892, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 7, 1421, 60, 10135, 60, 85, 21756, 70, 60, 85, 1085, 1690, 60, 85, 7663, 66, 7, 6901, 399, 7, 1700, 60, 85, 1840, 66, 60, 85, 1165, 2259, 7, 6901, 399, 7, 6185, 60, 7224, 383, 60, 7224, 2036, 60, 7224, 16, 70, 60, 7224, 556, 659, 2079, 399, 7, 9664, 6185, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 383, 65, 16, 659, 399, 7, 5320, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 975, 1257, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 8269, 659, 399, 7, 5320, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 1840, 66, 659, 399, 17483, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 17657, 60, 85, 8255, 70, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 383, 2426, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 7663, 69, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 7224, 556, 659, 399, 17483, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 1286, 4288, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 70, 4321, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 17657, 70, 5533, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 19141, 556, 771, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 17657, 4717, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 10031, 2260, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 3043, 2592, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 18, 556, 21, 358, 267, 291, 14, 629, 8, 1927, 10837, 14, 6726, 8, 85, 1154, 85, 16, 15590, 659, 399, 1154, 85, 1644, 614, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 1840, 69, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 85, 4999, 65, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 69, 4183, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 1154, 53, 1493, 69, 32728, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 7, 1421, 60, 85, 1717, 1235, 1700, 358, 267, 291, 14, 1855, 8, 7087, 547, 12, 2073, 10837, 14, 6726, 12, 399, 7, 1421, 60, 11425, 1400, 1700, 358, 267, 327, 277, 14, 629, 8, 1927, 10837, 14, 6726, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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instance import shared_steem_instance from .amount import Amount from .converter import Converter from .exceptions import AccountDoesNotExistsException from .utils import parse_time class Account(dict): """ This class allows to easily access Account data :param str account_name: Name of the account :param Steem steem_instance: Steem() instance to use when accesing a RPC :param bool lazy: Use lazy loading """ def __init__( self, account_name, steem_instance=None, lazy=False, ): self.steem = steem_instance or shared_steem_instance() self.cached = False self.name = account_name # caches self._converter = None if not lazy: self.refresh() def refresh(self): account = self.steem.rpc.get_account(self.name) if not account: raise AccountDoesNotExistsException super(Account, self).__init__(account) self.cached = True def __getitem__(self, key): if not self.cached: self.refresh() return super(Account, self).__getitem__(key) def items(self): if not self.cached: self.refresh() return super(Account, self).items() @property def converter(self): if not self._converter: self._converter = Converter(self.steem) return self._converter @property def profile(self): with suppress(Exception): meta_str = self.get("json_metadata", "") return json.loads(meta_str).get('profile', dict()) @property def sp(self): vests = Amount(self['vesting_shares']).amount return round(self.converter.vests_to_sp(vests), 3) @property def rep(self): return self.reputation() @property def balances(self): return self.get_balances() def get_balances(self, as_float=False): my_account_balances = self.steem.get_balances(self.name) balance = { "STEEM": my_account_balances["balance"], "SBD": my_account_balances["sbd_balance"], "VESTS": my_account_balances["vesting_shares"], "SAVINGS_STEEM": my_account_balances["savings_balance"], "SAVINGS_SBD": my_account_balances["savings_sbd_balance"] } if as_float: return {k: v.amount for k, v in balance.items()} else: return balance def reputation(self, precision=2): rep = int(self['reputation']) if rep == 0: return 25 score = (math.log10(abs(rep)) - 9) * 9 + 25 if rep < 0: score = 50 - score return round(score, precision) def voting_power(self): return self['voting_power'] / 100 def get_followers(self): return [x['follower'] for x in self._get_followers(direction="follower")] def get_following(self): return [x['following'] for x in self._get_followers(direction="following")] def _get_followers(self, direction="follower", last_user=""): if direction == "follower": followers = self.steem.rpc.get_followers(self.name, last_user, "blog", 100, api="follow") elif direction == "following": followers = self.steem.rpc.get_following(self.name, last_user, "blog", 100, api="follow") if len(followers) >= 100: followers += self._get_followers(direction=direction, last_user=followers[-1][direction])[1:] return followers def has_voted(self, post): active_votes = {v["voter"]: v for v in getattr(post, "active_votes")} return self.name in active_votes def curation_stats(self): trailing_24hr_t = time.time() - datetime.timedelta(hours=24).total_seconds() trailing_7d_t = time.time() - datetime.timedelta(days=7).total_seconds() reward_24h = 0.0 reward_7d = 0.0 for reward in self.history2(filter_by="curation_reward", take=10000): timestamp = parse_time(reward['timestamp']).timestamp() if timestamp > trailing_7d_t: reward_7d += Amount(reward['reward']).amount if timestamp > trailing_24hr_t: reward_24h += Amount(reward['reward']).amount reward_7d = self.converter.vests_to_sp(reward_7d) reward_24h = self.converter.vests_to_sp(reward_24h) return { "24hr": reward_24h, "7d": reward_7d, "avg": reward_7d / 7, } def virtual_op_count(self): try: last_item = self.steem.rpc.get_account_history(self.name, -1, 0)[0][0] except IndexError: return 0 else: return last_item def get_account_votes(self): return self.steem.rpc.get_account_votes(self.name) def get_withdraw_routes(self): return self.steem.rpc.get_withdraw_routes(self.name, 'all') def get_conversion_requests(self): return self.steem.rpc.get_conversion_requests(self.name) @staticmethod def filter_by_date(items, start_time, end_time=None): start_time = parse_time(start_time).timestamp() if end_time: end_time = parse_time(end_time).timestamp() else: end_time = time.time() filtered_items = [] for item in items: if 'time' in item: item_time = item['time'] elif 'timestamp' in item: item_time = item['timestamp'] timestamp = parse_time(item_time).timestamp() if end_time > timestamp > start_time: filtered_items.append(item) return filtered_items def history(self, filter_by=None, start=0): """ Take all elements from start to last from history, oldest first. """ batch_size = 1000 max_index = self.virtual_op_count() if not max_index: return start_index = start + batch_size i = start_index while True: if i == start_index: limit = batch_size else: limit = batch_size - 1 history = self.steem.rpc.get_account_history(self.name, i, limit) for item in history: index = item[0] if index >= max_index: return op_type = item[1]['op'][0] op = item[1]['op'][1] timestamp = item[1]['timestamp'] trx_id = item[1]['trx_id'] def construct_op(account_name): r = { "index": index, "account": account_name, "trx_id": trx_id, "timestamp": timestamp, "type": op_type, } r.update(op) return r if filter_by is None: yield construct_op(self.name) else: if type(filter_by) is list: if op_type in filter_by: yield construct_op(self.name) if type(filter_by) is str: if op_type == filter_by: yield construct_op(self.name) i += batch_size def history2(self, filter_by=None, take=1000): """ Take X elements from most recent history, oldest first. """ max_index = self.virtual_op_count() start_index = max_index - take if start_index < 0: start_index = 0 return self.history(filter_by, start=start_index) def rawhistory( self, first=99999999999, limit=-1, only_ops=[], exclude_ops=[] ): """ Returns a generator for individual account transactions. The latest operation will be first. This call can be used in a ``for`` loop. :param str account: account name to get history for :param int first: sequence number of the first transaction to return :param int limit: limit number of transactions to return :param array only_ops: Limit generator by these operations """ cnt = 0 _limit = 100 if _limit > first: _limit = first while first > 0: # RPC call txs = self.steem.rpc.get_account_history(self.name, first, _limit) for i in txs[::-1]: if exclude_ops and i[1]["op"][0] in exclude_ops: continue if not only_ops or i[1]["op"][0] in only_ops: cnt += 1 yield i if limit >= 0 and cnt >= limit: break if limit >= 0 and cnt >= limit: break if len(txs) < _limit: break first = txs[0][0] - 1 # new first if _limit > first: _limit = first
unlicense
[ 646, 2197, 199, 646, 2022, 199, 646, 3473, 199, 646, 900, 199, 504, 15502, 492, 15678, 199, 199, 504, 299, 631, 265, 14, 842, 492, 5709, 63, 1597, 5633, 63, 842, 199, 199, 504, 1275, 4606, 492, 26701, 199, 504, 1275, 11256, 492, 11801, 351, 199, 504, 1275, 3924, 492, 9973, 7193, 7965, 1726, 199, 504, 1275, 1208, 492, 2198, 63, 521, 421, 199, 533, 9973, 8, 807, 304, 272, 408, 961, 1021, 6127, 370, 16174, 2879, 9973, 666, 398, 520, 635, 620, 2933, 63, 354, 26, 2812, 402, 314, 2933, 267, 520, 635, 17854, 5633, 20345, 5633, 63, 842, 26, 17854, 5633, 342, 1256, 370, 675, 1380, 1066, 823, 316, 282, 11785, 267, 520, 635, 2155, 9617, 26, 3645, 9617, 8697, 339, 408, 272, 347, 636, 826, 721, 267, 291, 12, 267, 2933, 63, 354, 12, 267, 20345, 5633, 63, 842, 29, 403, 12, 267, 9617, 29, 797, 12, 272, 3461, 267, 291, 14, 1597, 5633, 275, 20345, 5633, 63, 842, 503, 5709, 63, 1597, 5633, 63, 842, 342, 267, 291, 14, 5245, 275, 756, 267, 291, 14, 354, 275, 2933, 63, 354, 398, 327, 18014, 267, 291, 423, 11256, 275, 488, 398, 340, 440, 9617, 26, 288, 291, 14, 6635, 342, 339, 347, 9236, 8, 277, 304, 267, 2933, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 2048, 8, 277, 14, 354, 9, 267, 340, 440, 2933, 26, 288, 746, 9973, 7193, 7965, 1726, 267, 1613, 8, 6009, 12, 291, 2843, 826, 721, 2048, 9, 267, 291, 14, 5245, 275, 715, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 440, 291, 14, 5245, 26, 288, 291, 14, 6635, 342, 267, 372, 1613, 8, 6009, 12, 291, 2843, 6095, 721, 498, 9, 339, 347, 2974, 8, 277, 304, 267, 340, 440, 291, 14, 5245, 26, 288, 291, 14, 6635, 342, 267, 372, 1613, 8, 6009, 12, 291, 680, 1744, 342, 339, 768, 1829, 272, 347, 11109, 8, 277, 304, 267, 340, 440, 291, 423, 11256, 26, 288, 291, 423, 11256, 275, 11801, 351, 8, 277, 14, 1597, 5633, 9, 267, 372, 291, 423, 11256, 339, 768, 1829, 272, 347, 4690, 8, 277, 304, 267, 543, 15678, 8, 1726, 304, 288, 3404, 63, 495, 275, 291, 14, 362, 480, 1001, 63, 2343, 401, 6899, 288, 372, 2022, 14, 3640, 8, 2024, 63, 495, 680, 362, 360, 2913, 297, 1211, 1012, 339, 768, 1829, 272, 347, 2249, 8, 277, 304, 267, 373, 597, 83, 275, 26701, 8, 277, 459, 13981, 316, 63, 18318, 13227, 4606, 267, 372, 6168, 8, 277, 14, 11256, 14, 432, 10329, 63, 475, 63, 681, 8, 432, 10329, 395, 650, 9, 339, 768, 1829, 272, 347, 1833, 8, 277, 304, 267, 372, 291, 14, 264, 524, 425, 342, 339, 768, 1829, 272, 347, 8091, 13236, 8, 277, 304, 267, 372, 291, 14, 362, 63, 7358, 83, 342, 339, 347, 664, 63, 7358, 83, 8, 277, 12, 465, 63, 1609, 29, 797, 304, 267, 3002, 63, 2048, 63, 7358, 83, 275, 291, 14, 1597, 5633, 14, 362, 63, 7358, 83, 8, 277, 14, 354, 9, 267, 14094, 275, 469, 288, 298, 840, 37, 2769, 582, 3002, 63, 2048, 63, 7358, 83, 905, 7358, 2255, 288, 298, 51, 11156, 582, 3002, 63, 2048, 63, 7358, 83, 905, 83, 3691, 63, 7358, 2255, 288, 298, 54, 1719, 51, 582, 3002, 63, 2048, 63, 7358, 83, 905, 13981, 316, 63, 18318, 2255, 288, 298, 4251, 54, 3881, 63, 840, 37, 2769, 582, 3002, 63, 2048, 63, 7358, 83, 905, 23374, 780, 63, 7358, 2255, 288, 298, 4251, 54, 3881, 63, 51, 11156, 582, 3002, 63, 2048, 63, 7358, 83, 905, 23374, 780, 63, 83, 3691, 63, 7358, 937, 267, 789, 267, 340, 465, 63, 1609, 26, 288, 372, 469, 75, 26, 373, 14, 4606, 367, 1022, 12, 373, 315, 14094, 14, 1744, 12737, 267, 587, 26, 288, 372, 14094, 339, 347, 295, 524, 425, 8, 277, 12, 7151, 29, 18, 304, 267, 1833, 275, 1109, 8, 277, 459, 264, 524, 425, 1105, 267, 340, 1833, 508, 378, 26, 288, 372, 5661, 267, 5396, 275, 334, 3442, 14, 793, 709, 8, 2101, 8, 1155, 430, 446, 1749, 9, 627, 1749, 435, 5661, 267, 340, 1833, 665, 378, 26, 288, 5396, 275, 5238, 446, 5396, 267, 372, 6168, 8, 3397, 12, 7151, 9, 339, 347, 373, 15866, 63, 5652, 8, 277, 304, 267, 372, 291, 459, 86, 15866, 63, 5652, 418, 1182, 2948, 339, 347, 664, 63, 22648, 8, 277, 304, 267, 372, 359, 88, 459, 25615, 418, 367, 671, 315, 291, 423, 362, 63, 22648, 8, 6874, 628, 25615, 11323, 339, 347, 664, 63, 21589, 8, 277, 304, 267, 372, 359, 88, 459, 21589, 418, 367, 671, 315, 291, 423, 362, 63, 22648, 8, 6874, 628, 21589, 11323, 339, 347, 485, 362, 63, 22648, 8, 277, 12, 7581, 628, 25615, 401, 2061, 63, 751, 17364, 267, 340, 7581, 508, 298, 25615, 582, 288, 31474, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 22648, 8, 277, 14, 354, 12, 2061, 63, 751, 12, 298, 11486, 401, 2948, 12, 2986, 628, 7207, 531, 267, 916, 7581, 508, 298, 21589, 582, 288, 31474, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 21589, 8, 277, 14, 354, 12, 2061, 63, 751, 12, 298, 11486, 401, 2948, 12, 2986, 628, 7207, 531, 267, 340, 822, 8, 22648, 9, 2356, 2948, 26, 288, 31474, 847, 291, 423, 362, 63, 22648, 8, 6874, 29, 6874, 12, 2061, 63, 751, 29, 22648, 1988, 17, 1527, 6874, 11057, 17, 2938, 267, 372, 31474, 339, 347, 965, 63, 2392, 471, 8, 277, 12, 2963, 304, 267, 4702, 63, 16660, 275, 469, 86, 905, 2392, 351, 6229, 373, 367, 373, 315, 2519, 8, 1932, 12, 298, 2682, 63, 16660, 531, 93, 267, 372, 291, 14, 354, 315, 4702, 63, 16660, 339, 347, 1094, 425, 63, 3200, 8, 277, 304, 267, 8520, 63, 1194, 6271, 63, 84, 275, 900, 14, 521, 342, 446, 2197, 14, 7473, 8, 8419, 29, 1194, 680, 2923, 63, 4515, 342, 267, 8520, 63, 23, 68, 63, 84, 275, 900, 14, 521, 342, 446, 2197, 14, 7473, 8, 4899, 29, 23, 680, 2923, 63, 4515 ]
[ 2197, 199, 646, 2022, 199, 646, 3473, 199, 646, 900, 199, 504, 15502, 492, 15678, 199, 199, 504, 299, 631, 265, 14, 842, 492, 5709, 63, 1597, 5633, 63, 842, 199, 199, 504, 1275, 4606, 492, 26701, 199, 504, 1275, 11256, 492, 11801, 351, 199, 504, 1275, 3924, 492, 9973, 7193, 7965, 1726, 199, 504, 1275, 1208, 492, 2198, 63, 521, 421, 199, 533, 9973, 8, 807, 304, 272, 408, 961, 1021, 6127, 370, 16174, 2879, 9973, 666, 398, 520, 635, 620, 2933, 63, 354, 26, 2812, 402, 314, 2933, 267, 520, 635, 17854, 5633, 20345, 5633, 63, 842, 26, 17854, 5633, 342, 1256, 370, 675, 1380, 1066, 823, 316, 282, 11785, 267, 520, 635, 2155, 9617, 26, 3645, 9617, 8697, 339, 408, 272, 347, 636, 826, 721, 267, 291, 12, 267, 2933, 63, 354, 12, 267, 20345, 5633, 63, 842, 29, 403, 12, 267, 9617, 29, 797, 12, 272, 3461, 267, 291, 14, 1597, 5633, 275, 20345, 5633, 63, 842, 503, 5709, 63, 1597, 5633, 63, 842, 342, 267, 291, 14, 5245, 275, 756, 267, 291, 14, 354, 275, 2933, 63, 354, 398, 327, 18014, 267, 291, 423, 11256, 275, 488, 398, 340, 440, 9617, 26, 288, 291, 14, 6635, 342, 339, 347, 9236, 8, 277, 304, 267, 2933, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 2048, 8, 277, 14, 354, 9, 267, 340, 440, 2933, 26, 288, 746, 9973, 7193, 7965, 1726, 267, 1613, 8, 6009, 12, 291, 2843, 826, 721, 2048, 9, 267, 291, 14, 5245, 275, 715, 339, 347, 636, 6095, 721, 277, 12, 790, 304, 267, 340, 440, 291, 14, 5245, 26, 288, 291, 14, 6635, 342, 267, 372, 1613, 8, 6009, 12, 291, 2843, 6095, 721, 498, 9, 339, 347, 2974, 8, 277, 304, 267, 340, 440, 291, 14, 5245, 26, 288, 291, 14, 6635, 342, 267, 372, 1613, 8, 6009, 12, 291, 680, 1744, 342, 339, 768, 1829, 272, 347, 11109, 8, 277, 304, 267, 340, 440, 291, 423, 11256, 26, 288, 291, 423, 11256, 275, 11801, 351, 8, 277, 14, 1597, 5633, 9, 267, 372, 291, 423, 11256, 339, 768, 1829, 272, 347, 4690, 8, 277, 304, 267, 543, 15678, 8, 1726, 304, 288, 3404, 63, 495, 275, 291, 14, 362, 480, 1001, 63, 2343, 401, 6899, 288, 372, 2022, 14, 3640, 8, 2024, 63, 495, 680, 362, 360, 2913, 297, 1211, 1012, 339, 768, 1829, 272, 347, 2249, 8, 277, 304, 267, 373, 597, 83, 275, 26701, 8, 277, 459, 13981, 316, 63, 18318, 13227, 4606, 267, 372, 6168, 8, 277, 14, 11256, 14, 432, 10329, 63, 475, 63, 681, 8, 432, 10329, 395, 650, 9, 339, 768, 1829, 272, 347, 1833, 8, 277, 304, 267, 372, 291, 14, 264, 524, 425, 342, 339, 768, 1829, 272, 347, 8091, 13236, 8, 277, 304, 267, 372, 291, 14, 362, 63, 7358, 83, 342, 339, 347, 664, 63, 7358, 83, 8, 277, 12, 465, 63, 1609, 29, 797, 304, 267, 3002, 63, 2048, 63, 7358, 83, 275, 291, 14, 1597, 5633, 14, 362, 63, 7358, 83, 8, 277, 14, 354, 9, 267, 14094, 275, 469, 288, 298, 840, 37, 2769, 582, 3002, 63, 2048, 63, 7358, 83, 905, 7358, 2255, 288, 298, 51, 11156, 582, 3002, 63, 2048, 63, 7358, 83, 905, 83, 3691, 63, 7358, 2255, 288, 298, 54, 1719, 51, 582, 3002, 63, 2048, 63, 7358, 83, 905, 13981, 316, 63, 18318, 2255, 288, 298, 4251, 54, 3881, 63, 840, 37, 2769, 582, 3002, 63, 2048, 63, 7358, 83, 905, 23374, 780, 63, 7358, 2255, 288, 298, 4251, 54, 3881, 63, 51, 11156, 582, 3002, 63, 2048, 63, 7358, 83, 905, 23374, 780, 63, 83, 3691, 63, 7358, 937, 267, 789, 267, 340, 465, 63, 1609, 26, 288, 372, 469, 75, 26, 373, 14, 4606, 367, 1022, 12, 373, 315, 14094, 14, 1744, 12737, 267, 587, 26, 288, 372, 14094, 339, 347, 295, 524, 425, 8, 277, 12, 7151, 29, 18, 304, 267, 1833, 275, 1109, 8, 277, 459, 264, 524, 425, 1105, 267, 340, 1833, 508, 378, 26, 288, 372, 5661, 267, 5396, 275, 334, 3442, 14, 793, 709, 8, 2101, 8, 1155, 430, 446, 1749, 9, 627, 1749, 435, 5661, 267, 340, 1833, 665, 378, 26, 288, 5396, 275, 5238, 446, 5396, 267, 372, 6168, 8, 3397, 12, 7151, 9, 339, 347, 373, 15866, 63, 5652, 8, 277, 304, 267, 372, 291, 459, 86, 15866, 63, 5652, 418, 1182, 2948, 339, 347, 664, 63, 22648, 8, 277, 304, 267, 372, 359, 88, 459, 25615, 418, 367, 671, 315, 291, 423, 362, 63, 22648, 8, 6874, 628, 25615, 11323, 339, 347, 664, 63, 21589, 8, 277, 304, 267, 372, 359, 88, 459, 21589, 418, 367, 671, 315, 291, 423, 362, 63, 22648, 8, 6874, 628, 21589, 11323, 339, 347, 485, 362, 63, 22648, 8, 277, 12, 7581, 628, 25615, 401, 2061, 63, 751, 17364, 267, 340, 7581, 508, 298, 25615, 582, 288, 31474, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 22648, 8, 277, 14, 354, 12, 2061, 63, 751, 12, 298, 11486, 401, 2948, 12, 2986, 628, 7207, 531, 267, 916, 7581, 508, 298, 21589, 582, 288, 31474, 275, 291, 14, 1597, 5633, 14, 4354, 14, 362, 63, 21589, 8, 277, 14, 354, 12, 2061, 63, 751, 12, 298, 11486, 401, 2948, 12, 2986, 628, 7207, 531, 267, 340, 822, 8, 22648, 9, 2356, 2948, 26, 288, 31474, 847, 291, 423, 362, 63, 22648, 8, 6874, 29, 6874, 12, 2061, 63, 751, 29, 22648, 1988, 17, 1527, 6874, 11057, 17, 2938, 267, 372, 31474, 339, 347, 965, 63, 2392, 471, 8, 277, 12, 2963, 304, 267, 4702, 63, 16660, 275, 469, 86, 905, 2392, 351, 6229, 373, 367, 373, 315, 2519, 8, 1932, 12, 298, 2682, 63, 16660, 531, 93, 267, 372, 291, 14, 354, 315, 4702, 63, 16660, 339, 347, 1094, 425, 63, 3200, 8, 277, 304, 267, 8520, 63, 1194, 6271, 63, 84, 275, 900, 14, 521, 342, 446, 2197, 14, 7473, 8, 8419, 29, 1194, 680, 2923, 63, 4515, 342, 267, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
sagar30051991/ozsmart-erp
erpnext/selling/doctype/customer/test_customer.py
7
4063
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe import unittest from frappe.test_runner import make_test_records from erpnext.exceptions import PartyFrozen, PartyDisabled test_ignore = ["Price List"] test_records = frappe.get_test_records('Customer') class TestCustomer(unittest.TestCase): def test_party_details(self): from erpnext.accounts.party import get_party_details to_check = { 'selling_price_list': None, 'customer_group': '_Test Customer Group', 'contact_designation': None, 'customer_address': '_Test Address-Office', 'contact_department': None, 'contact_email': 'test_contact_customer@example.com', 'contact_mobile': None, 'sales_team': [], 'contact_display': '_Test Contact For _Test Customer', 'contact_person': '_Test Contact For _Test Customer-_Test Customer', 'territory': u'_Test Territory', 'contact_phone': '+91 0000000000', 'customer_name': '_Test Customer' } make_test_records("Address") make_test_records("Contact") frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer", "is_primary_contact", 1) details = get_party_details("_Test Customer") for key, value in to_check.iteritems(): self.assertEquals(value, details.get(key)) def test_rename(self): for name in ("_Test Customer 1", "_Test Customer 1 Renamed"): frappe.db.sql("""delete from `tabCommunication` where communication_type='Comment' and reference_doctype=%s and reference_name=%s""", ("Customer", name)) comment = frappe.get_doc("Customer", "_Test Customer 1").add_comment("Comment", "Test Comment for Rename") frappe.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed") self.assertTrue(frappe.db.exists("Customer", "_Test Customer 1 Renamed")) self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1")) # test that comment gets renamed self.assertEquals(frappe.db.get_value("Communication", { "communication_type": "Comment", "reference_doctype": "Customer", "reference_name": "_Test Customer 1 Renamed" }), comment.name) frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1") def test_freezed_customer(self): make_test_records("Item") frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 1) from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order so = make_sales_order(do_not_save= True) self.assertRaises(PartyFrozen, so.save) frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 0) so.save() def test_disabled_customer(self): make_test_records("Item") frappe.db.set_value("Customer", "_Test Customer", "disabled", 1) from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order so = make_sales_order(do_not_save=True) self.assertRaises(PartyDisabled, so.save) frappe.db.set_value("Customer", "_Test Customer", "disabled", 0) so.save() def test_duplicate_customer(self): frappe.db.sql("delete from `tabCustomer` where customer_name='_Test Customer 1'") if not frappe.db.get_value("Customer", "_Test Customer 1"): test_customer_1 = frappe.get_doc({ "customer_group": "_Test Customer Group", "customer_name": "_Test Customer 1", "customer_type": "Individual", "doctype": "Customer", "territory": "_Test Territory" }).insert(ignore_permissions=True) else: test_customer_1 = frappe.get_doc("Customer", "_Test Customer 1") duplicate_customer = frappe.get_doc({ "customer_group": "_Test Customer Group", "customer_name": "_Test Customer 1", "customer_type": "Individual", "doctype": "Customer", "territory": "_Test Territory" }).insert(ignore_permissions=True) self.assertEquals("_Test Customer 1", test_customer_1.name) self.assertEquals("_Test Customer 1 - 1", duplicate_customer.name) self.assertEquals(test_customer_1.customer_name, duplicate_customer.customer_name)
agpl-3.0
[ 3, 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6950, 199, 646, 2882, 199, 199, 504, 6950, 14, 396, 63, 5933, 492, 1852, 63, 396, 63, 6502, 199, 504, 29106, 14, 3924, 492, 2235, 369, 29767, 12, 2235, 369, 15049, 199, 199, 396, 63, 4247, 275, 2097, 11826, 3820, 937, 199, 199, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 17025, 358, 199, 199, 533, 1379, 17025, 8, 2796, 14, 1746, 304, 199, 198, 318, 511, 63, 7522, 63, 5087, 8, 277, 304, 507, 198, 504, 29106, 14, 8370, 14, 7522, 492, 664, 63, 7522, 63, 5087, 2742, 198, 475, 63, 1074, 275, 469, 686, 198, 1159, 1697, 316, 63, 4777, 63, 513, 356, 488, 12, 686, 198, 7, 10178, 63, 923, 356, 2513, 774, 22397, 5611, 297, 686, 198, 7, 7811, 63, 14748, 425, 356, 488, 12, 686, 198, 7, 10178, 63, 1562, 356, 2513, 774, 9906, 13, 31166, 297, 686, 198, 7, 7811, 63, 19623, 356, 488, 12, 686, 198, 7, 7811, 63, 2123, 356, 283, 396, 63, 7811, 63, 10178, 32, 2694, 14, 957, 297, 686, 198, 7, 7811, 63, 11375, 356, 488, 12, 686, 198, 1159, 7098, 63, 5969, 356, 990, 686, 198, 7, 7811, 63, 2918, 356, 2513, 774, 18684, 2104, 485, 774, 22397, 297, 686, 198, 7, 7811, 63, 5484, 356, 2513, 774, 18684, 2104, 485, 774, 22397, 13, 63, 774, 22397, 297, 686, 198, 1133, 281, 26425, 356, 399, 26142, 774, 13861, 26425, 297, 686, 198, 7, 7811, 63, 9339, 356, 6681, 3328, 378, 25464, 297, 686, 198, 7, 10178, 63, 354, 356, 2513, 774, 22397, 7, 507, 198, 93, 2742, 198, 1875, 63, 396, 63, 6502, 480, 1476, 531, 507, 198, 1875, 63, 396, 63, 6502, 480, 14499, 531, 507, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 14499, 401, 2668, 774, 18684, 2104, 485, 774, 22397, 13, 63, 774, 22397, 401, 686, 198, 2, 374, 63, 3327, 63, 7811, 401, 413, 9, 2742, 198, 5087, 275, 664, 63, 7522, 63, 5087, 11008, 774, 22397, 531, 2742, 198, 509, 790, 12, 574, 315, 370, 63, 1074, 14, 4611, 837, 686, 198, 277, 14, 2947, 8, 585, 12, 2436, 14, 362, 8, 498, 430, 421, 198, 318, 511, 63, 8165, 8, 277, 304, 507, 198, 509, 536, 315, 1689, 63, 774, 22397, 413, 401, 2668, 774, 22397, 413, 22756, 68, 2349, 686, 198, 9098, 14, 697, 14, 3009, 4852, 1807, 687, 658, 2902, 27258, 425, 64, 1585, 198, 4509, 23506, 63, 466, 534, 7488, 7, 436, 3659, 63, 6356, 2458, 83, 436, 3659, 63, 354, 2458, 83, 7208, 1585, 198, 480, 17025, 401, 536, 430, 2742, 198, 3349, 275, 6950, 14, 362, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 3471, 525, 63, 3349, 480, 7488, 401, 298, 774, 6819, 367, 22756, 531, 2742, 198, 9098, 14, 8165, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 401, 2668, 774, 22397, 413, 22756, 68, 531, 2742, 198, 277, 14, 1815, 8, 9098, 14, 697, 14, 2444, 480, 17025, 401, 2668, 774, 22397, 413, 22756, 68, 2237, 507, 198, 277, 14, 3334, 8, 9098, 14, 697, 14, 2444, 480, 17025, 401, 2668, 774, 22397, 413, 2237, 2742, 198, 3, 511, 626, 3721, 7545, 17864, 507, 198, 277, 14, 2947, 8, 9098, 14, 697, 14, 362, 63, 585, 480, 27258, 425, 401, 469, 686, 198, 2, 29351, 63, 466, 582, 298, 7488, 401, 686, 198, 2, 4443, 63, 6356, 582, 298, 17025, 401, 686, 198, 2, 4443, 63, 354, 582, 2668, 774, 22397, 413, 22756, 68, 2, 507, 198, 8688, 3721, 14, 354, 9, 2742, 198, 9098, 14, 8165, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 22756, 68, 401, 2668, 774, 22397, 413, 531, 421, 198, 318, 511, 63, 4624, 7068, 63, 10178, 8, 277, 304, 507, 198, 1875, 63, 396, 63, 6502, 480, 2081, 531, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 374, 63, 11202, 401, 413, 9, 2742, 198, 504, 29106, 14, 261, 10564, 14, 6356, 14, 16175, 63, 1648, 14, 396, 63, 16175, 63, 1648, 492, 1852, 63, 16175, 63, 1648, 2742, 198, 1152, 275, 1852, 63, 16175, 63, 1648, 8, 1117, 63, 1397, 63, 2117, 29, 715, 9, 2742, 198, 277, 14, 1855, 8, 25233, 29767, 12, 880, 14, 2117, 9, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 374, 63, 11202, 401, 378, 9, 2742, 198, 1152, 14, 2117, 342, 421, 198, 318, 511, 63, 7011, 63, 10178, 8, 277, 304, 507, 198, 1875, 63, 396, 63, 6502, 480, 2081, 531, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 7011, 401, 413, 9, 2742, 198, 504, 29106, 14, 261, 10564, 14, 6356, 14, 16175, 63, 1648, 14, 396, 63, 16175, 63, 1648, 492, 1852, 63, 16175, 63, 1648, 2742, 198, 1152, 275, 1852, 63, 16175, 63, 1648, 8, 1117, 63, 1397, 63, 2117, 29, 549, 9, 2742, 198, 277, 14, 1855, 8, 25233, 15049, 12, 880, 14, 2117, 9, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 7011, 401, 378, 9, 2742, 198, 1152, 14, 2117, 342, 421, 198, 318, 511, 63, 11081, 63, 10178, 8, 277, 304, 507, 198, 9098, 14, 697, 14, 3009, 480, 1807, 687, 658, 2902, 17025, 64, 2382, 15229, 63, 354, 17574, 774, 22397, 413, 9859, 2742, 198, 692, 440, 6950, 14, 697, 14, 362, 63, 585, 480, 17025, 401, 2668, 774, 22397, 413, 2349, 686, 198, 396, 63, 10178, 63, 17, 275, 6950, 14, 362, 63, 1301, 2561, 1871, 298, 10178, 63, 923, 582, 2668, 774, 22397, 5611, 401, 1871, 298, 10178, 63, 354, 582, 2668, 774, 22397, 413, 401, 1871, 298, 10178, 63, 466, 582, 298, 28604, 401, 1871, 298, 6356, 582, 298, 17025, 401, 1871, 298, 351, 26425, 582, 2668, 774, 13861, 26425, 2, 686, 198 ]
[ 1898, 334, 67, 9, 6900, 12, 481, 5034, 19215, 29053, 14, 12126, 14, 436, 23212, 199, 3, 844, 26, 1664, 1696, 1684, 844, 373, 19, 14, 1666, 4190, 14, 2424, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 6950, 199, 646, 2882, 199, 199, 504, 6950, 14, 396, 63, 5933, 492, 1852, 63, 396, 63, 6502, 199, 504, 29106, 14, 3924, 492, 2235, 369, 29767, 12, 2235, 369, 15049, 199, 199, 396, 63, 4247, 275, 2097, 11826, 3820, 937, 199, 199, 396, 63, 6502, 275, 6950, 14, 362, 63, 396, 63, 6502, 360, 17025, 358, 199, 199, 533, 1379, 17025, 8, 2796, 14, 1746, 304, 199, 198, 318, 511, 63, 7522, 63, 5087, 8, 277, 304, 507, 198, 504, 29106, 14, 8370, 14, 7522, 492, 664, 63, 7522, 63, 5087, 2742, 198, 475, 63, 1074, 275, 469, 686, 198, 1159, 1697, 316, 63, 4777, 63, 513, 356, 488, 12, 686, 198, 7, 10178, 63, 923, 356, 2513, 774, 22397, 5611, 297, 686, 198, 7, 7811, 63, 14748, 425, 356, 488, 12, 686, 198, 7, 10178, 63, 1562, 356, 2513, 774, 9906, 13, 31166, 297, 686, 198, 7, 7811, 63, 19623, 356, 488, 12, 686, 198, 7, 7811, 63, 2123, 356, 283, 396, 63, 7811, 63, 10178, 32, 2694, 14, 957, 297, 686, 198, 7, 7811, 63, 11375, 356, 488, 12, 686, 198, 1159, 7098, 63, 5969, 356, 990, 686, 198, 7, 7811, 63, 2918, 356, 2513, 774, 18684, 2104, 485, 774, 22397, 297, 686, 198, 7, 7811, 63, 5484, 356, 2513, 774, 18684, 2104, 485, 774, 22397, 13, 63, 774, 22397, 297, 686, 198, 1133, 281, 26425, 356, 399, 26142, 774, 13861, 26425, 297, 686, 198, 7, 7811, 63, 9339, 356, 6681, 3328, 378, 25464, 297, 686, 198, 7, 10178, 63, 354, 356, 2513, 774, 22397, 7, 507, 198, 93, 2742, 198, 1875, 63, 396, 63, 6502, 480, 1476, 531, 507, 198, 1875, 63, 396, 63, 6502, 480, 14499, 531, 507, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 14499, 401, 2668, 774, 18684, 2104, 485, 774, 22397, 13, 63, 774, 22397, 401, 686, 198, 2, 374, 63, 3327, 63, 7811, 401, 413, 9, 2742, 198, 5087, 275, 664, 63, 7522, 63, 5087, 11008, 774, 22397, 531, 2742, 198, 509, 790, 12, 574, 315, 370, 63, 1074, 14, 4611, 837, 686, 198, 277, 14, 2947, 8, 585, 12, 2436, 14, 362, 8, 498, 430, 421, 198, 318, 511, 63, 8165, 8, 277, 304, 507, 198, 509, 536, 315, 1689, 63, 774, 22397, 413, 401, 2668, 774, 22397, 413, 22756, 68, 2349, 686, 198, 9098, 14, 697, 14, 3009, 4852, 1807, 687, 658, 2902, 27258, 425, 64, 1585, 198, 4509, 23506, 63, 466, 534, 7488, 7, 436, 3659, 63, 6356, 2458, 83, 436, 3659, 63, 354, 2458, 83, 7208, 1585, 198, 480, 17025, 401, 536, 430, 2742, 198, 3349, 275, 6950, 14, 362, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 3471, 525, 63, 3349, 480, 7488, 401, 298, 774, 6819, 367, 22756, 531, 2742, 198, 9098, 14, 8165, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 401, 2668, 774, 22397, 413, 22756, 68, 531, 2742, 198, 277, 14, 1815, 8, 9098, 14, 697, 14, 2444, 480, 17025, 401, 2668, 774, 22397, 413, 22756, 68, 2237, 507, 198, 277, 14, 3334, 8, 9098, 14, 697, 14, 2444, 480, 17025, 401, 2668, 774, 22397, 413, 2237, 2742, 198, 3, 511, 626, 3721, 7545, 17864, 507, 198, 277, 14, 2947, 8, 9098, 14, 697, 14, 362, 63, 585, 480, 27258, 425, 401, 469, 686, 198, 2, 29351, 63, 466, 582, 298, 7488, 401, 686, 198, 2, 4443, 63, 6356, 582, 298, 17025, 401, 686, 198, 2, 4443, 63, 354, 582, 2668, 774, 22397, 413, 22756, 68, 2, 507, 198, 8688, 3721, 14, 354, 9, 2742, 198, 9098, 14, 8165, 63, 1301, 480, 17025, 401, 2668, 774, 22397, 413, 22756, 68, 401, 2668, 774, 22397, 413, 531, 421, 198, 318, 511, 63, 4624, 7068, 63, 10178, 8, 277, 304, 507, 198, 1875, 63, 396, 63, 6502, 480, 2081, 531, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 374, 63, 11202, 401, 413, 9, 2742, 198, 504, 29106, 14, 261, 10564, 14, 6356, 14, 16175, 63, 1648, 14, 396, 63, 16175, 63, 1648, 492, 1852, 63, 16175, 63, 1648, 2742, 198, 1152, 275, 1852, 63, 16175, 63, 1648, 8, 1117, 63, 1397, 63, 2117, 29, 715, 9, 2742, 198, 277, 14, 1855, 8, 25233, 29767, 12, 880, 14, 2117, 9, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 374, 63, 11202, 401, 378, 9, 2742, 198, 1152, 14, 2117, 342, 421, 198, 318, 511, 63, 7011, 63, 10178, 8, 277, 304, 507, 198, 1875, 63, 396, 63, 6502, 480, 2081, 531, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 7011, 401, 413, 9, 2742, 198, 504, 29106, 14, 261, 10564, 14, 6356, 14, 16175, 63, 1648, 14, 396, 63, 16175, 63, 1648, 492, 1852, 63, 16175, 63, 1648, 2742, 198, 1152, 275, 1852, 63, 16175, 63, 1648, 8, 1117, 63, 1397, 63, 2117, 29, 549, 9, 2742, 198, 277, 14, 1855, 8, 25233, 15049, 12, 880, 14, 2117, 9, 2742, 198, 9098, 14, 697, 14, 409, 63, 585, 480, 17025, 401, 2668, 774, 22397, 401, 298, 7011, 401, 378, 9, 2742, 198, 1152, 14, 2117, 342, 421, 198, 318, 511, 63, 11081, 63, 10178, 8, 277, 304, 507, 198, 9098, 14, 697, 14, 3009, 480, 1807, 687, 658, 2902, 17025, 64, 2382, 15229, 63, 354, 17574, 774, 22397, 413, 9859, 2742, 198, 692, 440, 6950, 14, 697, 14, 362, 63, 585, 480, 17025, 401, 2668, 774, 22397, 413, 2349, 686, 198, 396, 63, 10178, 63, 17, 275, 6950, 14, 362, 63, 1301, 2561, 1871, 298, 10178, 63, 923, 582, 2668, 774, 22397, 5611, 401, 1871, 298, 10178, 63, 354, 582, 2668, 774, 22397, 413, 401, 1871, 298, 10178, 63, 466, 582, 298, 28604, 401, 1871, 298, 6356, 582, 298, 17025, 401, 1871, 298, 351, 26425, 582, 2668, 774, 13861, 26425, 2, 686, 198, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Mec-iS/chronostriples-backup
flankers/tagmeapi/tagMeService.py
3
7680
# # A basic API to query TagMe RESTful services # __author__ = ['lorenzo'] import time from pprint import pprint import urllib import urllib2 from flankers.tagmeapi.secret.keys import return_api_key from flankers.tools import retrieve_json api_key = return_api_key() class TagMeService: """ Contains methods that format inputs and fetch the required data from the service -------------------------------------------------------------------------------- """ @staticmethod def return_gen_scopes(): return ['Aerospace', 'Astrophysics', 'Cosmic_ray', 'Spaceflight', 'Spacecraft', 'Avionics', "Command_and_control", "Geodesy", 'Astronomical_object', 'Astronomy', 'Aircraft', 'Atmosphere', "Navigation", "Radio_navigation", "Satellite", "Spaceflight", "Physics", "NASA", "Planetary_science"] @staticmethod def check_spotting(text): """ Spot wikipedia references in a given text 'http://tagme.di.unipi.it/spot?key=****&text=Recent+poll+show+President+Obama+opening+up+a+small+lead' :param text: the text to analyze :return: dictionary with a flag message ('spotted') and a loaded JSON from response ('value') """ import json endpoint = "http://tagme.di.unipi.it/spot" body = str(text.encode('ascii', 'replace')) params = { "key": api_key, "text": body } url = endpoint + '?' + urllib.urlencode(params) try: answer = json.loads(urllib2.urlopen(url).read()) except (Exception, UnicodeDecodeError): print(">>>>>>>>>>>>>>>>> ERROR >>>>>>>>>>", text) return {"spotted": False, "value": None} if len(answer["spots"]) != 0: result = {"spotted": True, "value": answer} return result return {"spotted": False, "value": answer} @staticmethod def retrieve_taggings(term, method='GET'): """ Find annotations of a given concept/word/sets of words 'http://tagme.di.unipi.it/tag?key=****&text=Recent+poll+show+President+Obama+opening+up+a+small+lead' :param term: the text to analyze as a byte (b'string') :return: dictionary with loaded JSON from response """ endpoint = "http://tagme.di.unipi.it/tag" # print(term) if str(term) == 'None': return {"timestamp": time.time(), "time": 0, "api": "tag", "annotations": [], "lang": "en"} params = { "key": api_key, "text": term, "include_categories": True, "include_abstract": True, "include_all_spots": True } if method == 'GET': url = endpoint + '?' + urllib.urlencode(params) data = None # print(url) elif method == 'POST': url = endpoint data = params else: raise BadRequest('retrieve_taggings(): Wrong HTTP Verb') results = {"timestamp": time.time(), "time": 0, "api": "tag", "annotations": [], "lang": "en"} try: results = retrieve_json(url, method=method, data=data) except (Exception, ValueError): return results if "errors" not in results.keys() or results["errors"] == 0: return results raise BadRequest('retrieve_taggings() Failed') @classmethod def relate(cls, titles, comparing=None, min_rho=0.42): """ Implement the TagMe's 'relating API' :param titles: a string that is wikipedia title or a list of titles :param comparing: a string that is wikipedia title or a list of titles :param min_rho: the minimum rho to filter the relation :return: a list of results objects with "rel" > min_rho """ endpoint = "http://tagme.di.unipi.it/rel" if comparing is None: comparing = cls.return_gen_scopes() params = { "key": api_key, "tt": [] } if isinstance(titles, list): if len(titles) > 1: if isinstance(comparing, list): [params["tt"].append(t + ' ' + c) for c in comparing for t in titles if t != c] elif isinstance(comparing, str): [params["tt"].append(t + ' ' + comparing) for t in titles if t != comparing] elif len(titles) == 1: if isinstance(comparing, list): [params["tt"].append(titles[0] + ' ' + c) for c in comparing if titles[0] != c] elif isinstance(comparing, str): params["tt"].append(titles[0] + ' ' + comparing) else: raise ConceptNotInDBpedia('This term does not have annotations, so it cannot be searched for related') else: if isinstance(comparing, list): [params["tt"].append(titles + ' ' + c) for c in comparing if titles != c] elif isinstance(comparing, str): params["tt"].append(titles + ' ' + comparing) url = endpoint + '?' + urllib.urlencode(params, True) try: results = retrieve_json(url) #pprint(results) except (Exception, ValueError): raise BadRequest('Error in connection or in JSON parsing the response from TagMe Relating API') try: if int(results["errors"]) == 0 and len(results["result"]) != 0: output = [r for r in results["result"] if float(r["rel"]) > min_rho] return output else: for r in results["result"]: if 'err' in r.keys(): print(BadRequest("Error in request data to TagMe: " + str(r['err'] + " in " + str(r)))) return None except (Exception, KeyError) as e: raise e raise BadRequest('TagMe API responded with an error: ' + str(results)) @staticmethod def check_if_rho_fits_spaceknowledge(output, level=0.42): """ Takes as input the results of a TagMeService.relate() function and check if the mean of resulting rhos is above a level. Used to check if a term is semantically related to a list of fields [refer to argument "comparing" in relate()] :param output: what returns the TagMeService.relate() :param level: the level at which to filter the mean of the rhos in the results :return: boolean """ if output: result = tuple() count = len(output) zeros = 0 if count != 0: name = str() total = 0.0 for o in output: if float(o["rel"]) == 0.0000: zeros += 1 else: name = o['couple'].split(' ')[0] total += float(o["rel"]) mean = total / count if level < mean < 0.61 and zeros < 8: # the interval is { min: 'level' max: 0.61 } return True, name, mean else: return False, result return False return False class ConceptNotInDBpedia(Exception): """ terms passed to the API have no annotations from WikiPedia """ pass class BadRequest(Exception): """ Request returned with some error """ pass class TextNotSpotted(Exception): """ No terms where found in the string """ pass if __name__ == "__main__": print("This is a useful module, not a stand-alone script")
apache-2.0
[ 3, 199, 3, 437, 5678, 3261, 370, 1827, 8053, 1352, 14880, 1893, 8500, 199, 3, 199, 199, 363, 2502, 363, 275, 788, 320, 828, 18070, 418, 421, 199, 646, 900, 199, 504, 10933, 492, 10933, 199, 646, 4011, 199, 646, 4011, 18, 199, 199, 504, 289, 1983, 1192, 14, 1450, 278, 1246, 14, 4731, 14, 1612, 492, 372, 63, 1246, 63, 498, 199, 504, 289, 1983, 1192, 14, 2537, 492, 8044, 63, 1001, 199, 199, 1246, 63, 498, 275, 372, 63, 1246, 63, 498, 342, 421, 199, 533, 8053, 1352, 3167, 26, 272, 408, 272, 22493, 3102, 626, 1475, 4153, 436, 5267, 314, 1415, 666, 687, 314, 2435, 272, 5620, 777, 272, 408, 339, 768, 4639, 272, 347, 372, 63, 2268, 63, 14129, 837, 267, 372, 788, 33, 281, 17601, 297, 283, 33, 24627, 24724, 297, 283, 26253, 15003, 63, 803, 297, 283, 7643, 28807, 297, 283, 7643, 32342, 297, 283, 33, 433, 265, 2932, 297, 298, 3110, 63, 460, 63, 2785, 401, 355, 298, 4240, 380, 1786, 401, 283, 33, 495, 15222, 2652, 63, 785, 297, 283, 33, 495, 17293, 297, 283, 33, 5958, 4800, 297, 283, 1271, 573, 14980, 297, 355, 298, 19617, 5360, 401, 298, 16065, 63, 24148, 401, 298, 51, 24779, 401, 298, 7643, 28807, 401, 298, 6678, 17378, 401, 355, 298, 46, 1179, 33, 401, 298, 13375, 386, 695, 63, 9907, 4894, 937, 339, 768, 4639, 272, 347, 1104, 63, 15185, 1337, 8, 505, 304, 267, 408, 267, 8360, 357, 336, 29386, 6941, 315, 282, 1627, 1318, 267, 283, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 15185, 31, 498, 29, 1116, 6, 505, 29, 29574, 11, 6843, 11, 2384, 11, 2398, 338, 1326, 11, 47, 2470, 391, 11, 21849, 11, 384, 11, 65, 11, 7241, 11, 13799, 7, 267, 520, 635, 1318, 26, 314, 1318, 370, 19897, 267, 520, 1107, 26, 2600, 543, 282, 3305, 1245, 661, 15185, 471, 358, 436, 282, 6511, 4840, 687, 1177, 661, 585, 358, 267, 408, 267, 492, 2022, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 15185, 2, 398, 2396, 275, 620, 8, 505, 14, 2143, 360, 4371, 297, 283, 1814, 1333, 398, 1862, 275, 469, 288, 298, 498, 582, 2986, 63, 498, 12, 288, 298, 505, 582, 2396, 267, 789, 267, 1166, 275, 6037, 435, 15539, 435, 4011, 14, 10738, 8, 1162, 9, 267, 862, 26, 288, 6385, 275, 2022, 14, 3640, 8, 4078, 18, 14, 10890, 8, 633, 680, 739, 1012, 267, 871, 334, 1726, 12, 18965, 304, 288, 870, 480, 28375, 28375, 28375, 1140, 6071, 12539, 1306, 28375, 6071, 401, 1318, 9, 288, 372, 2420, 15185, 471, 582, 756, 12, 298, 585, 582, 488, 93, 398, 340, 822, 8, 5934, 905, 15185, 83, 3135, 1137, 378, 26, 288, 754, 275, 2420, 15185, 471, 582, 715, 12, 298, 585, 582, 6385, 93, 288, 372, 754, 398, 372, 2420, 15185, 471, 582, 756, 12, 298, 585, 582, 6385, 93, 339, 768, 4639, 272, 347, 8044, 63, 1450, 71, 780, 8, 5125, 12, 1083, 534, 2970, 735, 267, 408, 267, 6668, 15538, 402, 282, 1627, 19834, 15, 1027, 15, 2193, 402, 5932, 267, 283, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 1450, 31, 498, 29, 1116, 6, 505, 29, 29574, 11, 6843, 11, 2384, 11, 2398, 338, 1326, 11, 47, 2470, 391, 11, 21849, 11, 384, 11, 65, 11, 7241, 11, 13799, 7, 267, 520, 635, 6707, 26, 314, 1318, 370, 19897, 465, 282, 3696, 334, 66, 1159, 1232, 358, 267, 520, 1107, 26, 2600, 543, 6511, 4840, 687, 1177, 267, 408, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 1450, 2, 267, 327, 870, 8, 5125, 9, 267, 340, 620, 8, 5125, 9, 508, 283, 403, 356, 288, 372, 2420, 3954, 582, 900, 14, 521, 1062, 298, 521, 582, 378, 12, 298, 1246, 582, 298, 1450, 401, 298, 11270, 582, 990, 298, 4159, 582, 298, 287, 3570, 267, 1862, 275, 469, 288, 298, 498, 582, 2986, 63, 498, 12, 288, 298, 505, 582, 6707, 12, 288, 298, 2613, 63, 8906, 582, 715, 12, 288, 298, 2613, 63, 6198, 582, 715, 12, 288, 298, 2613, 63, 452, 63, 15185, 83, 582, 715, 267, 789, 267, 340, 1083, 508, 283, 2970, 356, 288, 1166, 275, 6037, 435, 15539, 435, 4011, 14, 10738, 8, 1162, 9, 288, 666, 275, 488, 267, 327, 870, 8, 633, 9, 267, 916, 1083, 508, 283, 4030, 356, 288, 1166, 275, 6037, 288, 666, 275, 1862, 267, 587, 26, 288, 746, 8857, 2017, 360, 14270, 63, 1450, 71, 780, 837, 30801, 3101, 5444, 66, 358, 398, 2058, 275, 2420, 3954, 582, 900, 14, 521, 1062, 298, 521, 582, 378, 12, 298, 1246, 582, 298, 1450, 401, 298, 11270, 582, 990, 298, 4159, 582, 298, 287, 3570, 267, 862, 26, 288, 2058, 275, 8044, 63, 1001, 8, 633, 12, 1083, 29, 765, 12, 666, 29, 576, 9, 267, 871, 334, 1726, 12, 1722, 304, 288, 372, 2058, 398, 340, 298, 2550, 2, 440, 315, 2058, 14, 1612, 342, 503, 2058, 905, 2550, 937, 508, 378, 26, 288, 372, 2058, 398, 746, 8857, 2017, 360, 14270, 63, 1450, 71, 780, 342, 16277, 358, 339, 768, 3744, 272, 347, 295, 750, 8, 1886, 12, 16194, 12, 20234, 29, 403, 12, 1748, 63, 10412, 29, 16, 14, 2260, 304, 267, 408, 267, 22467, 314, 8053, 1352, 1159, 283, 3369, 1958, 3261, 7, 267, 520, 635, 16194, 26, 282, 1059, 626, 365, 336, 29386, 2538, 503, 282, 769, 402, 16194, 267, 520, 635, 20234, 26, 282, 1059, 626, 365, 336, 29386, 2538, 503, 282, 769, 402, 16194, 267, 520, 635, 1748, 63, 10412, 26, 314, 7481, 17908, 370, 2457, 314, 5850, 267, 520, 1107, 26, 282, 769, 402, 2058, 2251, 543, 298, 3369, 2, 690, 1748, 63, 10412, 267, 408, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 3369, 2, 267, 340, 20234, 365, 488, 26, 288, 20234, 275, 843, 14, 1107, 63, 2268, 63, 14129, 342, 398, 1862, 275, 469, 288, 298, 498, 582, 2986 ]
[ 199, 3, 437, 5678, 3261, 370, 1827, 8053, 1352, 14880, 1893, 8500, 199, 3, 199, 199, 363, 2502, 363, 275, 788, 320, 828, 18070, 418, 421, 199, 646, 900, 199, 504, 10933, 492, 10933, 199, 646, 4011, 199, 646, 4011, 18, 199, 199, 504, 289, 1983, 1192, 14, 1450, 278, 1246, 14, 4731, 14, 1612, 492, 372, 63, 1246, 63, 498, 199, 504, 289, 1983, 1192, 14, 2537, 492, 8044, 63, 1001, 199, 199, 1246, 63, 498, 275, 372, 63, 1246, 63, 498, 342, 421, 199, 533, 8053, 1352, 3167, 26, 272, 408, 272, 22493, 3102, 626, 1475, 4153, 436, 5267, 314, 1415, 666, 687, 314, 2435, 272, 5620, 777, 272, 408, 339, 768, 4639, 272, 347, 372, 63, 2268, 63, 14129, 837, 267, 372, 788, 33, 281, 17601, 297, 283, 33, 24627, 24724, 297, 283, 26253, 15003, 63, 803, 297, 283, 7643, 28807, 297, 283, 7643, 32342, 297, 283, 33, 433, 265, 2932, 297, 298, 3110, 63, 460, 63, 2785, 401, 355, 298, 4240, 380, 1786, 401, 283, 33, 495, 15222, 2652, 63, 785, 297, 283, 33, 495, 17293, 297, 283, 33, 5958, 4800, 297, 283, 1271, 573, 14980, 297, 355, 298, 19617, 5360, 401, 298, 16065, 63, 24148, 401, 298, 51, 24779, 401, 298, 7643, 28807, 401, 298, 6678, 17378, 401, 355, 298, 46, 1179, 33, 401, 298, 13375, 386, 695, 63, 9907, 4894, 937, 339, 768, 4639, 272, 347, 1104, 63, 15185, 1337, 8, 505, 304, 267, 408, 267, 8360, 357, 336, 29386, 6941, 315, 282, 1627, 1318, 267, 283, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 15185, 31, 498, 29, 1116, 6, 505, 29, 29574, 11, 6843, 11, 2384, 11, 2398, 338, 1326, 11, 47, 2470, 391, 11, 21849, 11, 384, 11, 65, 11, 7241, 11, 13799, 7, 267, 520, 635, 1318, 26, 314, 1318, 370, 19897, 267, 520, 1107, 26, 2600, 543, 282, 3305, 1245, 661, 15185, 471, 358, 436, 282, 6511, 4840, 687, 1177, 661, 585, 358, 267, 408, 267, 492, 2022, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 15185, 2, 398, 2396, 275, 620, 8, 505, 14, 2143, 360, 4371, 297, 283, 1814, 1333, 398, 1862, 275, 469, 288, 298, 498, 582, 2986, 63, 498, 12, 288, 298, 505, 582, 2396, 267, 789, 267, 1166, 275, 6037, 435, 15539, 435, 4011, 14, 10738, 8, 1162, 9, 267, 862, 26, 288, 6385, 275, 2022, 14, 3640, 8, 4078, 18, 14, 10890, 8, 633, 680, 739, 1012, 267, 871, 334, 1726, 12, 18965, 304, 288, 870, 480, 28375, 28375, 28375, 1140, 6071, 12539, 1306, 28375, 6071, 401, 1318, 9, 288, 372, 2420, 15185, 471, 582, 756, 12, 298, 585, 582, 488, 93, 398, 340, 822, 8, 5934, 905, 15185, 83, 3135, 1137, 378, 26, 288, 754, 275, 2420, 15185, 471, 582, 715, 12, 298, 585, 582, 6385, 93, 288, 372, 754, 398, 372, 2420, 15185, 471, 582, 756, 12, 298, 585, 582, 6385, 93, 339, 768, 4639, 272, 347, 8044, 63, 1450, 71, 780, 8, 5125, 12, 1083, 534, 2970, 735, 267, 408, 267, 6668, 15538, 402, 282, 1627, 19834, 15, 1027, 15, 2193, 402, 5932, 267, 283, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 1450, 31, 498, 29, 1116, 6, 505, 29, 29574, 11, 6843, 11, 2384, 11, 2398, 338, 1326, 11, 47, 2470, 391, 11, 21849, 11, 384, 11, 65, 11, 7241, 11, 13799, 7, 267, 520, 635, 6707, 26, 314, 1318, 370, 19897, 465, 282, 3696, 334, 66, 1159, 1232, 358, 267, 520, 1107, 26, 2600, 543, 6511, 4840, 687, 1177, 267, 408, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 1450, 2, 267, 327, 870, 8, 5125, 9, 267, 340, 620, 8, 5125, 9, 508, 283, 403, 356, 288, 372, 2420, 3954, 582, 900, 14, 521, 1062, 298, 521, 582, 378, 12, 298, 1246, 582, 298, 1450, 401, 298, 11270, 582, 990, 298, 4159, 582, 298, 287, 3570, 267, 1862, 275, 469, 288, 298, 498, 582, 2986, 63, 498, 12, 288, 298, 505, 582, 6707, 12, 288, 298, 2613, 63, 8906, 582, 715, 12, 288, 298, 2613, 63, 6198, 582, 715, 12, 288, 298, 2613, 63, 452, 63, 15185, 83, 582, 715, 267, 789, 267, 340, 1083, 508, 283, 2970, 356, 288, 1166, 275, 6037, 435, 15539, 435, 4011, 14, 10738, 8, 1162, 9, 288, 666, 275, 488, 267, 327, 870, 8, 633, 9, 267, 916, 1083, 508, 283, 4030, 356, 288, 1166, 275, 6037, 288, 666, 275, 1862, 267, 587, 26, 288, 746, 8857, 2017, 360, 14270, 63, 1450, 71, 780, 837, 30801, 3101, 5444, 66, 358, 398, 2058, 275, 2420, 3954, 582, 900, 14, 521, 1062, 298, 521, 582, 378, 12, 298, 1246, 582, 298, 1450, 401, 298, 11270, 582, 990, 298, 4159, 582, 298, 287, 3570, 267, 862, 26, 288, 2058, 275, 8044, 63, 1001, 8, 633, 12, 1083, 29, 765, 12, 666, 29, 576, 9, 267, 871, 334, 1726, 12, 1722, 304, 288, 372, 2058, 398, 340, 298, 2550, 2, 440, 315, 2058, 14, 1612, 342, 503, 2058, 905, 2550, 937, 508, 378, 26, 288, 372, 2058, 398, 746, 8857, 2017, 360, 14270, 63, 1450, 71, 780, 342, 16277, 358, 339, 768, 3744, 272, 347, 295, 750, 8, 1886, 12, 16194, 12, 20234, 29, 403, 12, 1748, 63, 10412, 29, 16, 14, 2260, 304, 267, 408, 267, 22467, 314, 8053, 1352, 1159, 283, 3369, 1958, 3261, 7, 267, 520, 635, 16194, 26, 282, 1059, 626, 365, 336, 29386, 2538, 503, 282, 769, 402, 16194, 267, 520, 635, 20234, 26, 282, 1059, 626, 365, 336, 29386, 2538, 503, 282, 769, 402, 16194, 267, 520, 635, 1748, 63, 10412, 26, 314, 7481, 17908, 370, 2457, 314, 5850, 267, 520, 1107, 26, 282, 769, 402, 2058, 2251, 543, 298, 3369, 2, 690, 1748, 63, 10412, 267, 408, 267, 6037, 275, 298, 1014, 921, 1450, 278, 14, 328, 14, 324, 711, 73, 14, 390, 15, 3369, 2, 267, 340, 20234, 365, 488, 26, 288, 20234, 275, 843, 14, 1107, 63, 2268, 63, 14129, 342, 398, 1862, 275, 469, 288, 298, 498, 582, 2986, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
cherry-hyx/divio-django-cms
cms/management/commands/subcommands/list.py
43
3281
# -*- coding: utf-8 -*- from cms.management.commands.subcommands.base import SubcommandsCommand from cms.models import Page from cms.models.pluginmodel import CMSPlugin from cms.plugin_pool import plugin_pool from django.core.management.base import NoArgsCommand class ListApphooksCommand(NoArgsCommand): help = 'Lists all apphooks in pages' def handle_noargs(self, **options): urls = Page.objects.filter(application_urls__gt='').values_list("application_urls", flat=True) for url in urls: self.stdout.write(u'%s\n' % url) def plugin_report(): # structure of report: # [ # { # 'type': CMSPlugin class, # 'model': plugin_type.model, # 'instances': instances in the CMSPlugin table, # 'unsaved_instances': those with no corresponding model instance, # }, # ] plugin_report = [] all_plugins = CMSPlugin.objects.order_by("plugin_type") plugin_types = list(set(all_plugins.values_list("plugin_type", flat=True))) plugin_types.sort() for plugin_type in plugin_types: plugin = {} plugin["type"] = plugin_type try: # get all plugins of this type plugins = CMSPlugin.objects.filter(plugin_type=plugin_type) plugin["instances"] = plugins # does this plugin have a model? report unsaved instances plugin["model"] = plugin_pool.get_plugin(name=plugin_type).model unsaved_instances = [p for p in plugins if not p.get_plugin_instance()[0]] plugin["unsaved_instances"] = unsaved_instances # catch uninstalled plugins except KeyError: plugin["model"] = None plugin["instances"] = plugins plugin["unsaved_instances"] = [] plugin_report.append(plugin) return plugin_report class ListPluginsCommand(NoArgsCommand): help = 'Lists all plugins in CMSPlugin' def handle_noargs(self, **options): self.stdout.write(u"==== Plugin report ==== \n\n") self.stdout.write(u"There are %s plugin types in your database \n" % len(plugin_report())) for plugin in plugin_report(): self.stdout.write(u"\n%s \n" % plugin["type"]) plugin_model = plugin["model"] instances = len(plugin["instances"]) unsaved_instances = len(plugin["unsaved_instances"]) if not plugin_model: self.stdout.write(self.style.ERROR(" ERROR : not installed \n")) elif plugin_model == CMSPlugin: self.stdout.write(u" model-less plugin \n") self.stdout.write(u" unsaved instance(s) : %s \n" % unsaved_instances) else: self.stdout.write(u" model : %s.%s \n" % (plugin_model.__module__, plugin_model.__name__)) if unsaved_instances: self.stdout.write(self.style.ERROR(" ERROR : %s unsaved instance(s) \n" % unsaved_instances)) self.stdout.write(u" instance(s): %s \n" % instances) class ListCommand(SubcommandsCommand): help = 'List commands' subcommands = { 'apphooks': ListApphooksCommand, 'plugins': ListPluginsCommand }
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 19240, 14, 8110, 14, 4405, 14, 954, 4405, 14, 1095, 492, 4804, 4405, 3110, 199, 504, 19240, 14, 992, 492, 10331, 199, 504, 19240, 14, 992, 14, 2718, 1238, 492, 29554, 5061, 199, 504, 19240, 14, 2718, 63, 2293, 492, 3589, 63, 2293, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 199, 533, 3820, 2640, 7922, 3110, 8, 27099, 3110, 304, 339, 1720, 275, 283, 15116, 1006, 1145, 7922, 315, 6497, 7, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 267, 8187, 275, 10331, 14, 1462, 14, 1541, 8, 3578, 63, 3603, 363, 3308, 534, 1959, 1459, 63, 513, 480, 3578, 63, 3603, 401, 6829, 29, 549, 9, 267, 367, 1166, 315, 8187, 26, 288, 291, 14, 2703, 14, 952, 8, 85, 5956, 83, 60, 78, 7, 450, 1166, 9, 199, 199, 318, 3589, 63, 3070, 837, 272, 327, 5523, 402, 3622, 26, 272, 327, 359, 272, 327, 258, 469, 272, 327, 260, 283, 466, 356, 29554, 5061, 1021, 12, 272, 327, 260, 283, 1238, 356, 3589, 63, 466, 14, 1238, 12, 272, 327, 260, 283, 5990, 356, 4454, 315, 314, 29554, 5061, 1817, 12, 272, 327, 260, 283, 324, 8420, 63, 5990, 356, 5204, 543, 949, 5226, 1402, 1256, 12, 272, 327, 258, 1660, 272, 327, 1622, 272, 3589, 63, 3070, 275, 942, 272, 1006, 63, 5265, 275, 29554, 5061, 14, 1462, 14, 1648, 63, 991, 480, 2718, 63, 466, 531, 272, 3589, 63, 1313, 275, 769, 8, 409, 8, 452, 63, 5265, 14, 1459, 63, 513, 480, 2718, 63, 466, 401, 6829, 29, 549, 1724, 272, 3589, 63, 1313, 14, 3191, 342, 339, 367, 3589, 63, 466, 315, 3589, 63, 1313, 26, 267, 3589, 275, 1052, 267, 3589, 905, 466, 937, 275, 3589, 63, 466, 267, 862, 26, 288, 327, 664, 1006, 8963, 402, 642, 730, 288, 8963, 275, 29554, 5061, 14, 1462, 14, 1541, 8, 2718, 63, 466, 29, 2718, 63, 466, 9, 288, 3589, 905, 5990, 937, 275, 8963, 288, 327, 1630, 642, 3589, 1172, 282, 1402, 31, 3622, 625, 8420, 4454, 288, 3589, 905, 1238, 937, 275, 3589, 63, 2293, 14, 362, 63, 2718, 8, 354, 29, 2718, 63, 466, 680, 1238, 288, 625, 8420, 63, 5990, 275, 359, 80, 367, 299, 315, 8963, 340, 440, 299, 14, 362, 63, 2718, 63, 842, 3430, 16, 2677, 288, 3589, 905, 324, 8420, 63, 5990, 937, 275, 625, 8420, 63, 5990, 398, 327, 8579, 625, 7657, 8963, 267, 871, 4067, 26, 288, 3589, 905, 1238, 937, 275, 488, 288, 3589, 905, 5990, 937, 275, 8963, 288, 3589, 905, 324, 8420, 63, 5990, 937, 275, 942, 398, 3589, 63, 3070, 14, 740, 8, 2718, 9, 339, 372, 3589, 63, 3070, 4388, 199, 533, 3820, 19330, 3110, 8, 27099, 3110, 304, 339, 1720, 275, 283, 15116, 1006, 8963, 315, 29554, 5061, 7, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 267, 291, 14, 2703, 14, 952, 8, 85, 2, 532, 11349, 3622, 275, 5918, 971, 78, 60, 78, 531, 267, 291, 14, 2703, 14, 952, 8, 85, 2, 10924, 787, 450, 83, 3589, 2943, 315, 2195, 3050, 971, 78, 2, 450, 822, 8, 2718, 63, 3070, 4059, 267, 367, 3589, 315, 3589, 63, 3070, 837, 288, 291, 14, 2703, 14, 952, 8, 85, 3212, 78, 5, 83, 971, 78, 2, 450, 3589, 905, 466, 3135, 953, 3589, 63, 1238, 275, 3589, 905, 1238, 937, 288, 4454, 275, 822, 8, 2718, 905, 5990, 3135, 288, 625, 8420, 63, 5990, 275, 822, 8, 2718, 905, 324, 8420, 63, 5990, 3135, 953, 340, 440, 3589, 63, 1238, 26, 355, 291, 14, 2703, 14, 952, 8, 277, 14, 2487, 14, 3170, 480, 221, 12539, 420, 520, 440, 4903, 971, 78, 2237, 953, 916, 3589, 63, 1238, 508, 29554, 5061, 26, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 259, 1402, 13, 2003, 3589, 971, 78, 531, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 259, 625, 8420, 1256, 8, 83, 9, 520, 450, 83, 221, 971, 78, 2, 450, 625, 8420, 63, 5990, 9, 953, 587, 26, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 221, 1402, 420, 520, 450, 83, 4111, 83, 221, 971, 78, 2, 450, 490, 334, 2718, 63, 1238, 855, 578, 3108, 3589, 63, 1238, 855, 354, 8964, 355, 340, 625, 8420, 63, 5990, 26, 490, 291, 14, 2703, 14, 952, 8, 277, 14, 2487, 14, 3170, 480, 221, 12539, 420, 520, 450, 83, 625, 8420, 1256, 8, 83, 9, 971, 78, 2, 450, 625, 8420, 63, 5990, 430, 953, 291, 14, 2703, 14, 952, 8, 85, 2, 221, 1256, 8, 83, 304, 450, 83, 971, 78, 2, 450, 4454, 9, 421, 199, 533, 3820, 3110, 8, 2610, 4405, 3110, 304, 272, 1720, 275, 283, 1296, 3718, 7, 272, 1007, 4405, 275, 469, 267, 283, 571, 7922, 356, 3820, 2640, 7922, 3110, 12, 267, 283, 5265, 356, 3820, 19330, 3110, 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 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 19240, 14, 8110, 14, 4405, 14, 954, 4405, 14, 1095, 492, 4804, 4405, 3110, 199, 504, 19240, 14, 992, 492, 10331, 199, 504, 19240, 14, 992, 14, 2718, 1238, 492, 29554, 5061, 199, 504, 19240, 14, 2718, 63, 2293, 492, 3589, 63, 2293, 199, 504, 1639, 14, 1018, 14, 8110, 14, 1095, 492, 3091, 6213, 3110, 199, 199, 533, 3820, 2640, 7922, 3110, 8, 27099, 3110, 304, 339, 1720, 275, 283, 15116, 1006, 1145, 7922, 315, 6497, 7, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 267, 8187, 275, 10331, 14, 1462, 14, 1541, 8, 3578, 63, 3603, 363, 3308, 534, 1959, 1459, 63, 513, 480, 3578, 63, 3603, 401, 6829, 29, 549, 9, 267, 367, 1166, 315, 8187, 26, 288, 291, 14, 2703, 14, 952, 8, 85, 5956, 83, 60, 78, 7, 450, 1166, 9, 199, 199, 318, 3589, 63, 3070, 837, 272, 327, 5523, 402, 3622, 26, 272, 327, 359, 272, 327, 258, 469, 272, 327, 260, 283, 466, 356, 29554, 5061, 1021, 12, 272, 327, 260, 283, 1238, 356, 3589, 63, 466, 14, 1238, 12, 272, 327, 260, 283, 5990, 356, 4454, 315, 314, 29554, 5061, 1817, 12, 272, 327, 260, 283, 324, 8420, 63, 5990, 356, 5204, 543, 949, 5226, 1402, 1256, 12, 272, 327, 258, 1660, 272, 327, 1622, 272, 3589, 63, 3070, 275, 942, 272, 1006, 63, 5265, 275, 29554, 5061, 14, 1462, 14, 1648, 63, 991, 480, 2718, 63, 466, 531, 272, 3589, 63, 1313, 275, 769, 8, 409, 8, 452, 63, 5265, 14, 1459, 63, 513, 480, 2718, 63, 466, 401, 6829, 29, 549, 1724, 272, 3589, 63, 1313, 14, 3191, 342, 339, 367, 3589, 63, 466, 315, 3589, 63, 1313, 26, 267, 3589, 275, 1052, 267, 3589, 905, 466, 937, 275, 3589, 63, 466, 267, 862, 26, 288, 327, 664, 1006, 8963, 402, 642, 730, 288, 8963, 275, 29554, 5061, 14, 1462, 14, 1541, 8, 2718, 63, 466, 29, 2718, 63, 466, 9, 288, 3589, 905, 5990, 937, 275, 8963, 288, 327, 1630, 642, 3589, 1172, 282, 1402, 31, 3622, 625, 8420, 4454, 288, 3589, 905, 1238, 937, 275, 3589, 63, 2293, 14, 362, 63, 2718, 8, 354, 29, 2718, 63, 466, 680, 1238, 288, 625, 8420, 63, 5990, 275, 359, 80, 367, 299, 315, 8963, 340, 440, 299, 14, 362, 63, 2718, 63, 842, 3430, 16, 2677, 288, 3589, 905, 324, 8420, 63, 5990, 937, 275, 625, 8420, 63, 5990, 398, 327, 8579, 625, 7657, 8963, 267, 871, 4067, 26, 288, 3589, 905, 1238, 937, 275, 488, 288, 3589, 905, 5990, 937, 275, 8963, 288, 3589, 905, 324, 8420, 63, 5990, 937, 275, 942, 398, 3589, 63, 3070, 14, 740, 8, 2718, 9, 339, 372, 3589, 63, 3070, 4388, 199, 533, 3820, 19330, 3110, 8, 27099, 3110, 304, 339, 1720, 275, 283, 15116, 1006, 8963, 315, 29554, 5061, 7, 272, 347, 2429, 63, 889, 589, 8, 277, 12, 1011, 1419, 304, 267, 291, 14, 2703, 14, 952, 8, 85, 2, 532, 11349, 3622, 275, 5918, 971, 78, 60, 78, 531, 267, 291, 14, 2703, 14, 952, 8, 85, 2, 10924, 787, 450, 83, 3589, 2943, 315, 2195, 3050, 971, 78, 2, 450, 822, 8, 2718, 63, 3070, 4059, 267, 367, 3589, 315, 3589, 63, 3070, 837, 288, 291, 14, 2703, 14, 952, 8, 85, 3212, 78, 5, 83, 971, 78, 2, 450, 3589, 905, 466, 3135, 953, 3589, 63, 1238, 275, 3589, 905, 1238, 937, 288, 4454, 275, 822, 8, 2718, 905, 5990, 3135, 288, 625, 8420, 63, 5990, 275, 822, 8, 2718, 905, 324, 8420, 63, 5990, 3135, 953, 340, 440, 3589, 63, 1238, 26, 355, 291, 14, 2703, 14, 952, 8, 277, 14, 2487, 14, 3170, 480, 221, 12539, 420, 520, 440, 4903, 971, 78, 2237, 953, 916, 3589, 63, 1238, 508, 29554, 5061, 26, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 259, 1402, 13, 2003, 3589, 971, 78, 531, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 259, 625, 8420, 1256, 8, 83, 9, 520, 450, 83, 221, 971, 78, 2, 450, 625, 8420, 63, 5990, 9, 953, 587, 26, 355, 291, 14, 2703, 14, 952, 8, 85, 2, 221, 1402, 420, 520, 450, 83, 4111, 83, 221, 971, 78, 2, 450, 490, 334, 2718, 63, 1238, 855, 578, 3108, 3589, 63, 1238, 855, 354, 8964, 355, 340, 625, 8420, 63, 5990, 26, 490, 291, 14, 2703, 14, 952, 8, 277, 14, 2487, 14, 3170, 480, 221, 12539, 420, 520, 450, 83, 625, 8420, 1256, 8, 83, 9, 971, 78, 2, 450, 625, 8420, 63, 5990, 430, 953, 291, 14, 2703, 14, 952, 8, 85, 2, 221, 1256, 8, 83, 304, 450, 83, 971, 78, 2, 450, 4454, 9, 421, 199, 533, 3820, 3110, 8, 2610, 4405, 3110, 304, 272, 1720, 275, 283, 1296, 3718, 7, 272, 1007, 4405, 275, 469, 267, 283, 571, 7922, 356, 3820, 2640, 7922, 3110, 12, 267, 283, 5265, 356, 3820, 19330, 3110, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
badloop/SickRage
sickbeard/tvcache.py
2
14587
# Author: Nic Wolfe <nic@wolfeden.ca> # URL: http://code.google.com/p/sickbeard/ # # This file is part of SickRage. # # SickRage 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. # # SickRage 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 SickRage. If not, see <http://www.gnu.org/licenses/>. import time import datetime import itertools import urllib2 import sickbeard from sickbeard import db from sickbeard import logger from sickbeard import helpers from sickbeard.common import Quality from sickbeard.rssfeeds import getFeed from sickbeard import show_name_helpers from sickrage.helper.encoding import ss from sickrage.helper.exceptions import AuthException, ex from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException class CacheDBConnection(db.DBConnection): def __init__(self, providerName): db.DBConnection.__init__(self, "cache.db") # Create the table if it's not already there try: if not self.hasTable(providerName): self.action( "CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT, release_group TEXT)") else: sqlResults = self.select("SELECT url, COUNT(url) AS count FROM [" + providerName + "] GROUP BY url HAVING count > 1") for cur_dupe in sqlResults: self.action("DELETE FROM [" + providerName + "] WHERE url = ?", [cur_dupe["url"]]) # add unique index to prevent further dupes from happening if one does not exist self.action("CREATE UNIQUE INDEX IF NOT EXISTS idx_url ON [" + providerName + "] (url)") # add release_group column to table if missing if not self.hasColumn(providerName, 'release_group'): self.addColumn(providerName, 'release_group', "TEXT", "") # add version column to table if missing if not self.hasColumn(providerName, 'version'): self.addColumn(providerName, 'version', "NUMERIC", "-1") except Exception, e: if str(e) != "table [" + providerName + "] already exists": raise # Create the table if it's not already there try: if not self.hasTable('lastUpdate'): self.action("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC)") except Exception, e: if str(e) != "table lastUpdate already exists": raise class TVCache(object): def __init__(self, provider): self.provider = provider self.providerID = self.provider.getID() self.providerDB = None self.minTime = 10 def _getDB(self): # init provider database if not done already if not self.providerDB: self.providerDB = CacheDBConnection(self.providerID) return self.providerDB def _clearCache(self): if self.shouldClearCache(): myDB = self._getDB() myDB.action("DELETE FROM [" + self.providerID + "] WHERE 1") def _get_title_and_url(self, item): return self.provider._get_title_and_url(item) def _getRSSData(self): return None def _checkAuth(self, data): return True def _checkItemAuth(self, title, url): return True def updateCache(self): # check if we should update if not self.shouldUpdate(): return try: data = self._getRSSData() if self._checkAuth(data): # clear cache self._clearCache() # set updated self.setLastUpdate() cl = [] for item in data['entries'] or []: ci = self._parseItem(item) if ci is not None: cl.append(ci) if len(cl) > 0: myDB = self._getDB() myDB.mass_action(cl) except AuthException, e: logger.log(u"Authentication error: " + ex(e), logger.ERROR) except Exception, e: logger.log(u"Error while searching " + self.provider.name + ", skipping: " + repr(e), logger.DEBUG) def getRSSFeed(self, url): handlers = [] if sickbeard.PROXY_SETTING: logger.log(u"Using global proxy for url: " + url, logger.DEBUG) scheme, address = urllib2.splittype(sickbeard.PROXY_SETTING) address = sickbeard.PROXY_SETTING if scheme else 'http://' + sickbeard.PROXY_SETTING handlers = [urllib2.ProxyHandler({'http': address, 'https': address})] self.provider.headers.update({'Referer': address}) elif 'Referer' in self.provider.headers: self.provider.headers.pop('Referer') return getFeed( url, request_headers=self.provider.headers, handlers=handlers) def _translateTitle(self, title): return u'' + title.replace(' ', '.') def _translateLinkURL(self, url): return url.replace('&amp;', '&') def _parseItem(self, item): title, url = self._get_title_and_url(item) self._checkItemAuth(title, url) if title and url: title = self._translateTitle(title) url = self._translateLinkURL(url) logger.log(u"Attempting to add item to cache: " + title, logger.DEBUG) return self._addCacheEntry(title, url) else: logger.log( u"The data returned from the " + self.provider.name + " feed is incomplete, this result is unusable", logger.DEBUG) return False def _getLastUpdate(self): myDB = self._getDB() sqlResults = myDB.select("SELECT time FROM lastUpdate WHERE provider = ?", [self.providerID]) if sqlResults: lastTime = int(sqlResults[0]["time"]) if lastTime > int(time.mktime(datetime.datetime.today().timetuple())): lastTime = 0 else: lastTime = 0 return datetime.datetime.fromtimestamp(lastTime) def _getLastSearch(self): myDB = self._getDB() sqlResults = myDB.select("SELECT time FROM lastSearch WHERE provider = ?", [self.providerID]) if sqlResults: lastTime = int(sqlResults[0]["time"]) if lastTime > int(time.mktime(datetime.datetime.today().timetuple())): lastTime = 0 else: lastTime = 0 return datetime.datetime.fromtimestamp(lastTime) def setLastUpdate(self, toDate=None): if not toDate: toDate = datetime.datetime.today() myDB = self._getDB() myDB.upsert("lastUpdate", {'time': int(time.mktime(toDate.timetuple()))}, {'provider': self.providerID}) def setLastSearch(self, toDate=None): if not toDate: toDate = datetime.datetime.today() myDB = self._getDB() myDB.upsert("lastSearch", {'time': int(time.mktime(toDate.timetuple()))}, {'provider': self.providerID}) lastUpdate = property(_getLastUpdate) lastSearch = property(_getLastSearch) def shouldUpdate(self): # if we've updated recently then skip the update if datetime.datetime.today() - self.lastUpdate < datetime.timedelta(minutes=self.minTime): logger.log(u"Last update was too soon, using old cache: " + str(self.lastUpdate) + ". Updated less then " + str(self.minTime) + " minutes ago", logger.DEBUG) return False return True def shouldClearCache(self): # if daily search hasn't used our previous results yet then don't clear the cache if self.lastUpdate > self.lastSearch: return False return True def _addCacheEntry(self, name, url, parse_result=None, indexer_id=0): # check if we passed in a parsed result or should we try and create one if not parse_result: # create showObj from indexer_id if available showObj = None if indexer_id: showObj = helpers.findCertainShow(sickbeard.showList, indexer_id) try: myParser = NameParser(showObj=showObj) parse_result = myParser.parse(name) except InvalidNameException: logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG) return None except InvalidShowException: logger.log(u"Unable to parse the filename " + name + " into a valid show", logger.DEBUG) return None if not parse_result or not parse_result.series_name: return None # if we made it this far then lets add the parsed result to cache for usager later on season = parse_result.season_number if parse_result.season_number else 1 episodes = parse_result.episode_numbers if season and episodes: # store episodes as a seperated string episodeText = "|" + "|".join(map(str, episodes)) + "|" # get the current timestamp curTimestamp = int(time.mktime(datetime.datetime.today().timetuple())) # get quality of release quality = parse_result.quality name = ss(name) # get release group release_group = parse_result.release_group # get version version = parse_result.version logger.log(u"Added RSS item: [" + name + "] to cache: [" + self.providerID + "]", logger.DEBUG) return [ "INSERT OR IGNORE INTO [" + self.providerID + "] (name, season, episodes, indexerid, url, time, quality, release_group, version) VALUES (?,?,?,?,?,?,?,?,?)", [name, season, episodeText, parse_result.show.indexerid, url, curTimestamp, quality, release_group, version]] def searchCache(self, episode, manualSearch=False, downCurQuality=False): neededEps = self.findNeededEpisodes(episode, manualSearch, downCurQuality) return neededEps[episode] if episode in neededEps else [] def listPropers(self, date=None): myDB = self._getDB() sql = "SELECT * FROM [" + self.providerID + "] WHERE name LIKE '%.PROPER.%' OR name LIKE '%.REPACK.%'" if date != None: sql += " AND time >= " + str(int(time.mktime(date.timetuple()))) propers_results = myDB.select(sql) return [x for x in propers_results if x['indexerid']] def findNeededEpisodes(self, episode, manualSearch=False, downCurQuality=False): neededEps = {} cl = [] myDB = self._getDB() if not episode: sqlResults = myDB.select("SELECT * FROM [" + self.providerID + "]") elif type(episode) != list: sqlResults = myDB.select( "SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ?", [episode.show.indexerid, episode.season, "%|" + str(episode.episode) + "|%"]) else: for epObj in episode: cl.append([ "SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? AND quality IN (" + ",".join( [str(x) for x in epObj.wantedQuality]) + ")", [epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"]]) sqlResults = myDB.mass_action(cl, fetchall=True) sqlResults = list(itertools.chain(*sqlResults)) # for each cache entry for curResult in sqlResults: # ignored/required words, and non-tv junk if not show_name_helpers.filterBadReleases(curResult["name"]): continue # get the show object, or if it's not one of our shows then ignore it showObj = helpers.findCertainShow(sickbeard.showList, int(curResult["indexerid"])) if not showObj: continue # skip if provider is anime only and show is not anime if self.provider.anime_only and not showObj.is_anime: logger.log(u"" + str(showObj.name) + " is not an anime, skiping", logger.DEBUG) continue # get season and ep data (ignoring multi-eps for now) curSeason = int(curResult["season"]) if curSeason == -1: continue curEp = curResult["episodes"].split("|")[1] if not curEp: continue curEp = int(curEp) curQuality = int(curResult["quality"]) curReleaseGroup = curResult["release_group"] curVersion = curResult["version"] # if the show says we want that episode then add it to the list if not showObj.wantEpisode(curSeason, curEp, curQuality, manualSearch, downCurQuality): logger.log(u"Skipping " + curResult["name"] + " because we don't want an episode that's " + Quality.qualityStrings[curQuality], logger.INFO) continue epObj = showObj.getEpisode(curSeason, curEp) # build a result object title = curResult["name"] url = curResult["url"] logger.log(u"Found result " + title + " at " + url) result = self.provider.getResult([epObj]) result.show = showObj result.url = url result.name = title result.quality = curQuality result.release_group = curReleaseGroup result.version = curVersion result.content = None # add it to the list if epObj not in neededEps: neededEps[epObj] = [result] else: neededEps[epObj].append(result) # datetime stamp this search so cache gets cleared self.setLastSearch() return neededEps
gpl-3.0
[ 3, 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 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, 28964, 31066, 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, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 900, 199, 646, 2197, 199, 646, 7975, 199, 646, 4011, 18, 199, 199, 646, 17898, 199, 504, 17898, 492, 1592, 199, 504, 17898, 492, 2512, 199, 504, 17898, 492, 10897, 199, 504, 17898, 14, 2330, 492, 24108, 199, 504, 17898, 14, 13614, 11522, 492, 664, 7658, 199, 504, 17898, 492, 2498, 63, 354, 63, 7546, 199, 504, 17028, 28812, 14, 3676, 14, 2991, 492, 10110, 199, 504, 17028, 28812, 14, 3676, 14, 3924, 492, 3590, 1726, 12, 444, 199, 504, 17898, 14, 354, 63, 2087, 14, 2087, 492, 2812, 2842, 12, 6378, 985, 1726, 12, 6378, 6824, 1726, 421, 199, 533, 11977, 2846, 3225, 8, 697, 14, 2846, 3225, 304, 272, 347, 636, 826, 721, 277, 12, 5022, 985, 304, 267, 1592, 14, 2846, 3225, 855, 826, 721, 277, 12, 298, 1637, 14, 697, 531, 398, 327, 2790, 314, 1817, 340, 652, 1159, 440, 2575, 2337, 267, 862, 26, 288, 340, 440, 291, 14, 1989, 3186, 8, 3780, 985, 304, 355, 291, 14, 1287, 8, 490, 298, 8366, 9934, 2097, 435, 5022, 985, 435, 32705, 334, 354, 11951, 12, 14718, 31806, 12, 30060, 11951, 12, 23093, 344, 31806, 12, 1166, 11951, 12, 900, 31806, 12, 11030, 11951, 12, 4683, 63, 923, 11951, 6320, 288, 587, 26, 355, 3875, 6579, 275, 291, 14, 2416, 480, 4859, 1166, 12, 24903, 8, 633, 9, 4319, 2338, 4442, 2097, 435, 5022, 985, 435, 32705, 15443, 6515, 1166, 869, 6087, 1206, 2338, 690, 413, 531, 2234, 367, 1094, 63, 30706, 315, 3875, 6579, 26, 490, 291, 14, 1287, 480, 7014, 4442, 2097, 435, 5022, 985, 435, 32705, 6038, 1166, 275, 5805, 401, 359, 895, 63, 30706, 905, 633, 937, 566, 953, 327, 1050, 3747, 1478, 370, 7981, 9848, 15776, 22020, 687, 5992, 316, 340, 1373, 1630, 440, 2187, 288, 291, 14, 1287, 480, 8366, 6778, 41, 10526, 17055, 8036, 2845, 23875, 4280, 63, 633, 5258, 2097, 435, 5022, 985, 435, 32705, 334, 633, 6320, 953, 327, 1050, 4683, 63, 923, 2763, 370, 1817, 340, 4124, 288, 340, 440, 291, 14, 1989, 4547, 8, 3780, 985, 12, 283, 3221, 63, 923, 735, 355, 291, 14, 525, 4547, 8, 3780, 985, 12, 283, 3221, 63, 923, 297, 298, 3876, 401, 6899, 953, 327, 1050, 1015, 2763, 370, 1817, 340, 4124, 288, 340, 440, 291, 14, 1989, 4547, 8, 3780, 985, 12, 283, 1023, 735, 355, 291, 14, 525, 4547, 8, 3780, 985, 12, 283, 1023, 297, 298, 28425, 401, 3905, 17, 531, 398, 871, 2186, 12, 325, 26, 288, 340, 620, 8, 69, 9, 1137, 298, 1224, 2097, 435, 5022, 985, 435, 32705, 2575, 3495, 582, 355, 746, 398, 327, 2790, 314, 1817, 340, 652, 1159, 440, 2575, 2337, 267, 862, 26, 288, 340, 440, 291, 14, 1989, 3186, 360, 2019, 4152, 735, 355, 291, 14, 1287, 480, 8366, 9934, 2061, 4152, 334, 3780, 11951, 12, 900, 31806, 6320, 267, 871, 2186, 12, 325, 26, 288, 340, 620, 8, 69, 9, 1137, 298, 1224, 2061, 4152, 2575, 3495, 582, 355, 746, 421, 199, 533, 26990, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5022, 304, 267, 291, 14, 3780, 275, 5022, 267, 291, 14, 3780, 998, 275, 291, 14, 3780, 14, 362, 998, 342, 267, 291, 14, 3780, 2846, 275, 488, 267, 291, 14, 827, 1366, 275, 1616, 339, 347, 485, 362, 2846, 8, 277, 304, 267, 327, 4205, 5022, 3050, 340, 440, 4224, 2575, 267, 340, 440, 291, 14, 3780, 2846, 26, 288, 291, 14, 3780, 2846, 275, 11977, 2846, 3225, 8, 277, 14, 3780, 998, 9, 398, 372, 291, 14, 3780, 2846, 339, 347, 485, 3584, 4437, 8, 277, 304, 267, 340, 291, 14, 5626, 9721, 4437, 837, 288, 3002, 2846, 275, 291, 423, 362, 2846, 342, 288, 3002, 2846, 14, 1287, 480, 7014, 4442, 2097, 435, 291, 14, 3780, 998, 435, 32705, 6038, 413, 531, 339, 347, 485, 362, 63, 1213, 63, 460, 63, 633, 8, 277, 12, 1242, 304, 267, 372, 291, 14, 3780, 423, 362, 63, 1213, 63, 460, 63, 633, 8, 1053, 9, 339, 347, 485, 362, 22786, 1451, 8, 277, 304, 267, 372, 488, 339, 347, 485, 1074, 2817, 8, 277, 12, 666, 304, 267, 372, 715, 339, 347, 485, 1074, 2081, 2817, 8, 277, 12, 2538, 12, 1166, 304, 267, 372, 715, 339, 347, 1678, 4437, 8, 277, 304, 267, 327, 1104, 340, 781, 1077, 1678, 267, 340, 440, 291, 14, 5626, 4152, 837, 288, 372, 398, 862, 26, 288, 666, 275, 291, 423, 362, 22786, 1451, 342, 288, 340, 291, 423, 1074, 2817, 8, 576, 304, 355, 327, 5436, 2581, 355, 291, 423, 3584, 4437, 342, 2234, 327, 663, 4588, 355, 291, 14, 409, 6090, 4152, 342, 2234, 824, 275, 942, 355, 367, 1242, 315, 666, 459, 3189, 418, 503, 18410, 490, 16279, 275, 291, 423, 1122, 2081, 8, 1053, 9, 490, 340, 16279, 365, 440, 488, 26, 717, 824, 14, 740, 8, 559, 9, 2234, 340, 822, 8, 429, 9, 690, 378, 26, 490, 3002, 2846, 275 ]
[ 6529, 26, 653, 530, 644, 79, 276, 69, 665, 12165, 32, 28070, 69, 848, 14, 696, 30, 199, 3, 2851, 26, 1455, 921, 600, 14, 3098, 14, 957, 15, 80, 15, 32370, 15283, 15, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 28964, 31066, 14, 199, 3, 199, 3, 28964, 31066, 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, 28964, 31066, 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, 28964, 31066, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 900, 199, 646, 2197, 199, 646, 7975, 199, 646, 4011, 18, 199, 199, 646, 17898, 199, 504, 17898, 492, 1592, 199, 504, 17898, 492, 2512, 199, 504, 17898, 492, 10897, 199, 504, 17898, 14, 2330, 492, 24108, 199, 504, 17898, 14, 13614, 11522, 492, 664, 7658, 199, 504, 17898, 492, 2498, 63, 354, 63, 7546, 199, 504, 17028, 28812, 14, 3676, 14, 2991, 492, 10110, 199, 504, 17028, 28812, 14, 3676, 14, 3924, 492, 3590, 1726, 12, 444, 199, 504, 17898, 14, 354, 63, 2087, 14, 2087, 492, 2812, 2842, 12, 6378, 985, 1726, 12, 6378, 6824, 1726, 421, 199, 533, 11977, 2846, 3225, 8, 697, 14, 2846, 3225, 304, 272, 347, 636, 826, 721, 277, 12, 5022, 985, 304, 267, 1592, 14, 2846, 3225, 855, 826, 721, 277, 12, 298, 1637, 14, 697, 531, 398, 327, 2790, 314, 1817, 340, 652, 1159, 440, 2575, 2337, 267, 862, 26, 288, 340, 440, 291, 14, 1989, 3186, 8, 3780, 985, 304, 355, 291, 14, 1287, 8, 490, 298, 8366, 9934, 2097, 435, 5022, 985, 435, 32705, 334, 354, 11951, 12, 14718, 31806, 12, 30060, 11951, 12, 23093, 344, 31806, 12, 1166, 11951, 12, 900, 31806, 12, 11030, 11951, 12, 4683, 63, 923, 11951, 6320, 288, 587, 26, 355, 3875, 6579, 275, 291, 14, 2416, 480, 4859, 1166, 12, 24903, 8, 633, 9, 4319, 2338, 4442, 2097, 435, 5022, 985, 435, 32705, 15443, 6515, 1166, 869, 6087, 1206, 2338, 690, 413, 531, 2234, 367, 1094, 63, 30706, 315, 3875, 6579, 26, 490, 291, 14, 1287, 480, 7014, 4442, 2097, 435, 5022, 985, 435, 32705, 6038, 1166, 275, 5805, 401, 359, 895, 63, 30706, 905, 633, 937, 566, 953, 327, 1050, 3747, 1478, 370, 7981, 9848, 15776, 22020, 687, 5992, 316, 340, 1373, 1630, 440, 2187, 288, 291, 14, 1287, 480, 8366, 6778, 41, 10526, 17055, 8036, 2845, 23875, 4280, 63, 633, 5258, 2097, 435, 5022, 985, 435, 32705, 334, 633, 6320, 953, 327, 1050, 4683, 63, 923, 2763, 370, 1817, 340, 4124, 288, 340, 440, 291, 14, 1989, 4547, 8, 3780, 985, 12, 283, 3221, 63, 923, 735, 355, 291, 14, 525, 4547, 8, 3780, 985, 12, 283, 3221, 63, 923, 297, 298, 3876, 401, 6899, 953, 327, 1050, 1015, 2763, 370, 1817, 340, 4124, 288, 340, 440, 291, 14, 1989, 4547, 8, 3780, 985, 12, 283, 1023, 735, 355, 291, 14, 525, 4547, 8, 3780, 985, 12, 283, 1023, 297, 298, 28425, 401, 3905, 17, 531, 398, 871, 2186, 12, 325, 26, 288, 340, 620, 8, 69, 9, 1137, 298, 1224, 2097, 435, 5022, 985, 435, 32705, 2575, 3495, 582, 355, 746, 398, 327, 2790, 314, 1817, 340, 652, 1159, 440, 2575, 2337, 267, 862, 26, 288, 340, 440, 291, 14, 1989, 3186, 360, 2019, 4152, 735, 355, 291, 14, 1287, 480, 8366, 9934, 2061, 4152, 334, 3780, 11951, 12, 900, 31806, 6320, 267, 871, 2186, 12, 325, 26, 288, 340, 620, 8, 69, 9, 1137, 298, 1224, 2061, 4152, 2575, 3495, 582, 355, 746, 421, 199, 533, 26990, 4437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5022, 304, 267, 291, 14, 3780, 275, 5022, 267, 291, 14, 3780, 998, 275, 291, 14, 3780, 14, 362, 998, 342, 267, 291, 14, 3780, 2846, 275, 488, 267, 291, 14, 827, 1366, 275, 1616, 339, 347, 485, 362, 2846, 8, 277, 304, 267, 327, 4205, 5022, 3050, 340, 440, 4224, 2575, 267, 340, 440, 291, 14, 3780, 2846, 26, 288, 291, 14, 3780, 2846, 275, 11977, 2846, 3225, 8, 277, 14, 3780, 998, 9, 398, 372, 291, 14, 3780, 2846, 339, 347, 485, 3584, 4437, 8, 277, 304, 267, 340, 291, 14, 5626, 9721, 4437, 837, 288, 3002, 2846, 275, 291, 423, 362, 2846, 342, 288, 3002, 2846, 14, 1287, 480, 7014, 4442, 2097, 435, 291, 14, 3780, 998, 435, 32705, 6038, 413, 531, 339, 347, 485, 362, 63, 1213, 63, 460, 63, 633, 8, 277, 12, 1242, 304, 267, 372, 291, 14, 3780, 423, 362, 63, 1213, 63, 460, 63, 633, 8, 1053, 9, 339, 347, 485, 362, 22786, 1451, 8, 277, 304, 267, 372, 488, 339, 347, 485, 1074, 2817, 8, 277, 12, 666, 304, 267, 372, 715, 339, 347, 485, 1074, 2081, 2817, 8, 277, 12, 2538, 12, 1166, 304, 267, 372, 715, 339, 347, 1678, 4437, 8, 277, 304, 267, 327, 1104, 340, 781, 1077, 1678, 267, 340, 440, 291, 14, 5626, 4152, 837, 288, 372, 398, 862, 26, 288, 666, 275, 291, 423, 362, 22786, 1451, 342, 288, 340, 291, 423, 1074, 2817, 8, 576, 304, 355, 327, 5436, 2581, 355, 291, 423, 3584, 4437, 342, 2234, 327, 663, 4588, 355, 291, 14, 409, 6090, 4152, 342, 2234, 824, 275, 942, 355, 367, 1242, 315, 666, 459, 3189, 418, 503, 18410, 490, 16279, 275, 291, 423, 1122, 2081, 8, 1053, 9, 490, 340, 16279, 365, 440, 488, 26, 717, 824, 14, 740, 8, 559, 9, 2234, 340, 822, 8, 429, 9, 690, 378, 26, 490, 3002, 2846, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
alexdzul/propiedades
resty/apps/properties/models.py
1
1066
import os import uuid from django.utils import timezone from django.db import models def image_path_post(self, filename): today = timezone.now() path = "{0}/{1}/{2}/".format(today.year, today.month, today.day) ext = filename.split('.')[-1] my_filename = "{0}.{1}".format(str(uuid.uuid1()).replace('-', ''), ext) url = os.path.join(path, my_filename) return url class House(models.Model): code = models.SlugField(max_length=200, unique=True) name = models.CharField(max_length=200) image = models.ImageField(upload_to=image_path_post, null=True, blank=True) description = models.TextField(max_length=1000, null=True, blank=True) latitude = models.CharField(max_length=100) longitude = models.CharField(max_length=100) price = models.DecimalField(max_digits=10, decimal_places=2, default=0.00) status = models.BooleanField(default=True) def __unicode__(self): return self.name class Meta: app_label = "properties" verbose_name = "Casa" verbose_name_plural = "Casas"
mit
[ 646, 747, 199, 646, 5377, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 318, 1834, 63, 515, 63, 1932, 8, 277, 12, 1788, 304, 272, 11168, 275, 7137, 14, 2131, 342, 272, 931, 275, 5310, 16, 16152, 17, 16152, 18, 5995, 1674, 908, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 9, 272, 1599, 275, 1788, 14, 1294, 29084, 17, 61, 272, 3002, 63, 1501, 275, 5310, 16, 26944, 17, 5469, 908, 8, 495, 8, 2580, 14, 2580, 17, 8801, 1814, 13858, 9929, 1599, 9, 272, 1166, 275, 747, 14, 515, 14, 904, 8, 515, 12, 3002, 63, 1501, 9, 272, 372, 1166, 421, 199, 533, 869, 7130, 8, 992, 14, 1685, 304, 272, 1233, 275, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1840, 12, 3747, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 1834, 275, 1709, 14, 21910, 8, 5064, 63, 475, 29, 1569, 63, 515, 63, 1932, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 6254, 8, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 18896, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 18154, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 12, 849, 29, 16, 14, 383, 9, 272, 2004, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 298, 3282, 2, 267, 3376, 63, 354, 275, 298, 35, 30253, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 35, 305, 305, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 199, 646, 5377, 199, 504, 1639, 14, 1208, 492, 7137, 199, 504, 1639, 14, 697, 492, 1709, 421, 199, 318, 1834, 63, 515, 63, 1932, 8, 277, 12, 1788, 304, 272, 11168, 275, 7137, 14, 2131, 342, 272, 931, 275, 5310, 16, 16152, 17, 16152, 18, 5995, 1674, 908, 8, 8136, 14, 3403, 12, 11168, 14, 4482, 12, 11168, 14, 2977, 9, 272, 1599, 275, 1788, 14, 1294, 29084, 17, 61, 272, 3002, 63, 1501, 275, 5310, 16, 26944, 17, 5469, 908, 8, 495, 8, 2580, 14, 2580, 17, 8801, 1814, 13858, 9929, 1599, 9, 272, 1166, 275, 747, 14, 515, 14, 904, 8, 515, 12, 3002, 63, 1501, 9, 272, 372, 1166, 421, 199, 533, 869, 7130, 8, 992, 14, 1685, 304, 272, 1233, 275, 1709, 14, 17315, 8, 988, 63, 1267, 29, 1840, 12, 3747, 29, 549, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 1834, 275, 1709, 14, 21910, 8, 5064, 63, 475, 29, 1569, 63, 515, 63, 1932, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 6254, 8, 988, 63, 1267, 29, 5279, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 18896, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 18154, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 8033, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 709, 12, 6107, 63, 10696, 29, 18, 12, 849, 29, 16, 14, 383, 9, 272, 2004, 275, 1709, 14, 5036, 8, 885, 29, 549, 9, 339, 347, 636, 2975, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 1145, 63, 1302, 275, 298, 3282, 2, 267, 3376, 63, 354, 275, 298, 35, 30253, 2, 267, 3376, 63, 354, 63, 10019, 275, 298, 35, 305, 305, 2, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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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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 ]
Yangqing/caffe2
caffe2/python/pipeline_test.py
4
3358
# Copyright (c) 2016-present, Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################## from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from caffe2.python.schema import ( Struct, FetchRecord, NewRecord, FeedRecord, InitEmptyRecord) from caffe2.python import core, workspace from caffe2.python.session import LocalSession from caffe2.python.dataset import Dataset from caffe2.python.pipeline import pipe from caffe2.python.queue_util import Queue from caffe2.python.task import TaskGroup from caffe2.python.test_util import TestCase from caffe2.python.net_builder import ops import numpy as np import math class TestPipeline(TestCase): def test_dequeue_many(self): init_net = core.Net('init') N = 17 NUM_DEQUEUE_RECORDS = 3 src_values = Struct( ('uid', np.array(range(N))), ('value', 0.1 * np.array(range(N)))) expected_dst = Struct( ('uid', 2 * np.array(range(N))), ('value', np.array(N * [0.0]))) with core.NameScope('init'): src_blobs = NewRecord(init_net, src_values) dst_blobs = InitEmptyRecord(init_net, src_values.clone_schema()) counter = init_net.Const(0) ONE = init_net.Const(1) def proc1(rec): with core.NameScope('proc1'): out = NewRecord(ops, rec) ops.Add([rec.uid(), rec.uid()], [out.uid()]) out.value.set(blob=rec.value(), unsafe=True) return out def proc2(rec): with core.NameScope('proc2'): out = NewRecord(ops, rec) out.uid.set(blob=rec.uid(), unsafe=True) ops.Sub([rec.value(), rec.value()], [out.value()]) ops.Add([counter, ONE], [counter]) return out src_ds = Dataset(src_blobs) dst_ds = Dataset(dst_blobs) with TaskGroup() as tg: out1 = pipe( src_ds.reader(), output=Queue( capacity=11, num_dequeue_records=NUM_DEQUEUE_RECORDS), processor=proc1) out2 = pipe(out1, processor=proc2) pipe(out2, dst_ds.writer()) ws = workspace.C.Workspace() FeedRecord(src_blobs, src_values, ws) session = LocalSession(ws) session.run(init_net) session.run(tg) output = FetchRecord(dst_blobs, ws=ws) num_dequeues = ws.blobs[str(counter)].fetch() self.assertEquals( num_dequeues, int(math.ceil(float(N) / NUM_DEQUEUE_RECORDS))) for a, b in zip(output.field_blobs(), expected_dst.field_blobs()): np.testing.assert_array_equal(a, b)
apache-2.0
[ 3, 1898, 334, 67, 9, 7800, 13, 1881, 12, 27107, 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, 199, 4605, 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, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1704, 2026, 18, 14, 1548, 14, 3629, 492, 334, 272, 13039, 12, 16347, 5433, 12, 7053, 5433, 12, 16261, 5433, 12, 21026, 4699, 5433, 9, 199, 504, 1704, 2026, 18, 14, 1548, 492, 6170, 12, 14466, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1730, 492, 10111, 4434, 199, 504, 1704, 2026, 18, 14, 1548, 14, 5214, 492, 20284, 199, 504, 1704, 2026, 18, 14, 1548, 14, 7379, 492, 5200, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1825, 63, 1974, 492, 10703, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1765, 492, 8495, 2448, 199, 504, 1704, 2026, 18, 14, 1548, 14, 396, 63, 1974, 492, 7640, 199, 504, 1704, 2026, 18, 14, 1548, 14, 846, 63, 5649, 492, 4156, 199, 646, 2680, 465, 980, 199, 646, 3473, 421, 199, 533, 1379, 17562, 8, 1746, 304, 272, 347, 511, 63, 18522, 63, 3479, 8, 277, 304, 267, 4205, 63, 846, 275, 6170, 14, 2480, 360, 826, 358, 267, 653, 275, 5557, 267, 11576, 63, 1093, 15125, 63, 9481, 726, 3177, 275, 650, 267, 2928, 63, 1459, 275, 13039, 8, 288, 661, 1535, 297, 980, 14, 1144, 8, 1842, 8, 46, 11508, 288, 661, 585, 297, 378, 14, 17, 627, 980, 14, 1144, 8, 1842, 8, 46, 7845, 267, 1420, 63, 5119, 275, 13039, 8, 288, 661, 1535, 297, 499, 627, 980, 14, 1144, 8, 1842, 8, 46, 11508, 288, 661, 585, 297, 980, 14, 1144, 8, 46, 627, 359, 16, 14, 16, 11845, 398, 543, 6170, 14, 985, 7812, 360, 826, 735, 288, 2928, 63, 21893, 275, 7053, 5433, 8, 826, 63, 846, 12, 2928, 63, 1459, 9, 288, 5042, 63, 21893, 275, 21026, 4699, 5433, 8, 826, 63, 846, 12, 2928, 63, 1459, 14, 6311, 63, 3629, 1012, 288, 7055, 275, 4205, 63, 846, 14, 6361, 8, 16, 9, 288, 13051, 275, 4205, 63, 846, 14, 6361, 8, 17, 9, 398, 347, 6499, 17, 8, 2761, 304, 288, 543, 6170, 14, 985, 7812, 360, 4687, 17, 735, 355, 734, 275, 7053, 5433, 8, 1483, 12, 6488, 9, 288, 4156, 14, 1123, 779, 2761, 14, 1535, 1062, 6488, 14, 1535, 15618, 359, 548, 14, 1535, 9383, 288, 734, 14, 585, 14, 409, 8, 6582, 29, 2761, 14, 585, 1062, 19293, 29, 549, 9, 288, 372, 734, 398, 347, 6499, 18, 8, 2761, 304, 288, 543, 6170, 14, 985, 7812, 360, 4687, 18, 735, 355, 734, 275, 7053, 5433, 8, 1483, 12, 6488, 9, 288, 734, 14, 1535, 14, 409, 8, 6582, 29, 2761, 14, 1535, 1062, 19293, 29, 549, 9, 288, 4156, 14, 2610, 779, 2761, 14, 585, 1062, 6488, 14, 585, 15618, 359, 548, 14, 585, 9383, 288, 4156, 14, 1123, 779, 5337, 12, 13051, 467, 359, 5337, 566, 288, 372, 734, 398, 2928, 63, 795, 275, 20284, 8, 2164, 63, 21893, 9, 267, 5042, 63, 795, 275, 20284, 8, 5119, 63, 21893, 9, 398, 543, 8495, 2448, 342, 465, 22387, 26, 288, 734, 17, 275, 5200, 8, 355, 2928, 63, 795, 14, 5503, 1062, 355, 1072, 29, 3737, 8, 490, 14893, 29, 845, 12, 1967, 63, 18522, 63, 6502, 29, 7125, 63, 1093, 15125, 63, 9481, 726, 3177, 395, 355, 12495, 29, 4687, 17, 9, 288, 734, 18, 275, 5200, 8, 548, 17, 12, 12495, 29, 4687, 18, 9, 288, 5200, 8, 548, 18, 12, 5042, 63, 795, 14, 5491, 1012, 398, 10900, 275, 14466, 14, 35, 14, 21058, 342, 267, 16261, 5433, 8, 2164, 63, 21893, 12, 2928, 63, 1459, 12, 10900, 9, 267, 2351, 275, 10111, 4434, 8, 3569, 9, 267, 2351, 14, 1065, 8, 826, 63, 846, 9, 267, 2351, 14, 1065, 8, 17699, 9, 267, 1072, 275, 16347, 5433, 8, 5119, 63, 21893, 12, 10900, 29, 3569, 9, 267, 1967, 63, 18522, 83, 275, 10900, 14, 21893, 59, 495, 8, 5337, 22509, 3535, 342, 398, 291, 14, 2947, 8, 288, 1967, 63, 18522, 83, 12, 1109, 8, 3442, 14, 14085, 8, 1609, 8, 46, 9, 1182, 11576, 63, 1093, 15125, 63, 9481, 726, 3177, 1724, 398, 367, 282, 12, 330, 315, 3482, 8, 1199, 14, 698, 63, 21893, 1062, 1420, 63, 5119, 14, 698, 63, 21893, 5109, 288, 980, 14, 4776, 14, 479, 63, 1144, 63, 1452, 8, 65, 12, 330, 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 ]
[ 1898, 334, 67, 9, 7800, 13, 1881, 12, 27107, 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, 199, 4605, 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, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1704, 2026, 18, 14, 1548, 14, 3629, 492, 334, 272, 13039, 12, 16347, 5433, 12, 7053, 5433, 12, 16261, 5433, 12, 21026, 4699, 5433, 9, 199, 504, 1704, 2026, 18, 14, 1548, 492, 6170, 12, 14466, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1730, 492, 10111, 4434, 199, 504, 1704, 2026, 18, 14, 1548, 14, 5214, 492, 20284, 199, 504, 1704, 2026, 18, 14, 1548, 14, 7379, 492, 5200, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1825, 63, 1974, 492, 10703, 199, 504, 1704, 2026, 18, 14, 1548, 14, 1765, 492, 8495, 2448, 199, 504, 1704, 2026, 18, 14, 1548, 14, 396, 63, 1974, 492, 7640, 199, 504, 1704, 2026, 18, 14, 1548, 14, 846, 63, 5649, 492, 4156, 199, 646, 2680, 465, 980, 199, 646, 3473, 421, 199, 533, 1379, 17562, 8, 1746, 304, 272, 347, 511, 63, 18522, 63, 3479, 8, 277, 304, 267, 4205, 63, 846, 275, 6170, 14, 2480, 360, 826, 358, 267, 653, 275, 5557, 267, 11576, 63, 1093, 15125, 63, 9481, 726, 3177, 275, 650, 267, 2928, 63, 1459, 275, 13039, 8, 288, 661, 1535, 297, 980, 14, 1144, 8, 1842, 8, 46, 11508, 288, 661, 585, 297, 378, 14, 17, 627, 980, 14, 1144, 8, 1842, 8, 46, 7845, 267, 1420, 63, 5119, 275, 13039, 8, 288, 661, 1535, 297, 499, 627, 980, 14, 1144, 8, 1842, 8, 46, 11508, 288, 661, 585, 297, 980, 14, 1144, 8, 46, 627, 359, 16, 14, 16, 11845, 398, 543, 6170, 14, 985, 7812, 360, 826, 735, 288, 2928, 63, 21893, 275, 7053, 5433, 8, 826, 63, 846, 12, 2928, 63, 1459, 9, 288, 5042, 63, 21893, 275, 21026, 4699, 5433, 8, 826, 63, 846, 12, 2928, 63, 1459, 14, 6311, 63, 3629, 1012, 288, 7055, 275, 4205, 63, 846, 14, 6361, 8, 16, 9, 288, 13051, 275, 4205, 63, 846, 14, 6361, 8, 17, 9, 398, 347, 6499, 17, 8, 2761, 304, 288, 543, 6170, 14, 985, 7812, 360, 4687, 17, 735, 355, 734, 275, 7053, 5433, 8, 1483, 12, 6488, 9, 288, 4156, 14, 1123, 779, 2761, 14, 1535, 1062, 6488, 14, 1535, 15618, 359, 548, 14, 1535, 9383, 288, 734, 14, 585, 14, 409, 8, 6582, 29, 2761, 14, 585, 1062, 19293, 29, 549, 9, 288, 372, 734, 398, 347, 6499, 18, 8, 2761, 304, 288, 543, 6170, 14, 985, 7812, 360, 4687, 18, 735, 355, 734, 275, 7053, 5433, 8, 1483, 12, 6488, 9, 288, 734, 14, 1535, 14, 409, 8, 6582, 29, 2761, 14, 1535, 1062, 19293, 29, 549, 9, 288, 4156, 14, 2610, 779, 2761, 14, 585, 1062, 6488, 14, 585, 15618, 359, 548, 14, 585, 9383, 288, 4156, 14, 1123, 779, 5337, 12, 13051, 467, 359, 5337, 566, 288, 372, 734, 398, 2928, 63, 795, 275, 20284, 8, 2164, 63, 21893, 9, 267, 5042, 63, 795, 275, 20284, 8, 5119, 63, 21893, 9, 398, 543, 8495, 2448, 342, 465, 22387, 26, 288, 734, 17, 275, 5200, 8, 355, 2928, 63, 795, 14, 5503, 1062, 355, 1072, 29, 3737, 8, 490, 14893, 29, 845, 12, 1967, 63, 18522, 63, 6502, 29, 7125, 63, 1093, 15125, 63, 9481, 726, 3177, 395, 355, 12495, 29, 4687, 17, 9, 288, 734, 18, 275, 5200, 8, 548, 17, 12, 12495, 29, 4687, 18, 9, 288, 5200, 8, 548, 18, 12, 5042, 63, 795, 14, 5491, 1012, 398, 10900, 275, 14466, 14, 35, 14, 21058, 342, 267, 16261, 5433, 8, 2164, 63, 21893, 12, 2928, 63, 1459, 12, 10900, 9, 267, 2351, 275, 10111, 4434, 8, 3569, 9, 267, 2351, 14, 1065, 8, 826, 63, 846, 9, 267, 2351, 14, 1065, 8, 17699, 9, 267, 1072, 275, 16347, 5433, 8, 5119, 63, 21893, 12, 10900, 29, 3569, 9, 267, 1967, 63, 18522, 83, 275, 10900, 14, 21893, 59, 495, 8, 5337, 22509, 3535, 342, 398, 291, 14, 2947, 8, 288, 1967, 63, 18522, 83, 12, 1109, 8, 3442, 14, 14085, 8, 1609, 8, 46, 9, 1182, 11576, 63, 1093, 15125, 63, 9481, 726, 3177, 1724, 398, 367, 282, 12, 330, 315, 3482, 8, 1199, 14, 698, 63, 21893, 1062, 1420, 63, 5119, 14, 698, 63, 21893, 5109, 288, 980, 14, 4776, 14, 479, 63, 1144, 63, 1452, 8, 65, 12, 330, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
cernops/python-neutronclient
neutronclient/neutron/v2_0/lb/v2/listener.py
2
3798
# Copyright 2014 Blue Box Group, Inc. # Copyright 2015 Hewlett-Packard Development Company, L.P. # All Rights Reserved # # Author: Craig Tracey <craigtracey@gmail.com> # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # from neutronclient.i18n import _ from neutronclient.neutron import v2_0 as neutronV20 def _get_loadbalancer_id(client, lb_id_or_name): return neutronV20.find_resourceid_by_name_or_id( client, 'loadbalancer', lb_id_or_name, cmd_resource='lbaas_loadbalancer') class ListListener(neutronV20.ListCommand): """LBaaS v2 List listeners that belong to a given tenant.""" resource = 'listener' list_columns = ['id', 'default_pool_id', 'name', 'protocol', 'protocol_port', 'admin_state_up', 'status'] pagination_support = True sorting_support = True class ShowListener(neutronV20.ShowCommand): """LBaaS v2 Show information of a given listener.""" resource = 'listener' class CreateListener(neutronV20.CreateCommand): """LBaaS v2 Create a listener.""" resource = 'listener' def add_known_arguments(self, parser): parser.add_argument( '--admin-state-down', dest='admin_state', action='store_false', help=_('Set admin state up to false.')) parser.add_argument( '--connection-limit', help=_('The maximum number of connections per second allowed for ' 'the vip. Positive integer or -1 for unlimited (default).')) parser.add_argument( '--description', help=_('Description of the listener.')) parser.add_argument( '--name', help=_('The name of the listener.')) parser.add_argument( '--loadbalancer', required=True, metavar='LOADBALANCER', help=_('ID or name of the load balancer.')) parser.add_argument( '--protocol', required=True, choices=['TCP', 'HTTP', 'HTTPS'], help=_('Protocol for the listener.')) parser.add_argument( '--protocol-port', dest='protocol_port', required=True, metavar='PORT', help=_('Protocol port for the listener.')) def args2body(self, parsed_args): if parsed_args.loadbalancer: parsed_args.loadbalancer = _get_loadbalancer_id( self.get_client(), parsed_args.loadbalancer) body = { self.resource: { 'loadbalancer_id': parsed_args.loadbalancer, 'protocol': parsed_args.protocol, 'protocol_port': parsed_args.protocol_port, 'admin_state_up': parsed_args.admin_state, }, } neutronV20.update_dict(parsed_args, body[self.resource], ['connection-limit', 'description', 'loadbalancer_id', 'name']) return body class UpdateListener(neutronV20.UpdateCommand): """LBaaS v2 Update a given listener.""" resource = 'listener' allow_names = False class DeleteListener(neutronV20.DeleteCommand): """LBaaS v2 Delete a given listener.""" resource = 'listener'
apache-2.0
[ 3, 1898, 6927, 22447, 20783, 5611, 12, 3277, 14, 199, 3, 1898, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 2900, 5924, 5702, 199, 3, 199, 3, 6529, 26, 445, 345, 528, 11680, 89, 665, 67, 345, 528, 3446, 89, 32, 6799, 14, 957, 30, 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, 3, 199, 199, 504, 8224, 1258, 14, 73, 1085, 78, 492, 485, 199, 504, 8224, 1258, 14, 10271, 492, 373, 18, 63, 16, 465, 8224, 54, 1165, 421, 199, 318, 485, 362, 63, 26615, 63, 344, 8, 1258, 12, 11104, 63, 344, 63, 269, 63, 354, 304, 272, 372, 8224, 54, 1165, 14, 1623, 63, 1927, 344, 63, 991, 63, 354, 63, 269, 63, 344, 8, 267, 1890, 12, 267, 283, 26615, 297, 267, 11104, 63, 344, 63, 269, 63, 354, 12, 267, 2088, 63, 1927, 534, 76, 2470, 305, 63, 26615, 358, 421, 199, 533, 3820, 10464, 8, 10271, 54, 1165, 14, 1296, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 3820, 19946, 626, 13511, 370, 282, 1627, 8261, 1041, 339, 2073, 275, 283, 9799, 7, 272, 769, 63, 3406, 275, 788, 344, 297, 283, 885, 63, 2293, 63, 344, 297, 283, 354, 297, 283, 3922, 297, 490, 283, 3922, 63, 719, 297, 283, 2113, 63, 929, 63, 384, 297, 283, 1205, 418, 272, 21192, 63, 4058, 275, 715, 272, 13351, 63, 4058, 275, 715, 421, 199, 533, 12968, 10464, 8, 10271, 54, 1165, 14, 6824, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 12968, 2556, 402, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 421, 199, 533, 2790, 10464, 8, 10271, 54, 1165, 14, 2499, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 2790, 282, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 339, 347, 1050, 63, 3159, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 2113, 13, 929, 13, 2110, 297, 288, 2053, 534, 2113, 63, 929, 297, 1595, 534, 1617, 63, 3910, 297, 288, 1720, 12397, 1084, 4628, 1174, 1536, 370, 3055, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 2105, 13, 3097, 297, 288, 1720, 12397, 1918, 5696, 1329, 402, 6947, 1126, 3499, 4370, 367, 283, 673, 283, 1589, 29681, 14, 30245, 3000, 503, 446, 17, 367, 625, 14136, 334, 885, 680, 1333, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 1802, 297, 288, 1720, 12397, 5831, 402, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 354, 297, 288, 1720, 12397, 1918, 536, 402, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 26615, 297, 288, 1415, 29, 549, 12, 288, 8214, 534, 7405, 31232, 879, 35, 540, 297, 288, 1720, 12397, 998, 503, 536, 402, 314, 2248, 17005, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 3922, 297, 288, 1415, 29, 549, 12, 288, 3415, 2968, 9735, 297, 283, 2856, 297, 283, 14921, 995, 288, 1720, 12397, 3658, 367, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 3922, 13, 719, 297, 288, 2053, 534, 3922, 63, 719, 297, 1415, 29, 549, 12, 288, 8214, 534, 3657, 297, 288, 1720, 12397, 3658, 1844, 367, 314, 11647, 12459, 339, 347, 1249, 18, 2030, 8, 277, 12, 4565, 63, 589, 304, 267, 340, 4565, 63, 589, 14, 26615, 26, 288, 4565, 63, 589, 14, 26615, 275, 485, 362, 63, 26615, 63, 344, 8, 355, 291, 14, 362, 63, 1258, 1062, 355, 4565, 63, 589, 14, 26615, 9, 267, 2396, 275, 469, 288, 291, 14, 1927, 26, 469, 355, 283, 26615, 63, 344, 356, 4565, 63, 589, 14, 26615, 12, 355, 283, 3922, 356, 4565, 63, 589, 14, 3922, 12, 355, 283, 3922, 63, 719, 356, 4565, 63, 589, 14, 3922, 63, 719, 12, 355, 283, 2113, 63, 929, 63, 384, 356, 4565, 63, 589, 14, 2113, 63, 929, 12, 288, 1660, 267, 789, 398, 8224, 54, 1165, 14, 873, 63, 807, 8, 6751, 63, 589, 12, 2396, 59, 277, 14, 1927, 467, 3044, 788, 2105, 13, 3097, 297, 283, 1802, 297, 1816, 283, 26615, 63, 344, 297, 283, 354, 1105, 267, 372, 2396, 421, 199, 533, 6162, 10464, 8, 10271, 54, 1165, 14, 4152, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 6162, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 272, 2040, 63, 1247, 275, 756, 421, 199, 533, 8496, 10464, 8, 10271, 54, 1165, 14, 5392, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 8496, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 22447, 20783, 5611, 12, 3277, 14, 199, 3, 1898, 6900, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 2900, 5924, 5702, 199, 3, 199, 3, 6529, 26, 445, 345, 528, 11680, 89, 665, 67, 345, 528, 3446, 89, 32, 6799, 14, 957, 30, 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, 3, 199, 199, 504, 8224, 1258, 14, 73, 1085, 78, 492, 485, 199, 504, 8224, 1258, 14, 10271, 492, 373, 18, 63, 16, 465, 8224, 54, 1165, 421, 199, 318, 485, 362, 63, 26615, 63, 344, 8, 1258, 12, 11104, 63, 344, 63, 269, 63, 354, 304, 272, 372, 8224, 54, 1165, 14, 1623, 63, 1927, 344, 63, 991, 63, 354, 63, 269, 63, 344, 8, 267, 1890, 12, 267, 283, 26615, 297, 267, 11104, 63, 344, 63, 269, 63, 354, 12, 267, 2088, 63, 1927, 534, 76, 2470, 305, 63, 26615, 358, 421, 199, 533, 3820, 10464, 8, 10271, 54, 1165, 14, 1296, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 3820, 19946, 626, 13511, 370, 282, 1627, 8261, 1041, 339, 2073, 275, 283, 9799, 7, 272, 769, 63, 3406, 275, 788, 344, 297, 283, 885, 63, 2293, 63, 344, 297, 283, 354, 297, 283, 3922, 297, 490, 283, 3922, 63, 719, 297, 283, 2113, 63, 929, 63, 384, 297, 283, 1205, 418, 272, 21192, 63, 4058, 275, 715, 272, 13351, 63, 4058, 275, 715, 421, 199, 533, 12968, 10464, 8, 10271, 54, 1165, 14, 6824, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 12968, 2556, 402, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 421, 199, 533, 2790, 10464, 8, 10271, 54, 1165, 14, 2499, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 2790, 282, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 339, 347, 1050, 63, 3159, 63, 4958, 8, 277, 12, 1798, 304, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 2113, 13, 929, 13, 2110, 297, 288, 2053, 534, 2113, 63, 929, 297, 1595, 534, 1617, 63, 3910, 297, 288, 1720, 12397, 1084, 4628, 1174, 1536, 370, 3055, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 2105, 13, 3097, 297, 288, 1720, 12397, 1918, 5696, 1329, 402, 6947, 1126, 3499, 4370, 367, 283, 673, 283, 1589, 29681, 14, 30245, 3000, 503, 446, 17, 367, 625, 14136, 334, 885, 680, 1333, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 1802, 297, 288, 1720, 12397, 5831, 402, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 354, 297, 288, 1720, 12397, 1918, 536, 402, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 26615, 297, 288, 1415, 29, 549, 12, 288, 8214, 534, 7405, 31232, 879, 35, 540, 297, 288, 1720, 12397, 998, 503, 536, 402, 314, 2248, 17005, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 3922, 297, 288, 1415, 29, 549, 12, 288, 3415, 2968, 9735, 297, 283, 2856, 297, 283, 14921, 995, 288, 1720, 12397, 3658, 367, 314, 11647, 12459, 267, 1798, 14, 525, 63, 2094, 8, 288, 2850, 3922, 13, 719, 297, 288, 2053, 534, 3922, 63, 719, 297, 1415, 29, 549, 12, 288, 8214, 534, 3657, 297, 288, 1720, 12397, 3658, 1844, 367, 314, 11647, 12459, 339, 347, 1249, 18, 2030, 8, 277, 12, 4565, 63, 589, 304, 267, 340, 4565, 63, 589, 14, 26615, 26, 288, 4565, 63, 589, 14, 26615, 275, 485, 362, 63, 26615, 63, 344, 8, 355, 291, 14, 362, 63, 1258, 1062, 355, 4565, 63, 589, 14, 26615, 9, 267, 2396, 275, 469, 288, 291, 14, 1927, 26, 469, 355, 283, 26615, 63, 344, 356, 4565, 63, 589, 14, 26615, 12, 355, 283, 3922, 356, 4565, 63, 589, 14, 3922, 12, 355, 283, 3922, 63, 719, 356, 4565, 63, 589, 14, 3922, 63, 719, 12, 355, 283, 2113, 63, 929, 63, 384, 356, 4565, 63, 589, 14, 2113, 63, 929, 12, 288, 1660, 267, 789, 398, 8224, 54, 1165, 14, 873, 63, 807, 8, 6751, 63, 589, 12, 2396, 59, 277, 14, 1927, 467, 3044, 788, 2105, 13, 3097, 297, 283, 1802, 297, 1816, 283, 26615, 63, 344, 297, 283, 354, 1105, 267, 372, 2396, 421, 199, 533, 6162, 10464, 8, 10271, 54, 1165, 14, 4152, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 6162, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 272, 2040, 63, 1247, 275, 756, 421, 199, 533, 8496, 10464, 8, 10271, 54, 1165, 14, 5392, 3110, 304, 272, 408, 11568, 2158, 51, 373, 18, 8496, 282, 1627, 11647, 1041, 339, 2073, 275, 283, 9799, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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.py
20
1748
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be> # Copyright (C) 2014 Jesús Espino <jespinog@gmail.com> # Copyright (C) 2014 David Barragán <bameda@dbarragan.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/>. import uuid from django.core.urlresolvers import reverse from taiga.users.models import User from taiga.users.models import AuthData from taiga.base.utils.urls import get_absolute_url def get_or_generate_config(project): config = project.modules_config.config if config and "github" in config: g_config = project.modules_config.config["github"] else: g_config = {"secret": uuid.uuid4().hex} url = reverse("github-hook-list") url = get_absolute_url(url) url = "%s?project=%s" % (url, project.id) g_config["webhooks_url"] = url return g_config def get_github_user(github_id): user = None if github_id: try: user = AuthData.objects.get(key="github", value=github_id).user except AuthData.DoesNotExist: pass if user is None: user = User.objects.get(is_system=True, username__startswith="github") return user
agpl-3.0
[ 3, 1898, 334, 35, 9, 6927, 6061, 17885, 437, 343, 3210, 72, 665, 8445, 14249, 32, 8445, 14249, 14, 1235, 30, 199, 3, 1898, 334, 35, 9, 6927, 1603, 397, 24602, 83, 662, 681, 10175, 665, 74, 397, 7751, 974, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6927, 20232, 12377, 2527, 11302, 78, 665, 66, 313, 983, 32, 697, 285, 2527, 290, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 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, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 5377, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 3052, 29055, 14, 3707, 14, 992, 492, 2876, 199, 504, 3052, 29055, 14, 3707, 14, 992, 492, 3590, 1451, 199, 504, 3052, 29055, 14, 1095, 14, 1208, 14, 3603, 492, 664, 63, 6116, 63, 633, 421, 199, 318, 664, 63, 269, 63, 4208, 63, 888, 8, 1715, 304, 272, 1101, 275, 2199, 14, 3112, 63, 888, 14, 888, 272, 340, 1101, 436, 298, 5031, 2, 315, 1101, 26, 267, 486, 63, 888, 275, 2199, 14, 3112, 63, 888, 14, 888, 905, 5031, 937, 272, 587, 26, 267, 486, 63, 888, 275, 2420, 4731, 582, 5377, 14, 2580, 20, 1252, 4097, 93, 339, 1166, 275, 3837, 480, 5031, 13, 3664, 13, 513, 531, 272, 1166, 275, 664, 63, 6116, 63, 633, 8, 633, 9, 272, 1166, 275, 2071, 83, 31, 1715, 2458, 83, 2, 450, 334, 633, 12, 2199, 14, 344, 9, 272, 486, 63, 888, 905, 2520, 7922, 63, 633, 937, 275, 1166, 272, 372, 486, 63, 888, 421, 199, 318, 664, 63, 5031, 63, 751, 8, 5031, 63, 344, 304, 272, 922, 275, 488, 339, 340, 12869, 63, 344, 26, 267, 862, 26, 288, 922, 275, 3590, 1451, 14, 1462, 14, 362, 8, 498, 628, 5031, 401, 574, 29, 5031, 63, 344, 680, 751, 267, 871, 3590, 1451, 14, 7400, 26, 288, 986, 339, 340, 922, 365, 488, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 374, 63, 2253, 29, 549, 12, 3434, 363, 2460, 628, 5031, 531, 339, 372, 922, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 6927, 6061, 17885, 437, 343, 3210, 72, 665, 8445, 14249, 32, 8445, 14249, 14, 1235, 30, 199, 3, 1898, 334, 35, 9, 6927, 1603, 397, 24602, 83, 662, 681, 10175, 665, 74, 397, 7751, 974, 32, 6799, 14, 957, 30, 199, 3, 1898, 334, 35, 9, 6927, 20232, 12377, 2527, 11302, 78, 665, 66, 313, 983, 32, 697, 285, 2527, 290, 14, 957, 30, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 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, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 646, 5377, 199, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 199, 504, 3052, 29055, 14, 3707, 14, 992, 492, 2876, 199, 504, 3052, 29055, 14, 3707, 14, 992, 492, 3590, 1451, 199, 504, 3052, 29055, 14, 1095, 14, 1208, 14, 3603, 492, 664, 63, 6116, 63, 633, 421, 199, 318, 664, 63, 269, 63, 4208, 63, 888, 8, 1715, 304, 272, 1101, 275, 2199, 14, 3112, 63, 888, 14, 888, 272, 340, 1101, 436, 298, 5031, 2, 315, 1101, 26, 267, 486, 63, 888, 275, 2199, 14, 3112, 63, 888, 14, 888, 905, 5031, 937, 272, 587, 26, 267, 486, 63, 888, 275, 2420, 4731, 582, 5377, 14, 2580, 20, 1252, 4097, 93, 339, 1166, 275, 3837, 480, 5031, 13, 3664, 13, 513, 531, 272, 1166, 275, 664, 63, 6116, 63, 633, 8, 633, 9, 272, 1166, 275, 2071, 83, 31, 1715, 2458, 83, 2, 450, 334, 633, 12, 2199, 14, 344, 9, 272, 486, 63, 888, 905, 2520, 7922, 63, 633, 937, 275, 1166, 272, 372, 486, 63, 888, 421, 199, 318, 664, 63, 5031, 63, 751, 8, 5031, 63, 344, 304, 272, 922, 275, 488, 339, 340, 12869, 63, 344, 26, 267, 862, 26, 288, 922, 275, 3590, 1451, 14, 1462, 14, 362, 8, 498, 628, 5031, 401, 574, 29, 5031, 63, 344, 680, 751, 267, 871, 3590, 1451, 14, 7400, 26, 288, 986, 339, 340, 922, 365, 488, 26, 267, 922, 275, 2876, 14, 1462, 14, 362, 8, 374, 63, 2253, 29, 549, 12, 3434, 363, 2460, 628, 5031, 531, 339, 372, 922, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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/python/systemd.py
12
2834
# -*- test-case-name: twisted.python.test.test_systemd -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Integration with systemd. Currently only the minimum APIs necessary for using systemd's socket activation feature are supported. """ from __future__ import division, absolute_import __all__ = ['ListenFDs'] from os import getpid class ListenFDs(object): """ L{ListenFDs} provides access to file descriptors inherited from systemd. Typically L{ListenFDs.fromEnvironment} should be used to construct a new instance of L{ListenFDs}. @cvar _START: File descriptors inherited from systemd are always consecutively numbered, with a fixed lowest "starting" descriptor. This gives the default starting descriptor. Since this must agree with the value systemd is using, it typically should not be overridden. @type _START: C{int} @ivar _descriptors: A C{list} of C{int} giving the descriptors which were inherited. """ _START = 3 def __init__(self, descriptors): """ @param descriptors: The descriptors which will be returned from calls to C{inheritedDescriptors}. """ self._descriptors = descriptors @classmethod def fromEnvironment(cls, environ=None, start=None): """ @param environ: A dictionary-like object to inspect to discover inherited descriptors. By default, C{None}, indicating that the real process environment should be inspected. The default is suitable for typical usage. @param start: An integer giving the lowest value of an inherited descriptor systemd will give us. By default, C{None}, indicating the known correct (that is, in agreement with systemd) value will be used. The default is suitable for typical usage. @return: A new instance of C{cls} which can be used to look up the descriptors which have been inherited. """ if environ is None: from os import environ if start is None: start = cls._START descriptors = [] try: pid = int(environ['LISTEN_PID']) except (KeyError, ValueError): pass else: if pid == getpid(): try: count = int(environ['LISTEN_FDS']) except (KeyError, ValueError): pass else: descriptors = range(start, start + count) del environ['LISTEN_PID'], environ['LISTEN_FDS'] return cls(descriptors) def inheritedDescriptors(self): """ @return: The configured list of descriptors. """ return list(self._descriptors)
gpl-3.0
[ 3, 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 1548, 14, 396, 14, 396, 63, 30830, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 20405, 543, 2656, 68, 14, 199, 199, 31499, 1454, 314, 7481, 15913, 5784, 367, 1808, 2656, 68, 1159, 2838, 10361, 199, 4445, 787, 3748, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 788, 8687, 7902, 83, 418, 199, 199, 504, 747, 492, 664, 3150, 421, 199, 533, 491, 7938, 7902, 83, 8, 785, 304, 272, 408, 272, 491, 91, 8687, 7902, 83, 93, 6571, 2879, 370, 570, 15428, 12623, 687, 2656, 68, 14, 339, 26914, 491, 91, 8687, 7902, 83, 14, 504, 8263, 93, 1077, 506, 1202, 370, 6982, 282, 892, 272, 1256, 402, 491, 91, 8687, 7902, 83, 5565, 339, 768, 26781, 485, 7363, 26, 3814, 15428, 12623, 687, 2656, 68, 787, 3544, 267, 406, 3321, 935, 5636, 1967, 18897, 12, 543, 282, 6317, 18966, 298, 15769, 2, 5872, 14, 221, 961, 267, 10557, 314, 849, 6617, 5872, 14, 221, 9336, 642, 1471, 10601, 543, 314, 267, 574, 2656, 68, 365, 1808, 12, 652, 13609, 1077, 440, 506, 10087, 14, 272, 768, 466, 485, 7363, 26, 445, 91, 442, 93, 339, 768, 7725, 485, 17752, 26, 437, 445, 91, 513, 93, 402, 445, 91, 442, 93, 15131, 314, 15428, 1314, 4898, 267, 12623, 14, 272, 408, 272, 485, 7363, 275, 650, 339, 347, 636, 826, 721, 277, 12, 15428, 304, 267, 408, 267, 768, 635, 15428, 26, 710, 15428, 1314, 911, 506, 2138, 687, 4882, 370, 288, 445, 91, 17571, 2586, 30547, 5565, 267, 408, 267, 291, 423, 17752, 275, 15428, 2378, 768, 3744, 272, 347, 687, 8263, 8, 1886, 12, 6160, 29, 403, 12, 1343, 29, 403, 304, 267, 408, 267, 768, 635, 6160, 26, 437, 2600, 13, 2930, 909, 370, 6485, 370, 20131, 288, 12623, 15428, 14, 221, 4885, 849, 12, 445, 91, 403, 1386, 9297, 626, 314, 288, 3363, 2112, 3734, 1077, 506, 5261, 1043, 14, 221, 710, 849, 365, 288, 11233, 367, 25780, 4503, 14, 398, 768, 635, 1343, 26, 1626, 3000, 15131, 314, 18966, 574, 402, 376, 12623, 288, 5872, 2656, 68, 911, 8120, 2739, 14, 221, 4885, 849, 12, 445, 91, 403, 1386, 9297, 288, 314, 6040, 3211, 334, 9099, 365, 12, 315, 25025, 543, 2656, 68, 9, 574, 911, 506, 288, 1202, 14, 221, 710, 849, 365, 11233, 367, 25780, 4503, 14, 398, 768, 1107, 26, 437, 892, 1256, 402, 445, 91, 1886, 93, 1314, 883, 506, 1202, 370, 3648, 1536, 314, 288, 15428, 1314, 1172, 2757, 12623, 14, 267, 408, 267, 340, 6160, 365, 488, 26, 288, 687, 747, 492, 6160, 267, 340, 1343, 365, 488, 26, 288, 1343, 275, 843, 423, 7363, 398, 15428, 275, 942, 398, 862, 26, 288, 4422, 275, 1109, 8, 2314, 459, 4924, 742, 63, 16098, 1105, 267, 871, 334, 10230, 12, 1722, 304, 288, 986, 267, 587, 26, 288, 340, 4422, 508, 664, 3150, 837, 355, 862, 26, 490, 2338, 275, 1109, 8, 2314, 459, 4924, 742, 63, 38, 3177, 1105, 355, 871, 334, 10230, 12, 1722, 304, 490, 986, 355, 587, 26, 490, 15428, 275, 1425, 8, 928, 12, 1343, 435, 2338, 9, 490, 2150, 6160, 459, 4924, 742, 63, 16098, 995, 6160, 459, 4924, 742, 63, 38, 3177, 418, 398, 372, 843, 8, 17752, 9, 2378, 347, 12623, 2586, 30547, 8, 277, 304, 267, 408, 267, 768, 1107, 26, 710, 7526, 769, 402, 15428, 14, 267, 408, 267, 372, 769, 8, 277, 423, 17752, 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 ]
[ 1882, 511, 13, 2546, 13, 354, 26, 7390, 14, 1548, 14, 396, 14, 396, 63, 30830, 1882, 199, 3, 1898, 334, 67, 9, 17078, 8449, 26640, 14, 199, 3, 1666, 5113, 367, 2436, 14, 199, 199, 624, 199, 20405, 543, 2656, 68, 14, 199, 199, 31499, 1454, 314, 7481, 15913, 5784, 367, 1808, 2656, 68, 1159, 2838, 10361, 199, 4445, 787, 3748, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 12, 3679, 63, 646, 199, 199, 363, 452, 363, 275, 788, 8687, 7902, 83, 418, 199, 199, 504, 747, 492, 664, 3150, 421, 199, 533, 491, 7938, 7902, 83, 8, 785, 304, 272, 408, 272, 491, 91, 8687, 7902, 83, 93, 6571, 2879, 370, 570, 15428, 12623, 687, 2656, 68, 14, 339, 26914, 491, 91, 8687, 7902, 83, 14, 504, 8263, 93, 1077, 506, 1202, 370, 6982, 282, 892, 272, 1256, 402, 491, 91, 8687, 7902, 83, 5565, 339, 768, 26781, 485, 7363, 26, 3814, 15428, 12623, 687, 2656, 68, 787, 3544, 267, 406, 3321, 935, 5636, 1967, 18897, 12, 543, 282, 6317, 18966, 298, 15769, 2, 5872, 14, 221, 961, 267, 10557, 314, 849, 6617, 5872, 14, 221, 9336, 642, 1471, 10601, 543, 314, 267, 574, 2656, 68, 365, 1808, 12, 652, 13609, 1077, 440, 506, 10087, 14, 272, 768, 466, 485, 7363, 26, 445, 91, 442, 93, 339, 768, 7725, 485, 17752, 26, 437, 445, 91, 513, 93, 402, 445, 91, 442, 93, 15131, 314, 15428, 1314, 4898, 267, 12623, 14, 272, 408, 272, 485, 7363, 275, 650, 339, 347, 636, 826, 721, 277, 12, 15428, 304, 267, 408, 267, 768, 635, 15428, 26, 710, 15428, 1314, 911, 506, 2138, 687, 4882, 370, 288, 445, 91, 17571, 2586, 30547, 5565, 267, 408, 267, 291, 423, 17752, 275, 15428, 2378, 768, 3744, 272, 347, 687, 8263, 8, 1886, 12, 6160, 29, 403, 12, 1343, 29, 403, 304, 267, 408, 267, 768, 635, 6160, 26, 437, 2600, 13, 2930, 909, 370, 6485, 370, 20131, 288, 12623, 15428, 14, 221, 4885, 849, 12, 445, 91, 403, 1386, 9297, 626, 314, 288, 3363, 2112, 3734, 1077, 506, 5261, 1043, 14, 221, 710, 849, 365, 288, 11233, 367, 25780, 4503, 14, 398, 768, 635, 1343, 26, 1626, 3000, 15131, 314, 18966, 574, 402, 376, 12623, 288, 5872, 2656, 68, 911, 8120, 2739, 14, 221, 4885, 849, 12, 445, 91, 403, 1386, 9297, 288, 314, 6040, 3211, 334, 9099, 365, 12, 315, 25025, 543, 2656, 68, 9, 574, 911, 506, 288, 1202, 14, 221, 710, 849, 365, 11233, 367, 25780, 4503, 14, 398, 768, 1107, 26, 437, 892, 1256, 402, 445, 91, 1886, 93, 1314, 883, 506, 1202, 370, 3648, 1536, 314, 288, 15428, 1314, 1172, 2757, 12623, 14, 267, 408, 267, 340, 6160, 365, 488, 26, 288, 687, 747, 492, 6160, 267, 340, 1343, 365, 488, 26, 288, 1343, 275, 843, 423, 7363, 398, 15428, 275, 942, 398, 862, 26, 288, 4422, 275, 1109, 8, 2314, 459, 4924, 742, 63, 16098, 1105, 267, 871, 334, 10230, 12, 1722, 304, 288, 986, 267, 587, 26, 288, 340, 4422, 508, 664, 3150, 837, 355, 862, 26, 490, 2338, 275, 1109, 8, 2314, 459, 4924, 742, 63, 38, 3177, 1105, 355, 871, 334, 10230, 12, 1722, 304, 490, 986, 355, 587, 26, 490, 15428, 275, 1425, 8, 928, 12, 1343, 435, 2338, 9, 490, 2150, 6160, 459, 4924, 742, 63, 16098, 995, 6160, 459, 4924, 742, 63, 38, 3177, 418, 398, 372, 843, 8, 17752, 9, 2378, 347, 12623, 2586, 30547, 8, 277, 304, 267, 408, 267, 768, 1107, 26, 710, 7526, 769, 402, 15428, 14, 267, 408, 267, 372, 769, 8, 277, 423, 17752, 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, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
mne-tools/mne-tools.github.io
0.13/_downloads/plot_compute_raw_data_spectrum.py
8
3431
""" ================================================== Compute the power spectral density of raw data ================================================== This script shows how to compute the power spectral density (PSD) of measurements on a raw dataset. It also show the effect of applying SSP to the data to reduce ECG and EOG artifacts. """ # Authors: Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr> # Martin Luessi <mluessi@nmr.mgh.harvard.edu> # Eric Larson <larson.eric.d@gmail.com> # License: BSD (3-clause) import numpy as np import matplotlib.pyplot as plt import mne from mne import io, read_proj, read_selection from mne.datasets import sample from mne.time_frequency import psd_multitaper print(__doc__) ############################################################################### # Set parameters data_path = sample.data_path() raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif' proj_fname = data_path + '/MEG/sample/sample_audvis_eog-proj.fif' tmin, tmax = 0, 60 # use the first 60s of data # Setup for reading the raw data (to save memory, crop before loading) raw = io.read_raw_fif(raw_fname).crop(tmin, tmax).load_data() raw.info['bads'] += ['MEG 2443', 'EEG 053'] # bads + 2 more # Add SSP projection vectors to reduce EOG and ECG artifacts projs = read_proj(proj_fname) raw.add_proj(projs, remove_existing=True) fmin, fmax = 2, 300 # look at frequencies between 2 and 300Hz n_fft = 2048 # the FFT size (n_fft). Ideally a power of 2 # Let's first check out all channel types raw.plot_psd(area_mode='range', tmax=10.0, show=False) # Now let's focus on a smaller subset: # Pick MEG magnetometers in the Left-temporal region selection = read_selection('Left-temporal') picks = mne.pick_types(raw.info, meg='mag', eeg=False, eog=False, stim=False, exclude='bads', selection=selection) # Let's just look at the first few channels for demonstration purposes picks = picks[:4] plt.figure() ax = plt.axes() raw.plot_psd(tmin=tmin, tmax=tmax, fmin=fmin, fmax=fmax, n_fft=n_fft, n_jobs=1, proj=False, ax=ax, color=(0, 0, 1), picks=picks, show=False) # And now do the same with SSP applied raw.plot_psd(tmin=tmin, tmax=tmax, fmin=fmin, fmax=fmax, n_fft=n_fft, n_jobs=1, proj=True, ax=ax, color=(0, 1, 0), picks=picks, show=False) # And now do the same with SSP + notch filtering # Pick all channels for notch since the SSP projection mixes channels together raw.notch_filter(np.arange(60, 241, 60), n_jobs=1) raw.plot_psd(tmin=tmin, tmax=tmax, fmin=fmin, fmax=fmax, n_fft=n_fft, n_jobs=1, proj=True, ax=ax, color=(1, 0, 0), picks=picks, show=False) ax.set_title('Four left-temporal magnetometers') plt.legend(['Without SSP', 'With SSP', 'SSP + Notch']) # Alternatively, you may also create PSDs from Raw objects with ``psd_*`` f, ax = plt.subplots() psds, freqs = psd_multitaper(raw, low_bias=True, tmin=tmin, tmax=tmax, fmin=fmin, fmax=fmax, proj=True, picks=picks, n_jobs=1) psds = 10 * np.log10(psds) psds_mean = psds.mean(0) psds_std = psds.std(0) ax.plot(freqs, psds_mean, color='k') ax.fill_between(freqs, psds_mean - psds_std, psds_mean + psds_std, color='k', alpha=.5) ax.set(title='Multitaper PSD', xlabel='Frequency', ylabel='Power Spectral Density (dB)') plt.show()
bsd-3-clause
[ 624, 199, 12813, 389, 199, 8564, 314, 7074, 28397, 13650, 402, 3066, 666, 199, 12813, 389, 199, 199, 2765, 2884, 13703, 4212, 370, 4526, 314, 7074, 28397, 13650, 334, 48, 3693, 9, 199, 1618, 32619, 641, 282, 3066, 4789, 14, 2779, 2597, 2498, 314, 7763, 402, 18876, 428, 5763, 199, 475, 314, 666, 370, 7114, 662, 4064, 436, 662, 14008, 27990, 14, 199, 624, 199, 3, 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 15253, 957, 13, 462, 374, 15970, 14, 4391, 30, 199, 3, 3515, 603, 26788, 491, 10138, 338, 665, 757, 10138, 338, 32, 10756, 82, 14, 77, 3561, 14, 8210, 86, 1005, 14, 8654, 30, 199, 3, 3515, 662, 1567, 491, 285, 834, 665, 9828, 834, 14, 281, 530, 14, 68, 32, 6799, 14, 957, 30, 199, 3, 844, 26, 6289, 334, 19, 13, 8501, 9, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 18250, 199, 504, 18250, 492, 5890, 12, 1586, 63, 5468, 12, 1586, 63, 5592, 199, 504, 18250, 14, 12281, 492, 2690, 199, 504, 18250, 14, 521, 63, 11132, 492, 299, 3893, 63, 3029, 84, 9804, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 11490, 199, 3, 2494, 2633, 199, 576, 63, 515, 275, 2690, 14, 576, 63, 515, 342, 199, 1773, 63, 5252, 275, 666, 63, 515, 435, 1994, 3635, 39, 15, 3271, 15, 3271, 63, 32024, 5068, 63, 1773, 14, 25533, 7, 199, 5468, 63, 5252, 275, 666, 63, 515, 435, 1994, 3635, 39, 15, 3271, 15, 3271, 63, 32024, 5068, 63, 69, 974, 13, 5468, 14, 25533, 7, 199, 199, 84, 827, 12, 307, 988, 275, 378, 12, 5212, 221, 327, 675, 314, 1642, 5212, 83, 402, 666, 199, 199, 3, 12439, 367, 7664, 314, 3066, 666, 334, 475, 3354, 4402, 12, 18366, 2544, 8697, 9, 199, 1773, 275, 5890, 14, 739, 63, 1773, 63, 25533, 8, 1773, 63, 5252, 680, 15816, 8, 84, 827, 12, 307, 988, 680, 912, 63, 576, 342, 199, 1773, 14, 815, 459, 4087, 83, 418, 847, 788, 3635, 39, 499, 16284, 297, 283, 37, 4680, 378, 2481, 418, 221, 327, 4875, 83, 435, 499, 1655, 199, 199, 3, 2654, 428, 5763, 14777, 11102, 370, 7114, 662, 14008, 436, 662, 4064, 27990, 199, 496, 3596, 275, 1586, 63, 5468, 8, 5468, 63, 5252, 9, 199, 1773, 14, 525, 63, 5468, 8, 496, 3596, 12, 2813, 63, 5952, 29, 549, 9, 421, 199, 70, 827, 12, 289, 988, 275, 499, 12, 9601, 221, 327, 3648, 737, 22411, 3382, 499, 436, 9601, 13026, 199, 78, 63, 9996, 275, 18427, 221, 327, 314, 29484, 1568, 334, 78, 63, 9996, 680, 473, 271, 1183, 282, 7074, 402, 499, 199, 199, 3, 12230, 1159, 1642, 1104, 734, 1006, 3623, 2943, 199, 1773, 14, 2798, 63, 31600, 8, 6789, 63, 632, 534, 1842, 297, 307, 988, 29, 709, 14, 16, 12, 2498, 29, 797, 9, 199, 199, 3, 7356, 4691, 1159, 16470, 641, 282, 12700, 10026, 26, 199, 3, 16568, 603, 4680, 15916, 386, 1377, 878, 315, 314, 29350, 13, 30574, 4897, 199, 5592, 275, 1586, 63, 5592, 360, 8185, 13, 30574, 358, 199, 4510, 83, 275, 18250, 14, 4510, 63, 1313, 8, 1773, 14, 815, 12, 562, 71, 534, 5615, 297, 325, 5902, 29, 797, 12, 325, 974, 29, 797, 12, 2432, 29965, 29, 797, 12, 5760, 534, 4087, 83, 297, 7267, 29, 5592, 9, 199, 199, 3, 12230, 1159, 2951, 3648, 737, 314, 1642, 9284, 9245, 367, 23789, 270, 1754, 12901, 199, 4510, 83, 275, 31055, 1491, 20, 61, 199, 199, 6003, 14, 8941, 342, 199, 1219, 275, 4488, 14, 6402, 342, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 797, 12, 2185, 29, 1219, 12, 3164, 2687, 16, 12, 378, 12, 413, 395, 221, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 3, 6061, 3063, 886, 314, 2011, 543, 428, 5763, 6781, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 549, 12, 2185, 29, 1219, 12, 3164, 2687, 16, 12, 413, 12, 378, 395, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 3, 6061, 3063, 886, 314, 2011, 543, 428, 5763, 435, 440, 335, 14545, 199, 3, 16568, 1006, 9245, 367, 440, 335, 3967, 314, 428, 5763, 14777, 13667, 397, 9245, 10451, 199, 1773, 14, 1397, 335, 63, 1541, 8, 1590, 14, 5605, 8, 2259, 12, 499, 2953, 12, 5212, 395, 302, 63, 6920, 29, 17, 9, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 549, 12, 2185, 29, 1219, 12, 3164, 2687, 17, 12, 378, 12, 378, 395, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 1219, 14, 409, 63, 1213, 360, 24766, 3602, 13, 30574, 15916, 386, 1377, 878, 358, 199, 6003, 14, 10231, 2941, 12450, 428, 5763, 297, 283, 3007, 428, 5763, 297, 283, 2300, 48, 435, 2832, 335, 1105, 199, 199, 3, 26776, 12, 1265, 1443, 2597, 1218, 510, 3693, 83, 687, 13480, 2251, 543, 1124, 31600, 15192, 1040, 199, 70, 12, 2185, 275, 4488, 14, 21430, 342, 199, 1190, 795, 12, 9220, 83, 275, 299, 3893, 63, 3029, 84, 9804, 8, 1773, 12, 6465, 63, 8160, 29, 549, 12, 307, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 2490, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 13523, 29, 549, 12, 31055, 29, 4510, 83, 12, 2490, 302, 63, 6920, 29, 17, 9, 199, 1190, 795 ]
[ 199, 12813, 389, 199, 8564, 314, 7074, 28397, 13650, 402, 3066, 666, 199, 12813, 389, 199, 199, 2765, 2884, 13703, 4212, 370, 4526, 314, 7074, 28397, 13650, 334, 48, 3693, 9, 199, 1618, 32619, 641, 282, 3066, 4789, 14, 2779, 2597, 2498, 314, 7763, 402, 18876, 428, 5763, 199, 475, 314, 666, 370, 7114, 662, 4064, 436, 662, 14008, 27990, 14, 199, 624, 199, 3, 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 15253, 957, 13, 462, 374, 15970, 14, 4391, 30, 199, 3, 3515, 603, 26788, 491, 10138, 338, 665, 757, 10138, 338, 32, 10756, 82, 14, 77, 3561, 14, 8210, 86, 1005, 14, 8654, 30, 199, 3, 3515, 662, 1567, 491, 285, 834, 665, 9828, 834, 14, 281, 530, 14, 68, 32, 6799, 14, 957, 30, 199, 3, 844, 26, 6289, 334, 19, 13, 8501, 9, 199, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 646, 18250, 199, 504, 18250, 492, 5890, 12, 1586, 63, 5468, 12, 1586, 63, 5592, 199, 504, 18250, 14, 12281, 492, 2690, 199, 504, 18250, 14, 521, 63, 11132, 492, 299, 3893, 63, 3029, 84, 9804, 199, 199, 1361, 3460, 1301, 3368, 199, 199, 11490, 199, 3, 2494, 2633, 199, 576, 63, 515, 275, 2690, 14, 576, 63, 515, 342, 199, 1773, 63, 5252, 275, 666, 63, 515, 435, 1994, 3635, 39, 15, 3271, 15, 3271, 63, 32024, 5068, 63, 1773, 14, 25533, 7, 199, 5468, 63, 5252, 275, 666, 63, 515, 435, 1994, 3635, 39, 15, 3271, 15, 3271, 63, 32024, 5068, 63, 69, 974, 13, 5468, 14, 25533, 7, 199, 199, 84, 827, 12, 307, 988, 275, 378, 12, 5212, 221, 327, 675, 314, 1642, 5212, 83, 402, 666, 199, 199, 3, 12439, 367, 7664, 314, 3066, 666, 334, 475, 3354, 4402, 12, 18366, 2544, 8697, 9, 199, 1773, 275, 5890, 14, 739, 63, 1773, 63, 25533, 8, 1773, 63, 5252, 680, 15816, 8, 84, 827, 12, 307, 988, 680, 912, 63, 576, 342, 199, 1773, 14, 815, 459, 4087, 83, 418, 847, 788, 3635, 39, 499, 16284, 297, 283, 37, 4680, 378, 2481, 418, 221, 327, 4875, 83, 435, 499, 1655, 199, 199, 3, 2654, 428, 5763, 14777, 11102, 370, 7114, 662, 14008, 436, 662, 4064, 27990, 199, 496, 3596, 275, 1586, 63, 5468, 8, 5468, 63, 5252, 9, 199, 1773, 14, 525, 63, 5468, 8, 496, 3596, 12, 2813, 63, 5952, 29, 549, 9, 421, 199, 70, 827, 12, 289, 988, 275, 499, 12, 9601, 221, 327, 3648, 737, 22411, 3382, 499, 436, 9601, 13026, 199, 78, 63, 9996, 275, 18427, 221, 327, 314, 29484, 1568, 334, 78, 63, 9996, 680, 473, 271, 1183, 282, 7074, 402, 499, 199, 199, 3, 12230, 1159, 1642, 1104, 734, 1006, 3623, 2943, 199, 1773, 14, 2798, 63, 31600, 8, 6789, 63, 632, 534, 1842, 297, 307, 988, 29, 709, 14, 16, 12, 2498, 29, 797, 9, 199, 199, 3, 7356, 4691, 1159, 16470, 641, 282, 12700, 10026, 26, 199, 3, 16568, 603, 4680, 15916, 386, 1377, 878, 315, 314, 29350, 13, 30574, 4897, 199, 5592, 275, 1586, 63, 5592, 360, 8185, 13, 30574, 358, 199, 4510, 83, 275, 18250, 14, 4510, 63, 1313, 8, 1773, 14, 815, 12, 562, 71, 534, 5615, 297, 325, 5902, 29, 797, 12, 325, 974, 29, 797, 12, 2432, 29965, 29, 797, 12, 5760, 534, 4087, 83, 297, 7267, 29, 5592, 9, 199, 199, 3, 12230, 1159, 2951, 3648, 737, 314, 1642, 9284, 9245, 367, 23789, 270, 1754, 12901, 199, 4510, 83, 275, 31055, 1491, 20, 61, 199, 199, 6003, 14, 8941, 342, 199, 1219, 275, 4488, 14, 6402, 342, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 797, 12, 2185, 29, 1219, 12, 3164, 2687, 16, 12, 378, 12, 413, 395, 221, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 3, 6061, 3063, 886, 314, 2011, 543, 428, 5763, 6781, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 549, 12, 2185, 29, 1219, 12, 3164, 2687, 16, 12, 413, 12, 378, 395, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 3, 6061, 3063, 886, 314, 2011, 543, 428, 5763, 435, 440, 335, 14545, 199, 3, 16568, 1006, 9245, 367, 440, 335, 3967, 314, 428, 5763, 14777, 13667, 397, 9245, 10451, 199, 1773, 14, 1397, 335, 63, 1541, 8, 1590, 14, 5605, 8, 2259, 12, 499, 2953, 12, 5212, 395, 302, 63, 6920, 29, 17, 9, 199, 1773, 14, 2798, 63, 31600, 8, 84, 827, 29, 84, 827, 12, 307, 988, 29, 84, 988, 12, 289, 827, 29, 70, 827, 12, 289, 988, 29, 70, 988, 12, 302, 63, 9996, 29, 78, 63, 9996, 12, 1467, 302, 63, 6920, 29, 17, 12, 13523, 29, 549, 12, 2185, 29, 1219, 12, 3164, 2687, 17, 12, 378, 12, 378, 395, 31055, 29, 4510, 83, 12, 1467, 2498, 29, 797, 9, 199, 199, 1219, 14, 409, 63, 1213, 360, 24766, 3602, 13, 30574, 15916, 386, 1377, 878, 358, 199, 6003, 14, 10231, 2941, 12450, 428, 5763, 297, 283, 3007, 428, 5763, 297, 283, 2300, 48, 435, 2832, 335, 1105, 199, 199, 3, 26776, 12, 1265, 1443, 2597, 1218, 510, 3693, 83, 687, 13480, 2251, 543, 1124, 31600, 15192, 1040, 199, 70, 12, 2185, 275, 4488, 14, 21430, 342, 199, 1190, 795, 12, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tcheehow/MissionPlanner
Lib/pprint.py
57
12282
# Author: Fred L. Drake, Jr. # fdrake@acm.org # # This is a simple little module I wrote to make life easier. I didn't # see anything quite like it in the library, though I may have overlooked # something. I wrote this when I was trying to read some heavily nested # tuples with fairly non-descriptive content. This is modeled very much # after Lisp/Scheme - style pretty-printing of lists. If you find it # useful, thank small children who sleep at night. """Support to pretty-print lists, tuples, & dictionaries recursively. Very simple, but useful, especially in debugging data structures. Classes ------- PrettyPrinter() Handle pretty-printing operations onto a stream using a configured set of formatting parameters. Functions --------- pformat() Format a Python object into a pretty-printed representation. pprint() Pretty-print a Python object to a stream [default is sys.stdout]. saferepr() Generate a 'standard' repr()-like value, but protect against recursive data structures. """ import sys as _sys import warnings from cStringIO import StringIO as _StringIO __all__ = ["pprint","pformat","isreadable","isrecursive","saferepr", "PrettyPrinter"] # cache these for faster access: _commajoin = ", ".join _id = id _len = len _type = type def pprint(object, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python object to a stream [default is sys.stdout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(object) def pformat(object, indent=1, width=80, depth=None): """Format a Python object into a pretty-printed representation.""" return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(object) def saferepr(object): """Version of repr() which can handle recursive data structures.""" return _safe_repr(object, {}, None, 0)[0] def isreadable(object): """Determine if saferepr(object) is readable by eval().""" return _safe_repr(object, {}, None, 0)[1] def isrecursive(object): """Determine if object requires a recursive representation.""" return _safe_repr(object, {}, None, 0)[2] def _sorted(iterable): with warnings.catch_warnings(): if _sys.py3kwarning: warnings.filterwarnings("ignore", "comparing unequal types " "not supported", DeprecationWarning) return sorted(iterable) class PrettyPrinter: def __init__(self, indent=1, width=80, depth=None, stream=None): """Handle pretty printing operations onto a stream using a set of configured parameters. indent Number of spaces to indent for each level of nesting. width Attempted maximum number of columns in the output. depth The maximum depth to print out nested structures. stream The desired output stream. If omitted (or false), the standard output stream available at construction will be used. """ indent = int(indent) width = int(width) assert indent >= 0, "indent must be >= 0" assert depth is None or depth > 0, "depth must be > 0" assert width, "width must be != 0" self._depth = depth self._indent_per_level = indent self._width = width if stream is not None: self._stream = stream else: self._stream = _sys.stdout def pprint(self, object): self._format(object, self._stream, 0, 0, {}, 0) self._stream.write("\n") def pformat(self, object): sio = _StringIO() self._format(object, sio, 0, 0, {}, 0) return sio.getvalue() def isrecursive(self, object): return self.format(object, {}, 0, 0)[2] def isreadable(self, object): s, readable, recursive = self.format(object, {}, 0, 0) return readable and not recursive def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write if self._depth and level > self._depth: write(rep) return r = getattr(typ, "__repr__", None) if issubclass(typ, dict) and r is dict.__repr__: write('{') if self._indent_per_level > 1: write((self._indent_per_level - 1) * ' ') length = _len(object) if length: context[objid] = 1 indent = indent + self._indent_per_level items = _sorted(object.items()) key, ent = items[0] rep = self._repr(key, context, level) write(rep) write(': ') self._format(ent, stream, indent + _len(rep) + 2, allowance + 1, context, level) if length > 1: for key, ent in items[1:]: rep = self._repr(key, context, level) if sepLines: write(',\n%s%s: ' % (' '*indent, rep)) else: write(', %s: ' % rep) self._format(ent, stream, indent + _len(rep) + 2, allowance + 1, context, level) indent = indent - self._indent_per_level del context[objid] write('}') return if ((issubclass(typ, list) and r is list.__repr__) or (issubclass(typ, tuple) and r is tuple.__repr__) or (issubclass(typ, set) and r is set.__repr__) or (issubclass(typ, frozenset) and r is frozenset.__repr__) ): length = _len(object) if issubclass(typ, list): write('[') endchar = ']' elif issubclass(typ, set): if not length: write('set()') return write('set([') endchar = '])' object = _sorted(object) indent += 4 elif issubclass(typ, frozenset): if not length: write('frozenset()') return write('frozenset([') endchar = '])' object = _sorted(object) indent += 10 else: write('(') endchar = ')' if self._indent_per_level > 1 and sepLines: write((self._indent_per_level - 1) * ' ') if length: context[objid] = 1 indent = indent + self._indent_per_level self._format(object[0], stream, indent, allowance + 1, context, level) if length > 1: for ent in object[1:]: if sepLines: write(',\n' + ' '*indent) else: write(', ') self._format(ent, stream, indent, allowance + 1, context, level) indent = indent - self._indent_per_level del context[objid] if issubclass(typ, tuple) and length == 1: write(',') write(endchar) return write(rep) def _repr(self, object, context, level): repr, readable, recursive = self.format(object, context.copy(), self._depth, level) if not readable: self._readable = False if recursive: self._recursive = True return repr def format(self, object, context, maxlevels, level): """Format object for a specific context, returning a string and flags indicating whether the representation is 'readable' and whether the object represents a recursive construct. """ return _safe_repr(object, context, maxlevels, level) # Return triple (repr_string, isreadable, isrecursive). def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return repr(object), True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, repr(char)[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False r = getattr(typ, "__repr__", None) if issubclass(typ, dict) and r is dict.__repr__: if not object: return "{}", True, False objid = _id(object) if maxlevels and level >= maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in _sorted(object.items()): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if (issubclass(typ, list) and r is list.__repr__) or \ (issubclass(typ, tuple) and r is tuple.__repr__): if issubclass(typ, list): if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level >= maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = repr(object) return rep, (rep and not rep.startswith('<')), False def _recursion(object): return ("<Recursion on %s with id=%s>" % (_type(object).__name__, _id(object))) def _perfcheck(object=None): import time if object is None: object = [("string", (1, 2), [3, 4], {5: 6, 7: 8})] * 100000 p = PrettyPrinter() t1 = time.time() _safe_repr(object, {}, None, 0) t2 = time.time() p.pformat(object) t3 = time.time() print "_safe_repr:", t2 - t1 print "pformat:", t3 - t2 if __name__ == "__main__": _perfcheck()
gpl-3.0
[ 3, 221, 6529, 26, 420, 481, 581, 491, 14, 577, 345, 415, 12, 1603, 82, 14, 202, 199, 3, 5185, 6111, 345, 415, 32, 645, 77, 14, 1308, 202, 199, 3, 202, 199, 3, 221, 961, 365, 282, 3486, 12050, 859, 473, 336, 22665, 370, 1852, 15451, 14905, 14, 221, 473, 9980, 1133, 202, 199, 3, 221, 1937, 7003, 18794, 2839, 652, 315, 314, 3555, 12, 10617, 473, 1443, 1172, 1806, 320, 7620, 202, 199, 3, 221, 6020, 14, 221, 473, 336, 22665, 642, 1380, 473, 1990, 9936, 370, 1586, 2005, 946, 1214, 3444, 6032, 202, 199, 3, 221, 6346, 543, 28092, 590, 2222, 13, 271, 729, 21701, 1564, 14, 221, 961, 365, 818, 1146, 7437, 8298, 202, 199, 3, 221, 2410, 491, 27474, 15, 19530, 446, 3449, 7268, 13, 26514, 402, 5548, 14, 221, 982, 1265, 2342, 652, 202, 199, 3, 221, 2997, 12, 2419, 75, 7425, 4978, 3963, 9435, 737, 302, 1070, 14, 2999, 199, 624, 11532, 370, 7268, 13, 1361, 5548, 12, 6346, 12, 1253, 11196, 15035, 14, 2999, 199, 54, 994, 3486, 12, 1325, 2997, 12, 24002, 315, 10201, 666, 13955, 14, 2999, 199, 15711, 202, 199, 12797, 2999, 199, 27153, 14131, 342, 1128, 8690, 7268, 13, 26514, 5331, 14602, 282, 2547, 1808, 282, 7526, 1128, 663, 402, 10803, 2633, 14, 2999, 199, 13967, 202, 199, 9960, 2999, 199, 24225, 342, 1128, 9701, 282, 2018, 909, 1901, 282, 7268, 13, 27131, 6025, 14, 2999, 199, 15380, 342, 1128, 31651, 13, 1361, 282, 2018, 909, 370, 282, 2547, 359, 885, 365, 984, 14, 2703, 1055, 2999, 199, 3489, 2722, 342, 1128, 7958, 282, 283, 6807, 7, 4700, 22251, 2930, 574, 12, 1325, 25863, 6169, 9133, 1128, 666, 13955, 14, 2999, 199, 624, 2999, 199, 646, 984, 465, 485, 1274, 202, 199, 646, 3598, 2999, 199, 504, 15073, 492, 5228, 465, 485, 6424, 2999, 199, 363, 452, 363, 275, 2097, 15380, 2266, 24225, 2266, 374, 11875, 2266, 374, 9931, 2266, 3489, 2722, 401, 18691, 298, 27153, 14131, 937, 2999, 199, 3, 2581, 3520, 367, 12930, 2879, 26, 202, 199, 63, 13184, 904, 275, 3872, 3680, 904, 202, 199, 63, 344, 275, 1305, 202, 199, 63, 552, 275, 822, 202, 199, 63, 466, 275, 730, 8065, 199, 318, 10933, 8, 785, 12, 2547, 29, 403, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 304, 1128, 408, 27153, 13, 1361, 282, 2018, 909, 370, 282, 2547, 359, 885, 365, 984, 14, 2703, 61, 1041, 1128, 16639, 275, 31651, 14131, 8, 1039, 2547, 29, 1745, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 5818, 29, 4631, 9, 1128, 16639, 14, 15380, 8, 785, 9, 2999, 199, 318, 30843, 8, 785, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 304, 1128, 408, 3484, 282, 2018, 909, 1901, 282, 7268, 13, 27131, 6025, 1041, 1128, 372, 31651, 14131, 8, 3724, 29, 3724, 12, 3462, 29, 2063, 12, 5818, 29, 4631, 680, 24225, 8, 785, 9, 2999, 199, 318, 5048, 2722, 8, 785, 304, 1128, 408, 3353, 402, 4700, 342, 1314, 883, 2429, 9133, 666, 13955, 1041, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 16, 61, 2999, 199, 318, 365, 11875, 8, 785, 304, 1128, 408, 21767, 340, 5048, 2722, 8, 785, 9, 365, 12701, 701, 3468, 20693, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 17, 61, 2999, 199, 318, 365, 9931, 8, 785, 304, 1128, 408, 21767, 340, 909, 5074, 282, 9133, 6025, 1041, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 18, 61, 2999, 199, 318, 485, 5917, 8, 8147, 304, 1128, 543, 3598, 14, 9341, 63, 5451, 837, 1039, 340, 485, 1274, 14, 647, 19, 829, 1791, 26, 1675, 3598, 14, 23945, 480, 4247, 401, 298, 863, 9332, 625, 1452, 2943, 298, 202, 2511, 298, 1397, 3748, 401, 13413, 9, 1039, 372, 3355, 8, 8147, 9, 2999, 199, 533, 31651, 14131, 26, 1128, 347, 636, 826, 721, 277, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 12, 2547, 29, 403, 304, 1039, 408, 5940, 7268, 16116, 5331, 14602, 282, 2547, 1808, 282, 663, 402, 1039, 7526, 2633, 14, 4341, 4363, 1675, 4860, 402, 7883, 370, 4363, 367, 1924, 2166, 402, 19500, 14, 4341, 3462, 1675, 17413, 471, 5696, 1329, 402, 4362, 315, 314, 1072, 14, 4341, 5818, 1675, 710, 5696, 5818, 370, 870, 734, 6032, 13955, 14, 4341, 2547, 1675, 710, 6387, 1072, 2547, 14, 221, 982, 11684, 334, 269, 3055, 395, 314, 4465, 1675, 1072, 2547, 2808, 737, 14538, 911, 506, 1202, 14, 4341, 408, 1039, 4363, 275, 1109, 8, 3724, 9, 1039, 3462, 275, 1109, 8, 2063, 9, 1039, 702, 4363, 2356, 378, 12, 298, 3724, 1471, 506, 2356, 378, 2, 1039, 702, 5818, 365, 488, 503, 5818, 690, 378, 12, 298, 4631, 1471, 506, 690, 378, 2, 1039, 702, 3462, 12, 298, 2063, 1471, 506, 1137, 378, 2, 1039, 291, 423, 4631, 275, 5818, 1039, 291, 423, 3724, 63, 529, 63, 1896, 275, 4363, 1039, 291, 423, 2063, 275, 3462, 1039, 340, 2547, 365, 440, 488, 26, 1675, 291, 423, 1745, 275, 2547, 1039, 587, 26, 1675, 291, 423, 1745, 275, 485, 1274, 14, 2703, 2958, 347, 10933, 8, 277, 12, 909, 304, 1039, 291, 423, 908, 8, 785, 12, 291, 423, 1745, 12, 378, 12, 378, 12, 5479, 378, 9, 1039, 291, 423, 1745, 14, 952, 4582, 78, 531, 2958, 347, 30843, 8, 277, 12, 909, 304, 1039, 29129, 275, 485, 6424, 342, 1039, 291, 423, 908, 8, 785, 12, 29129, 12, 378, 12, 378, 12, 5479, 378, 9, 1039, 372, 29129, 14, 7150, 342, 2958, 347, 365, 9931, 8, 277, 12, 909, 304, 1039, 372, 291, 14, 908, 8, 785, 12, 5479, 378, 12, 378, 2788, 18, 61, 2958, 347, 365, 11875, 8, 277, 12, 909, 304, 1039, 308, 12, 12701, 12, 9133, 275, 291, 14, 908, 8, 785, 12, 5479, 378, 12, 378, 9, 1039, 372, 12701, 436, 440, 9133, 2958, 347, 485, 908, 8, 277, 12, 909, 12, 2547, 12, 4363, 12, 2040, 554, 12, 1067, 12, 2166, 304, 1039, 2166, 275, 2166, 435, 413 ]
[ 221, 6529, 26, 420, 481, 581, 491, 14, 577, 345, 415, 12, 1603, 82, 14, 202, 199, 3, 5185, 6111, 345, 415, 32, 645, 77, 14, 1308, 202, 199, 3, 202, 199, 3, 221, 961, 365, 282, 3486, 12050, 859, 473, 336, 22665, 370, 1852, 15451, 14905, 14, 221, 473, 9980, 1133, 202, 199, 3, 221, 1937, 7003, 18794, 2839, 652, 315, 314, 3555, 12, 10617, 473, 1443, 1172, 1806, 320, 7620, 202, 199, 3, 221, 6020, 14, 221, 473, 336, 22665, 642, 1380, 473, 1990, 9936, 370, 1586, 2005, 946, 1214, 3444, 6032, 202, 199, 3, 221, 6346, 543, 28092, 590, 2222, 13, 271, 729, 21701, 1564, 14, 221, 961, 365, 818, 1146, 7437, 8298, 202, 199, 3, 221, 2410, 491, 27474, 15, 19530, 446, 3449, 7268, 13, 26514, 402, 5548, 14, 221, 982, 1265, 2342, 652, 202, 199, 3, 221, 2997, 12, 2419, 75, 7425, 4978, 3963, 9435, 737, 302, 1070, 14, 2999, 199, 624, 11532, 370, 7268, 13, 1361, 5548, 12, 6346, 12, 1253, 11196, 15035, 14, 2999, 199, 54, 994, 3486, 12, 1325, 2997, 12, 24002, 315, 10201, 666, 13955, 14, 2999, 199, 15711, 202, 199, 12797, 2999, 199, 27153, 14131, 342, 1128, 8690, 7268, 13, 26514, 5331, 14602, 282, 2547, 1808, 282, 7526, 1128, 663, 402, 10803, 2633, 14, 2999, 199, 13967, 202, 199, 9960, 2999, 199, 24225, 342, 1128, 9701, 282, 2018, 909, 1901, 282, 7268, 13, 27131, 6025, 14, 2999, 199, 15380, 342, 1128, 31651, 13, 1361, 282, 2018, 909, 370, 282, 2547, 359, 885, 365, 984, 14, 2703, 1055, 2999, 199, 3489, 2722, 342, 1128, 7958, 282, 283, 6807, 7, 4700, 22251, 2930, 574, 12, 1325, 25863, 6169, 9133, 1128, 666, 13955, 14, 2999, 199, 624, 2999, 199, 646, 984, 465, 485, 1274, 202, 199, 646, 3598, 2999, 199, 504, 15073, 492, 5228, 465, 485, 6424, 2999, 199, 363, 452, 363, 275, 2097, 15380, 2266, 24225, 2266, 374, 11875, 2266, 374, 9931, 2266, 3489, 2722, 401, 18691, 298, 27153, 14131, 937, 2999, 199, 3, 2581, 3520, 367, 12930, 2879, 26, 202, 199, 63, 13184, 904, 275, 3872, 3680, 904, 202, 199, 63, 344, 275, 1305, 202, 199, 63, 552, 275, 822, 202, 199, 63, 466, 275, 730, 8065, 199, 318, 10933, 8, 785, 12, 2547, 29, 403, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 304, 1128, 408, 27153, 13, 1361, 282, 2018, 909, 370, 282, 2547, 359, 885, 365, 984, 14, 2703, 61, 1041, 1128, 16639, 275, 31651, 14131, 8, 1039, 2547, 29, 1745, 12, 4363, 29, 3724, 12, 3462, 29, 2063, 12, 5818, 29, 4631, 9, 1128, 16639, 14, 15380, 8, 785, 9, 2999, 199, 318, 30843, 8, 785, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 304, 1128, 408, 3484, 282, 2018, 909, 1901, 282, 7268, 13, 27131, 6025, 1041, 1128, 372, 31651, 14131, 8, 3724, 29, 3724, 12, 3462, 29, 2063, 12, 5818, 29, 4631, 680, 24225, 8, 785, 9, 2999, 199, 318, 5048, 2722, 8, 785, 304, 1128, 408, 3353, 402, 4700, 342, 1314, 883, 2429, 9133, 666, 13955, 1041, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 16, 61, 2999, 199, 318, 365, 11875, 8, 785, 304, 1128, 408, 21767, 340, 5048, 2722, 8, 785, 9, 365, 12701, 701, 3468, 20693, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 17, 61, 2999, 199, 318, 365, 9931, 8, 785, 304, 1128, 408, 21767, 340, 909, 5074, 282, 9133, 6025, 1041, 1128, 372, 485, 3489, 63, 2722, 8, 785, 12, 5479, 488, 12, 378, 2788, 18, 61, 2999, 199, 318, 485, 5917, 8, 8147, 304, 1128, 543, 3598, 14, 9341, 63, 5451, 837, 1039, 340, 485, 1274, 14, 647, 19, 829, 1791, 26, 1675, 3598, 14, 23945, 480, 4247, 401, 298, 863, 9332, 625, 1452, 2943, 298, 202, 2511, 298, 1397, 3748, 401, 13413, 9, 1039, 372, 3355, 8, 8147, 9, 2999, 199, 533, 31651, 14131, 26, 1128, 347, 636, 826, 721, 277, 12, 4363, 29, 17, 12, 3462, 29, 1257, 12, 5818, 29, 403, 12, 2547, 29, 403, 304, 1039, 408, 5940, 7268, 16116, 5331, 14602, 282, 2547, 1808, 282, 663, 402, 1039, 7526, 2633, 14, 4341, 4363, 1675, 4860, 402, 7883, 370, 4363, 367, 1924, 2166, 402, 19500, 14, 4341, 3462, 1675, 17413, 471, 5696, 1329, 402, 4362, 315, 314, 1072, 14, 4341, 5818, 1675, 710, 5696, 5818, 370, 870, 734, 6032, 13955, 14, 4341, 2547, 1675, 710, 6387, 1072, 2547, 14, 221, 982, 11684, 334, 269, 3055, 395, 314, 4465, 1675, 1072, 2547, 2808, 737, 14538, 911, 506, 1202, 14, 4341, 408, 1039, 4363, 275, 1109, 8, 3724, 9, 1039, 3462, 275, 1109, 8, 2063, 9, 1039, 702, 4363, 2356, 378, 12, 298, 3724, 1471, 506, 2356, 378, 2, 1039, 702, 5818, 365, 488, 503, 5818, 690, 378, 12, 298, 4631, 1471, 506, 690, 378, 2, 1039, 702, 3462, 12, 298, 2063, 1471, 506, 1137, 378, 2, 1039, 291, 423, 4631, 275, 5818, 1039, 291, 423, 3724, 63, 529, 63, 1896, 275, 4363, 1039, 291, 423, 2063, 275, 3462, 1039, 340, 2547, 365, 440, 488, 26, 1675, 291, 423, 1745, 275, 2547, 1039, 587, 26, 1675, 291, 423, 1745, 275, 485, 1274, 14, 2703, 2958, 347, 10933, 8, 277, 12, 909, 304, 1039, 291, 423, 908, 8, 785, 12, 291, 423, 1745, 12, 378, 12, 378, 12, 5479, 378, 9, 1039, 291, 423, 1745, 14, 952, 4582, 78, 531, 2958, 347, 30843, 8, 277, 12, 909, 304, 1039, 29129, 275, 485, 6424, 342, 1039, 291, 423, 908, 8, 785, 12, 29129, 12, 378, 12, 378, 12, 5479, 378, 9, 1039, 372, 29129, 14, 7150, 342, 2958, 347, 365, 9931, 8, 277, 12, 909, 304, 1039, 372, 291, 14, 908, 8, 785, 12, 5479, 378, 12, 378, 2788, 18, 61, 2958, 347, 365, 11875, 8, 277, 12, 909, 304, 1039, 308, 12, 12701, 12, 9133, 275, 291, 14, 908, 8, 785, 12, 5479, 378, 12, 378, 9, 1039, 372, 12701, 436, 440, 9133, 2958, 347, 485, 908, 8, 277, 12, 909, 12, 2547, 12, 4363, 12, 2040, 554, 12, 1067, 12, 2166, 304, 1039, 2166, 275, 2166, 435, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sileht/deb-openstack-keystone
keystone/contrib/ec2/backends/kvs.py
2
1772
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2012 OpenStack LLC # # 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 keystone.common import kvs class Ec2(kvs.Base): # Public interface def get_credential(self, credential_id): credential_ref = self.db.get('credential-%s' % credential_id) return credential_ref def list_credentials(self, user_id): credential_ids = self.db.get('credential_list', []) rv = [self.get_credential(x) for x in credential_ids] return [x for x in rv if x['user_id'] == user_id] # CRUD def create_credential(self, credential_id, credential): self.db.set('credential-%s' % credential_id, credential) credential_list = set(self.db.get('credential_list', [])) credential_list.add(credential_id) self.db.set('credential_list', list(credential_list)) return credential def delete_credential(self, credential_id): old_credential = self.db.get('credential-%s' % credential_id) self.db.delete('credential-%s' % credential_id) credential_list = set(self.db.get('credential_list', [])) credential_list.remove(credential_id) self.db.set('credential_list', list(credential_list)) return None
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 14260, 20376, 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, 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, 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, 19395, 14, 2330, 492, 1022, 3122, 421, 199, 533, 662, 67, 18, 8, 30862, 14, 1563, 304, 272, 327, 1684, 3217, 272, 347, 664, 63, 15591, 8, 277, 12, 16338, 63, 344, 304, 267, 16338, 63, 1121, 275, 291, 14, 697, 14, 362, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 372, 16338, 63, 1121, 339, 347, 769, 63, 6942, 8, 277, 12, 922, 63, 344, 304, 267, 16338, 63, 1580, 275, 291, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 3073, 267, 4336, 275, 359, 277, 14, 362, 63, 15591, 8, 88, 9, 367, 671, 315, 16338, 63, 1580, 61, 267, 372, 359, 88, 367, 671, 315, 4336, 340, 671, 459, 751, 63, 344, 418, 508, 922, 63, 344, 61, 339, 327, 17101, 3383, 272, 347, 1218, 63, 15591, 8, 277, 12, 16338, 63, 344, 12, 16338, 304, 267, 291, 14, 697, 14, 409, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 12, 16338, 9, 267, 16338, 63, 513, 275, 663, 8, 277, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 15927, 267, 16338, 63, 513, 14, 525, 8, 15591, 63, 344, 9, 267, 291, 14, 697, 14, 409, 360, 15591, 63, 513, 297, 769, 8, 15591, 63, 513, 430, 267, 372, 16338, 339, 347, 3145, 63, 15591, 8, 277, 12, 16338, 63, 344, 304, 267, 2269, 63, 15591, 275, 291, 14, 697, 14, 362, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 291, 14, 697, 14, 1807, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 16338, 63, 513, 275, 663, 8, 277, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 15927, 267, 16338, 63, 513, 14, 2168, 8, 15591, 63, 344, 9, 267, 291, 14, 697, 14, 409, 360, 15591, 63, 513, 297, 769, 8, 15591, 63, 513, 430, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 14260, 20376, 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, 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, 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, 19395, 14, 2330, 492, 1022, 3122, 421, 199, 533, 662, 67, 18, 8, 30862, 14, 1563, 304, 272, 327, 1684, 3217, 272, 347, 664, 63, 15591, 8, 277, 12, 16338, 63, 344, 304, 267, 16338, 63, 1121, 275, 291, 14, 697, 14, 362, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 372, 16338, 63, 1121, 339, 347, 769, 63, 6942, 8, 277, 12, 922, 63, 344, 304, 267, 16338, 63, 1580, 275, 291, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 3073, 267, 4336, 275, 359, 277, 14, 362, 63, 15591, 8, 88, 9, 367, 671, 315, 16338, 63, 1580, 61, 267, 372, 359, 88, 367, 671, 315, 4336, 340, 671, 459, 751, 63, 344, 418, 508, 922, 63, 344, 61, 339, 327, 17101, 3383, 272, 347, 1218, 63, 15591, 8, 277, 12, 16338, 63, 344, 12, 16338, 304, 267, 291, 14, 697, 14, 409, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 12, 16338, 9, 267, 16338, 63, 513, 275, 663, 8, 277, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 15927, 267, 16338, 63, 513, 14, 525, 8, 15591, 63, 344, 9, 267, 291, 14, 697, 14, 409, 360, 15591, 63, 513, 297, 769, 8, 15591, 63, 513, 430, 267, 372, 16338, 339, 347, 3145, 63, 15591, 8, 277, 12, 16338, 63, 344, 304, 267, 2269, 63, 15591, 275, 291, 14, 697, 14, 362, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 291, 14, 697, 14, 1807, 360, 15591, 3295, 83, 7, 450, 16338, 63, 344, 9, 267, 16338, 63, 513, 275, 663, 8, 277, 14, 697, 14, 362, 360, 15591, 63, 513, 297, 15927, 267, 16338, 63, 513, 14, 2168, 8, 15591, 63, 344, 9, 267, 291, 14, 697, 14, 409, 360, 15591, 63, 513, 297, 769, 8, 15591, 63, 513, 430, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
lqp276/repo_lqp
repopy/src/program/IpReqServer.py
1
1468
''' Created on Sep 27, 2018 @author: lqp ''' import os from os import environ from flask.app import Flask from util.TrackUtil import current_milli_time import json from flask.globals import request from util.logger import mainLogger from util import TrackUtil from flask import logging rootDir = '../..' if 'rootDir' in environ: rootDir = environ['rootDir'] print("rootDir: " + os.path.abspath(rootDir)) os.chdir(rootDir) app = Flask(__name__) logger = mainLogger() infoDoc = {} def trimInfoDoc(): toDel = [] for name in infoDoc: if infoDoc[name]['ts'] + TrackUtil.oneDayMillis() < current_milli_time(): toDel.append(name) for name in toDel: del infoDoc[name] @app.route('/api/report', methods=['POST']) def handleReport(): body = json.loads(request.data) logger.info('[%s] -> [%s]: %s' % (request.remote_addr, request.url, json.dumps(body))) name = body['name'] now = current_milli_time() if name not in infoDoc: infoDoc[name] = {'info': body['info'], 'ts': now} else: infoDoc[name]['info'] = body['info'] infoDoc[name]['ts'] = now trimInfoDoc() return 'success' @app.route('/api/query', methods=['GET']) def queryInfo(): trimInfoDoc() return json.dumps(infoDoc, indent=4) if __name__ == '__main__': log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) app.run('0.0.0.0', 59477, threaded=True) pass
gpl-2.0
[ 2344, 199, 10502, 641, 428, 1545, 8087, 12, 14894, 199, 199, 32, 2502, 26, 634, 15202, 199, 2344, 199, 199, 646, 747, 199, 504, 747, 492, 6160, 199, 504, 7209, 14, 571, 492, 16704, 199, 504, 4884, 14, 7927, 9562, 492, 1453, 63, 19579, 63, 521, 199, 646, 2022, 199, 504, 7209, 14, 8473, 492, 1056, 199, 504, 4884, 14, 2921, 492, 2446, 4455, 199, 504, 4884, 492, 17507, 9562, 199, 504, 7209, 492, 2050, 199, 199, 1231, 3567, 275, 20644, 703, 7, 199, 692, 283, 1231, 3567, 7, 315, 6160, 26, 272, 1738, 3567, 275, 6160, 459, 1231, 3567, 418, 1362, 199, 1361, 480, 1231, 3567, 26, 298, 435, 747, 14, 515, 14, 4832, 8, 1231, 3567, 430, 199, 736, 14, 8563, 8, 1231, 3567, 9, 199, 199, 571, 275, 16704, 3460, 354, 3368, 199, 2921, 275, 2446, 4455, 342, 199, 199, 815, 3768, 275, 1052, 199, 199, 318, 11639, 2354, 3768, 837, 272, 370, 6994, 275, 942, 272, 367, 536, 315, 2256, 3768, 26, 267, 340, 2256, 3768, 59, 354, 2733, 1086, 418, 435, 17507, 9562, 14, 368, 12631, 30145, 83, 342, 665, 1453, 63, 19579, 63, 521, 837, 288, 370, 6994, 14, 740, 8, 354, 9, 2286, 367, 536, 315, 370, 6994, 26, 267, 2150, 2256, 3768, 59, 354, 61, 199, 199, 32, 571, 14, 4449, 2336, 1246, 15, 3070, 297, 3102, 2968, 4030, 1105, 199, 318, 2429, 7457, 837, 272, 2396, 275, 2022, 14, 3640, 8, 1069, 14, 576, 9, 272, 2512, 14, 815, 360, 9722, 83, 61, 1035, 8978, 83, 2189, 450, 83, 7, 450, 334, 1069, 14, 3846, 63, 2697, 12, 1056, 14, 633, 12, 2022, 14, 4180, 8, 2030, 1724, 2286, 536, 275, 2396, 459, 354, 418, 272, 3063, 275, 1453, 63, 19579, 63, 521, 342, 272, 340, 536, 440, 315, 2256, 3768, 26, 267, 2256, 3768, 59, 354, 61, 275, 791, 815, 356, 2396, 459, 815, 995, 283, 1086, 356, 3063, 93, 272, 587, 26, 267, 2256, 3768, 59, 354, 2733, 815, 418, 275, 2396, 459, 815, 418, 267, 2256, 3768, 59, 354, 2733, 1086, 418, 275, 3063, 2286, 11639, 2354, 3768, 342, 272, 372, 283, 3742, 7, 199, 199, 32, 571, 14, 4449, 2336, 1246, 15, 1131, 297, 3102, 2968, 2970, 1105, 199, 318, 1827, 2354, 837, 272, 11639, 2354, 3768, 342, 272, 372, 2022, 14, 4180, 8, 815, 3768, 12, 4363, 29, 20, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 943, 275, 2050, 14, 5572, 360, 17719, 358, 272, 943, 14, 13548, 8, 4806, 14, 3170, 9, 2286, 1145, 14, 1065, 360, 16, 14, 16, 14, 16, 14, 16, 297, 959, 2635, 1138, 12, 25396, 29, 549, 9, 272, 986, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 10502, 641, 428, 1545, 8087, 12, 14894, 199, 199, 32, 2502, 26, 634, 15202, 199, 2344, 199, 199, 646, 747, 199, 504, 747, 492, 6160, 199, 504, 7209, 14, 571, 492, 16704, 199, 504, 4884, 14, 7927, 9562, 492, 1453, 63, 19579, 63, 521, 199, 646, 2022, 199, 504, 7209, 14, 8473, 492, 1056, 199, 504, 4884, 14, 2921, 492, 2446, 4455, 199, 504, 4884, 492, 17507, 9562, 199, 504, 7209, 492, 2050, 199, 199, 1231, 3567, 275, 20644, 703, 7, 199, 692, 283, 1231, 3567, 7, 315, 6160, 26, 272, 1738, 3567, 275, 6160, 459, 1231, 3567, 418, 1362, 199, 1361, 480, 1231, 3567, 26, 298, 435, 747, 14, 515, 14, 4832, 8, 1231, 3567, 430, 199, 736, 14, 8563, 8, 1231, 3567, 9, 199, 199, 571, 275, 16704, 3460, 354, 3368, 199, 2921, 275, 2446, 4455, 342, 199, 199, 815, 3768, 275, 1052, 199, 199, 318, 11639, 2354, 3768, 837, 272, 370, 6994, 275, 942, 272, 367, 536, 315, 2256, 3768, 26, 267, 340, 2256, 3768, 59, 354, 2733, 1086, 418, 435, 17507, 9562, 14, 368, 12631, 30145, 83, 342, 665, 1453, 63, 19579, 63, 521, 837, 288, 370, 6994, 14, 740, 8, 354, 9, 2286, 367, 536, 315, 370, 6994, 26, 267, 2150, 2256, 3768, 59, 354, 61, 199, 199, 32, 571, 14, 4449, 2336, 1246, 15, 3070, 297, 3102, 2968, 4030, 1105, 199, 318, 2429, 7457, 837, 272, 2396, 275, 2022, 14, 3640, 8, 1069, 14, 576, 9, 272, 2512, 14, 815, 360, 9722, 83, 61, 1035, 8978, 83, 2189, 450, 83, 7, 450, 334, 1069, 14, 3846, 63, 2697, 12, 1056, 14, 633, 12, 2022, 14, 4180, 8, 2030, 1724, 2286, 536, 275, 2396, 459, 354, 418, 272, 3063, 275, 1453, 63, 19579, 63, 521, 342, 272, 340, 536, 440, 315, 2256, 3768, 26, 267, 2256, 3768, 59, 354, 61, 275, 791, 815, 356, 2396, 459, 815, 995, 283, 1086, 356, 3063, 93, 272, 587, 26, 267, 2256, 3768, 59, 354, 2733, 815, 418, 275, 2396, 459, 815, 418, 267, 2256, 3768, 59, 354, 2733, 1086, 418, 275, 3063, 2286, 11639, 2354, 3768, 342, 272, 372, 283, 3742, 7, 199, 199, 32, 571, 14, 4449, 2336, 1246, 15, 1131, 297, 3102, 2968, 2970, 1105, 199, 318, 1827, 2354, 837, 272, 11639, 2354, 3768, 342, 272, 372, 2022, 14, 4180, 8, 815, 3768, 12, 4363, 29, 20, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 943, 275, 2050, 14, 5572, 360, 17719, 358, 272, 943, 14, 13548, 8, 4806, 14, 3170, 9, 2286, 1145, 14, 1065, 360, 16, 14, 16, 14, 16, 14, 16, 297, 959, 2635, 1138, 12, 25396, 29, 549, 9, 272, 986, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
brkt/brkt-cli
brkt_cli/aws/test_wrap_guest_image.py
1
9220
# Copyright 2017 Bracket Computing, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. # A copy of the License is located at # # https://github.com/brkt/brkt-cli/blob/master/LICENSE # # or in the "license" file accompanying this file. This file 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 email import json import unittest import zlib import brkt_cli import brkt_cli.aws import brkt_cli.util from brkt_cli.aws import wrap_image from brkt_cli.aws.model import Subnet from brkt_cli.aws.test_aws_service import build_aws_service from brkt_cli.instance_config import ( BRKT_CONFIG_CONTENT_TYPE, INSTANCE_METAVISOR_MODE, ) from brkt_cli.instance_config_args import ( instance_config_args_to_values, instance_config_from_values ) class TestWrappedInstanceName(unittest.TestCase): def test_encrypted_image_suffix(self): """ Test that generated suffixes are unique. """ s1 = wrap_image.get_wrapped_suffix() s2 = wrap_image.get_wrapped_suffix() self.assertNotEqual(s1, s2) class TestException(Exception): pass class TestRunEncryption(unittest.TestCase): def setUp(self): brkt_cli.util.SLEEP_ENABLED = False def test_smoke(self): """ Run the entire process and test that nothing obvious is broken. """ aws_svc, encryptor_image, guest_image = build_aws_service() instance = wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, ) self.assertIsNotNone(instance) def test_wrapped_instance_name(self): """ Test that the wrapped instance is launched with the guest AMI. """ aws_svc, encryptor_image, guest_image = build_aws_service() name = 'Am I an unencrypted guest instance?' instance = wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, wrapped_instance_name=name, ) instance = aws_svc.get_instance(instance.id) self.assertEqual(guest_image.id, instance.image_id) def test_subnet_with_security_groups(self): """ Test that the subnet and security groups are passed to the calls to AWSService.run_instance(). """ def run_instance_callback(args): self.assertEqual('subnet-1', args.subnet_id) self.assertEqual(['sg-1', 'sg-2'], args.security_group_ids) aws_svc, encryptor_image, guest_image = build_aws_service() aws_svc.run_instance_callback = run_instance_callback wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, subnet_id='subnet-1', security_group_ids=['sg-1', 'sg-2'] ) def test_subnet_without_security_groups(self): """ Test that we create the temporary security group in the subnet that the user specified. """ self.security_group_was_created = False def create_security_group_callback(vpc_id): self.security_group_was_created = True self.assertEqual('vpc-1', vpc_id) aws_svc, encryptor_image, guest_image = build_aws_service() aws_svc.create_security_group_callback = \ create_security_group_callback subnet = Subnet() subnet.id = 'subnet-1' subnet.vpc_id = 'vpc-1' aws_svc.subnets = {subnet.id: subnet} wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, subnet_id='subnet-1' ) self.assertTrue(self.security_group_was_created) def test_default_instance_type(self): """ Test that we launch the wrapped guest as m4.large by default """ aws_svc, encryptor_image, guest_image = build_aws_service() def run_instance_callback(args): if args.image_id == guest_image.id: self.assertEqual('m4.large', args.instance_type) elif args.image_id == encryptor_image.id: self.assertEqual('m4.large', args.instance_type) else: self.fail('Unexpected image id: ' + args.image_id) aws_svc.run_instance_callback = run_instance_callback wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, ) def test_guest_instance_type(self): """ Test that we use the specified instance type to launch the wrapped instance. """ aws_svc, encryptor_image, guest_image = build_aws_service() def run_instance_callback(args): if args.image_id == guest_image.id: self.assertEqual('t2.micro', args.instance_type) aws_svc.run_instance_callback = run_instance_callback wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, instance_type='t2.micro' ) def test_invalid_instance_type(self): """ Test that we use the specified instance type to launch the wrapped instance. """ aws_svc, encryptor_image, guest_image = build_aws_service() with self.assertRaises(brkt_cli.validation.ValidationError): brkt_cli.aws._validate( aws_svc, encryptor_image.id, instance_type='t2.nano' ) def test_iam_role(self): """ Test that the IAM role is passed to the calls to AWSService.run_instance(). """ aws_svc, encryptor_image, guest_image = build_aws_service() def run_instance_callback(args): self.assertEqual('valid', args.instance_profile_name) aws_svc.run_instance_callback = run_instance_callback wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, iam='valid' ) class TestBrktEnv(unittest.TestCase): def setUp(self): brkt_cli.util.SLEEP_ENABLED = False def _get_brkt_config_from_mime(self, compressed_mime_data): """Look for a 'brkt-config' part in the multi-part MIME input""" data = zlib.decompress(compressed_mime_data, 16 + zlib.MAX_WBITS) msg = email.message_from_string(data) for part in msg.walk(): if part.get_content_type() == BRKT_CONFIG_CONTENT_TYPE: return part.get_payload(decode=True) self.assertTrue(False, 'Did not find brkt-config part in userdata') def test_brkt_env_wrapped_instance(self): """ Test that we parse the brkt_env value and pass the correct values to user_data when launching the encryptor instance. """ aws_svc, encryptor_image, guest_image = build_aws_service() api_host_port = 'api.example.com:777' hsmproxy_host_port = 'hsmproxy.example.com:888' network_host_port = 'network.example.com:999' values = instance_config_args_to_values('') values.unencrypted_guest = True brkt_env = brkt_cli.BracketEnvironment( api_host='api.example.com', api_port=777, hsmproxy_host='hsmproxy.example.com', hsmproxy_port=888, network_host='network.example.com', network_port=999 ) ic = instance_config_from_values( values, mode=INSTANCE_METAVISOR_MODE, brkt_env=brkt_env) def run_instance_callback(args): if args.image_id == encryptor_image.id: brkt_config = self._get_brkt_config_from_mime(args.user_data) d = json.loads(brkt_config) self.assertEquals( api_host_port, d['brkt']['api_host'] ) self.assertEquals( hsmproxy_host_port, d['brkt']['hsmproxy_host'] ) self.assertEquals( network_host_port, d['brkt']['network_host'] ) self.assertEquals( 'metavisor', d['brkt']['solo_mode'] ) self.assertEquals( True, d['brkt']['allow_unencrypted_guest'] ) aws_svc.run_instance_callback = run_instance_callback wrap_image.launch_wrapped_image( aws_svc=aws_svc, image_id=guest_image.id, metavisor_ami=encryptor_image.id, wrapped_instance_name='Test wrapped instance', instance_config=ic )
apache-2.0
[ 3, 1898, 9708, 32377, 2284, 27799, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3471, 199, 3, 2047, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 437, 1331, 402, 314, 844, 365, 16180, 737, 199, 3, 199, 3, 4178, 921, 5031, 14, 957, 15, 3289, 5973, 15, 3289, 5973, 13, 2764, 15, 6582, 15, 4133, 15, 3961, 199, 3, 199, 3, 503, 315, 314, 298, 1682, 2, 570, 23073, 642, 570, 14, 961, 570, 365, 199, 3, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 199, 3, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 646, 3031, 199, 646, 2022, 199, 646, 2882, 199, 646, 12472, 199, 199, 646, 11665, 5973, 63, 2764, 199, 646, 11665, 5973, 63, 2764, 14, 7231, 199, 646, 11665, 5973, 63, 2764, 14, 1974, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 492, 4816, 63, 1569, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 14, 1238, 492, 4804, 846, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 14, 396, 63, 7231, 63, 1364, 492, 1900, 63, 7231, 63, 1364, 199, 504, 11665, 5973, 63, 2764, 14, 842, 63, 888, 492, 334, 272, 11713, 12362, 63, 5569, 63, 9663, 63, 2711, 12, 272, 20514, 7140, 63, 3940, 6087, 1311, 726, 63, 6963, 12, 199, 9, 199, 504, 11665, 5973, 63, 2764, 14, 842, 63, 888, 63, 589, 492, 334, 272, 1256, 63, 888, 63, 589, 63, 475, 63, 1459, 12, 272, 1256, 63, 888, 63, 504, 63, 1459, 199, 9, 421, 199, 533, 1379, 15991, 1915, 3244, 985, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 15078, 63, 1569, 63, 4511, 8, 277, 304, 267, 408, 1379, 626, 4046, 19475, 787, 3747, 14, 267, 408, 267, 308, 17, 275, 4816, 63, 1569, 14, 362, 63, 9130, 63, 4511, 342, 267, 308, 18, 275, 4816, 63, 1569, 14, 362, 63, 9130, 63, 4511, 342, 267, 291, 14, 7418, 8, 83, 17, 12, 308, 18, 9, 421, 199, 533, 1379, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 2540, 25687, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 11665, 5973, 63, 2764, 14, 1974, 14, 51, 906, 6102, 63, 15704, 275, 756, 339, 347, 511, 63, 30697, 8, 277, 304, 267, 408, 3378, 314, 8039, 2112, 436, 511, 626, 6548, 25259, 365, 10529, 14, 267, 408, 267, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 1256, 275, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 267, 776, 267, 291, 14, 10389, 8, 842, 9, 339, 347, 511, 63, 9130, 63, 842, 63, 354, 8, 277, 304, 267, 408, 1379, 626, 314, 8072, 1256, 365, 27725, 543, 314, 13980, 31694, 14, 267, 408, 267, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 398, 536, 275, 283, 24566, 473, 376, 625, 15078, 13980, 1256, 14069, 267, 1256, 275, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 288, 8072, 63, 842, 63, 354, 29, 354, 12, 267, 776, 267, 1256, 275, 11488, 63, 10599, 14, 362, 63, 842, 8, 842, 14, 344, 9, 267, 291, 14, 629, 8, 10409, 63, 1569, 14, 344, 12, 1256, 14, 1569, 63, 344, 9, 339, 347, 511, 63, 5327, 63, 1045, 63, 4416, 63, 2634, 8, 277, 304, 267, 408, 1379, 626, 314, 6303, 436, 6391, 4652, 787, 3032, 370, 314, 267, 4882, 370, 10168, 3167, 14, 1065, 63, 842, 1252, 267, 408, 398, 347, 1255, 63, 842, 63, 3058, 8, 589, 304, 288, 291, 14, 629, 360, 5327, 13, 17, 297, 1249, 14, 5327, 63, 344, 9, 288, 291, 14, 629, 2941, 1226, 13, 17, 297, 283, 1226, 13, 18, 995, 1249, 14, 4416, 63, 923, 63, 1580, 9, 398, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 11488, 63, 10599, 14, 1065, 63, 842, 63, 3058, 275, 1255, 63, 842, 63, 3058, 267, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 288, 6303, 63, 344, 534, 5327, 13, 17, 297, 288, 6391, 63, 923, 63, 1580, 2968, 1226, 13, 17, 297, 283, 1226, 13, 18, 418, 267, 776, 339, 347, 511, 63, 5327, 63, 7395, 63, 4416, 63, 2634, 8, 277, 304, 267, 408, 1379, 626, 781, 1218, 314, 7937, 6391, 1572, 315, 314, 6303, 267, 626, 314, 922, 2013, 14, 267, 408, 267, 291, 14, 4416, 63, 923, 63, 10274, 63, 3966, 275, 756, 398, 347, 1218, 63, 4416, 63, 923, 63, 3058, 8, 11742, 63, 344, 304, 288, 291, 14, 4416, 63, 923, 63, 10274, 63, 3966, 275, 715, 288, 291, 14, 629, 360, 11742, 13, 17, 297, 12830, 63, 344, 9, 398, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 11488, 63, 10599, 14, 981, 63, 4416, 63, 923, 63, 3058, 275, 971, 288, 1218, 63, 4416, 63, 923, 63, 3058, 398, 6303, 275, 4804, 846, 342, 267, 6303, 14, 344, 275, 283, 5327, 13, 17, 7, 267, 6303, 14, 11742, 63, 344, 275, 283, 11742, 13, 17, 7, 267, 11488, 63, 10599, 14, 14967, 275, 469, 5327, 14, 344, 26, 6303, 93, 398, 4816, 63 ]
[ 1898, 9708, 32377, 2284, 27799, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3471, 199, 3, 2047, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 437, 1331, 402, 314, 844, 365, 16180, 737, 199, 3, 199, 3, 4178, 921, 5031, 14, 957, 15, 3289, 5973, 15, 3289, 5973, 13, 2764, 15, 6582, 15, 4133, 15, 3961, 199, 3, 199, 3, 503, 315, 314, 298, 1682, 2, 570, 23073, 642, 570, 14, 961, 570, 365, 199, 3, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 199, 3, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 646, 3031, 199, 646, 2022, 199, 646, 2882, 199, 646, 12472, 199, 199, 646, 11665, 5973, 63, 2764, 199, 646, 11665, 5973, 63, 2764, 14, 7231, 199, 646, 11665, 5973, 63, 2764, 14, 1974, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 492, 4816, 63, 1569, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 14, 1238, 492, 4804, 846, 199, 504, 11665, 5973, 63, 2764, 14, 7231, 14, 396, 63, 7231, 63, 1364, 492, 1900, 63, 7231, 63, 1364, 199, 504, 11665, 5973, 63, 2764, 14, 842, 63, 888, 492, 334, 272, 11713, 12362, 63, 5569, 63, 9663, 63, 2711, 12, 272, 20514, 7140, 63, 3940, 6087, 1311, 726, 63, 6963, 12, 199, 9, 199, 504, 11665, 5973, 63, 2764, 14, 842, 63, 888, 63, 589, 492, 334, 272, 1256, 63, 888, 63, 589, 63, 475, 63, 1459, 12, 272, 1256, 63, 888, 63, 504, 63, 1459, 199, 9, 421, 199, 533, 1379, 15991, 1915, 3244, 985, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 15078, 63, 1569, 63, 4511, 8, 277, 304, 267, 408, 1379, 626, 4046, 19475, 787, 3747, 14, 267, 408, 267, 308, 17, 275, 4816, 63, 1569, 14, 362, 63, 9130, 63, 4511, 342, 267, 308, 18, 275, 4816, 63, 1569, 14, 362, 63, 9130, 63, 4511, 342, 267, 291, 14, 7418, 8, 83, 17, 12, 308, 18, 9, 421, 199, 533, 1379, 1726, 8, 1726, 304, 272, 986, 421, 199, 533, 1379, 2540, 25687, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 11665, 5973, 63, 2764, 14, 1974, 14, 51, 906, 6102, 63, 15704, 275, 756, 339, 347, 511, 63, 30697, 8, 277, 304, 267, 408, 3378, 314, 8039, 2112, 436, 511, 626, 6548, 25259, 365, 10529, 14, 267, 408, 267, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 1256, 275, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 267, 776, 267, 291, 14, 10389, 8, 842, 9, 339, 347, 511, 63, 9130, 63, 842, 63, 354, 8, 277, 304, 267, 408, 1379, 626, 314, 8072, 1256, 365, 27725, 543, 314, 13980, 31694, 14, 267, 408, 267, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 398, 536, 275, 283, 24566, 473, 376, 625, 15078, 13980, 1256, 14069, 267, 1256, 275, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 288, 8072, 63, 842, 63, 354, 29, 354, 12, 267, 776, 267, 1256, 275, 11488, 63, 10599, 14, 362, 63, 842, 8, 842, 14, 344, 9, 267, 291, 14, 629, 8, 10409, 63, 1569, 14, 344, 12, 1256, 14, 1569, 63, 344, 9, 339, 347, 511, 63, 5327, 63, 1045, 63, 4416, 63, 2634, 8, 277, 304, 267, 408, 1379, 626, 314, 6303, 436, 6391, 4652, 787, 3032, 370, 314, 267, 4882, 370, 10168, 3167, 14, 1065, 63, 842, 1252, 267, 408, 398, 347, 1255, 63, 842, 63, 3058, 8, 589, 304, 288, 291, 14, 629, 360, 5327, 13, 17, 297, 1249, 14, 5327, 63, 344, 9, 288, 291, 14, 629, 2941, 1226, 13, 17, 297, 283, 1226, 13, 18, 995, 1249, 14, 4416, 63, 923, 63, 1580, 9, 398, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 11488, 63, 10599, 14, 1065, 63, 842, 63, 3058, 275, 1255, 63, 842, 63, 3058, 267, 4816, 63, 1569, 14, 9850, 63, 9130, 63, 1569, 8, 288, 11488, 63, 10599, 29, 7231, 63, 10599, 12, 288, 1834, 63, 344, 29, 10409, 63, 1569, 14, 344, 12, 288, 3404, 8286, 63, 13496, 29, 11929, 269, 63, 1569, 14, 344, 12, 288, 6303, 63, 344, 534, 5327, 13, 17, 297, 288, 6391, 63, 923, 63, 1580, 2968, 1226, 13, 17, 297, 283, 1226, 13, 18, 418, 267, 776, 339, 347, 511, 63, 5327, 63, 7395, 63, 4416, 63, 2634, 8, 277, 304, 267, 408, 1379, 626, 781, 1218, 314, 7937, 6391, 1572, 315, 314, 6303, 267, 626, 314, 922, 2013, 14, 267, 408, 267, 291, 14, 4416, 63, 923, 63, 10274, 63, 3966, 275, 756, 398, 347, 1218, 63, 4416, 63, 923, 63, 3058, 8, 11742, 63, 344, 304, 288, 291, 14, 4416, 63, 923, 63, 10274, 63, 3966, 275, 715, 288, 291, 14, 629, 360, 11742, 13, 17, 297, 12830, 63, 344, 9, 398, 11488, 63, 10599, 12, 14645, 269, 63, 1569, 12, 13980, 63, 1569, 275, 1900, 63, 7231, 63, 1364, 342, 267, 11488, 63, 10599, 14, 981, 63, 4416, 63, 923, 63, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
40223108/w18
static/Brython3.1.1-20150328-091302/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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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ashhher3/seaborn
seaborn/tests/test_utils.py
11
11338
"""Tests for plotting utilities.""" import warnings import tempfile import shutil import numpy as np import pandas as pd import matplotlib.pyplot as plt import nose import nose.tools as nt from nose.tools import assert_equal, raises import numpy.testing as npt import pandas.util.testing as pdt from distutils.version import LooseVersion pandas_has_categoricals = LooseVersion(pd.__version__) >= "0.15" from pandas.util.testing import network try: from bs4 import BeautifulSoup except ImportError: BeautifulSoup = None from . import PlotTestCase from .. import utils, rcmod from ..utils import get_dataset_names, load_dataset a_norm = np.random.randn(100) def test_pmf_hist_basics(): """Test the function to return barplot args for pmf hist.""" out = utils.pmf_hist(a_norm) assert_equal(len(out), 3) x, h, w = out assert_equal(len(x), len(h)) # Test simple case a = np.arange(10) x, h, w = utils.pmf_hist(a, 10) nose.tools.assert_true(np.all(h == h[0])) def test_pmf_hist_widths(): """Test histogram width is correct.""" x, h, w = utils.pmf_hist(a_norm) assert_equal(x[1] - x[0], w) def test_pmf_hist_normalization(): """Test that output data behaves like a PMF.""" x, h, w = utils.pmf_hist(a_norm) nose.tools.assert_almost_equal(sum(h), 1) nose.tools.assert_less_equal(h.max(), 1) def test_pmf_hist_bins(): """Test bin specification.""" x, h, w = utils.pmf_hist(a_norm, 20) assert_equal(len(x), 20) def test_ci_to_errsize(): """Test behavior of ci_to_errsize.""" cis = [[.5, .5], [1.25, 1.5]] heights = [1, 1.5] actual_errsize = np.array([[.5, 1], [.25, 0]]) test_errsize = utils.ci_to_errsize(cis, heights) npt.assert_array_equal(actual_errsize, test_errsize) def test_desaturate(): """Test color desaturation.""" out1 = utils.desaturate("red", .5) assert_equal(out1, (.75, .25, .25)) out2 = utils.desaturate("#00FF00", .5) assert_equal(out2, (.25, .75, .25)) out3 = utils.desaturate((0, 0, 1), .5) assert_equal(out3, (.25, .25, .75)) out4 = utils.desaturate("red", .5) assert_equal(out4, (.75, .25, .25)) @raises(ValueError) def test_desaturation_prop(): """Test that pct outside of [0, 1] raises exception.""" utils.desaturate("blue", 50) def test_saturate(): """Test performance of saturation function.""" out = utils.saturate((.75, .25, .25)) assert_equal(out, (1, 0, 0)) def test_iqr(): """Test the IQR function.""" a = np.arange(5) iqr = utils.iqr(a) assert_equal(iqr, 2) class TestSpineUtils(PlotTestCase): sides = ["left", "right", "bottom", "top"] outer_sides = ["top", "right"] inner_sides = ["left", "bottom"] offset = 10 original_position = ("outward", 0) offset_position = ("outward", offset) def test_despine(self): f, ax = plt.subplots() for side in self.sides: nt.assert_true(ax.spines[side].get_visible()) utils.despine() for side in self.outer_sides: nt.assert_true(~ax.spines[side].get_visible()) for side in self.inner_sides: nt.assert_true(ax.spines[side].get_visible()) utils.despine(**dict(zip(self.sides, [True] * 4))) for side in self.sides: nt.assert_true(~ax.spines[side].get_visible()) def test_despine_specific_axes(self): f, (ax1, ax2) = plt.subplots(2, 1) utils.despine(ax=ax2) for side in self.sides: nt.assert_true(ax1.spines[side].get_visible()) for side in self.outer_sides: nt.assert_true(~ax2.spines[side].get_visible()) for side in self.inner_sides: nt.assert_true(ax2.spines[side].get_visible()) def test_despine_with_offset(self): f, ax = plt.subplots() for side in self.sides: nt.assert_equal(ax.spines[side].get_position(), self.original_position) utils.despine(ax=ax, offset=self.offset) for side in self.sides: is_visible = ax.spines[side].get_visible() new_position = ax.spines[side].get_position() if is_visible: nt.assert_equal(new_position, self.offset_position) else: nt.assert_equal(new_position, self.original_position) def test_despine_with_offset_specific_axes(self): f, (ax1, ax2) = plt.subplots(2, 1) utils.despine(offset=self.offset, ax=ax2) for side in self.sides: nt.assert_equal(ax1.spines[side].get_position(), self.original_position) if ax2.spines[side].get_visible(): nt.assert_equal(ax2.spines[side].get_position(), self.offset_position) else: nt.assert_equal(ax2.spines[side].get_position(), self.original_position) def test_despine_trim_spines(self): f, ax = plt.subplots() ax.plot([1, 2, 3], [1, 2, 3]) ax.set_xlim(.75, 3.25) utils.despine(trim=True) for side in self.inner_sides: bounds = ax.spines[side].get_bounds() nt.assert_equal(bounds, (1, 3)) def test_despine_trim_inverted(self): f, ax = plt.subplots() ax.plot([1, 2, 3], [1, 2, 3]) ax.set_ylim(.85, 3.15) ax.invert_yaxis() utils.despine(trim=True) for side in self.inner_sides: bounds = ax.spines[side].get_bounds() nt.assert_equal(bounds, (1, 3)) def test_despine_trim_noticks(self): f, ax = plt.subplots() ax.plot([1, 2, 3], [1, 2, 3]) ax.set_yticks([]) utils.despine(trim=True) nt.assert_equal(ax.get_yticks().size, 0) def test_offset_spines_warns(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always", category=UserWarning) f, ax = plt.subplots() utils.offset_spines(offset=self.offset) nt.assert_true('deprecated' in str(w[0].message)) nt.assert_true(issubclass(w[0].category, UserWarning)) def test_offset_spines(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always", category=UserWarning) f, ax = plt.subplots() for side in self.sides: nt.assert_equal(ax.spines[side].get_position(), self.original_position) utils.offset_spines(offset=self.offset) for side in self.sides: nt.assert_equal(ax.spines[side].get_position(), self.offset_position) def test_offset_spines_specific_axes(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always", category=UserWarning) f, (ax1, ax2) = plt.subplots(2, 1) utils.offset_spines(offset=self.offset, ax=ax2) for side in self.sides: nt.assert_equal(ax1.spines[side].get_position(), self.original_position) nt.assert_equal(ax2.spines[side].get_position(), self.offset_position) def test_ticklabels_overlap(): rcmod.set() f, ax = plt.subplots(figsize=(2, 2)) f.tight_layout() # This gets the Agg renderer working assert not utils.axis_ticklabels_overlap(ax.get_xticklabels()) big_strings = "abcdefgh", "ijklmnop" ax.set_xlim(-.5, 1.5) ax.set_xticks([0, 1]) ax.set_xticklabels(big_strings) assert utils.axis_ticklabels_overlap(ax.get_xticklabels()) x, y = utils.axes_ticklabels_overlap(ax) assert x assert not y def test_categorical_order(): x = ["a", "c", "c", "b", "a", "d"] y = [3, 2, 5, 1, 4] order = ["a", "b", "c", "d"] out = utils.categorical_order(x) nt.assert_equal(out, ["a", "c", "b", "d"]) out = utils.categorical_order(x, order) nt.assert_equal(out, order) out = utils.categorical_order(x, ["b", "a"]) nt.assert_equal(out, ["b", "a"]) out = utils.categorical_order(np.array(x)) nt.assert_equal(out, ["a", "c", "b", "d"]) out = utils.categorical_order(pd.Series(x)) nt.assert_equal(out, ["a", "c", "b", "d"]) out = utils.categorical_order(y) nt.assert_equal(out, [1, 2, 3, 4, 5]) out = utils.categorical_order(np.array(y)) nt.assert_equal(out, [1, 2, 3, 4, 5]) out = utils.categorical_order(pd.Series(y)) nt.assert_equal(out, [1, 2, 3, 4, 5]) if pandas_has_categoricals: x = pd.Categorical(x, order) out = utils.categorical_order(x) nt.assert_equal(out, list(x.categories)) x = pd.Series(x) out = utils.categorical_order(x) nt.assert_equal(out, list(x.cat.categories)) out = utils.categorical_order(x, ["b", "a"]) nt.assert_equal(out, ["b", "a"]) x = ["a", np.nan, "c", "c", "b", "a", "d"] out = utils.categorical_order(x) nt.assert_equal(out, ["a", "c", "b", "d"]) if LooseVersion(pd.__version__) >= "0.15": def check_load_dataset(name): ds = load_dataset(name, cache=False) assert(isinstance(ds, pd.DataFrame)) def check_load_cached_dataset(name): # Test the cacheing using a temporary file. # With Python 3.2+, we could use the tempfile.TemporaryDirectory() # context manager instead of this try...finally statement tmpdir = tempfile.mkdtemp() try: # download and cache ds = load_dataset(name, cache=True, data_home=tmpdir) # use cached version ds2 = load_dataset(name, cache=True, data_home=tmpdir) pdt.assert_frame_equal(ds, ds2) finally: shutil.rmtree(tmpdir) @network(url="https://github.com/mwaskom/seaborn-data") def test_get_dataset_names(): if not BeautifulSoup: raise nose.SkipTest("No BeautifulSoup available for parsing html") names = get_dataset_names() assert(len(names) > 0) assert(u"titanic" in names) @network(url="https://github.com/mwaskom/seaborn-data") def test_load_datasets(): if not BeautifulSoup: raise nose.SkipTest("No BeautifulSoup available for parsing html") # Heavy test to verify that we can load all available datasets for name in get_dataset_names(): # unfortunately @network somehow obscures this generator so it # does not get in effect, so we need to call explicitly # yield check_load_dataset, name check_load_dataset(name) @network(url="https://github.com/mwaskom/seaborn-data") def test_load_cached_datasets(): if not BeautifulSoup: raise nose.SkipTest("No BeautifulSoup available for parsing html") # Heavy test to verify that we can load all available datasets for name in get_dataset_names(): # unfortunately @network somehow obscures this generator so it # does not get in effect, so we need to call explicitly # yield check_load_dataset, name check_load_cached_dataset(name)
bsd-3-clause
[ 624, 2925, 367, 25174, 15841, 1041, 199, 646, 3598, 199, 646, 5549, 199, 646, 5145, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 11354, 199, 646, 11354, 14, 2537, 465, 13377, 199, 504, 11354, 14, 2537, 492, 702, 63, 1452, 12, 6534, 199, 646, 2680, 14, 4776, 465, 29340, 199, 646, 10634, 14, 1974, 14, 4776, 465, 299, 3583, 199, 199, 504, 7065, 14, 1023, 492, 18462, 199, 15718, 63, 1989, 63, 7206, 530, 2551, 275, 18462, 8, 8961, 855, 1023, 3368, 2356, 298, 16, 14, 1046, 2, 199, 199, 504, 10634, 14, 1974, 14, 4776, 492, 2784, 199, 199, 893, 26, 272, 687, 9922, 20, 492, 17132, 199, 2590, 3545, 26, 272, 17132, 275, 488, 199, 199, 504, 1275, 492, 14794, 1746, 199, 504, 2508, 492, 3778, 12, 4819, 1494, 199, 504, 2508, 1208, 492, 664, 63, 5214, 63, 1247, 12, 2248, 63, 5214, 421, 199, 65, 63, 4791, 275, 980, 14, 2355, 14, 10843, 8, 1960, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 4316, 83, 837, 272, 408, 774, 314, 805, 370, 372, 4681, 2798, 1249, 367, 299, 11821, 13612, 1041, 272, 734, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 702, 63, 1452, 8, 552, 8, 548, 395, 650, 9, 272, 671, 12, 394, 12, 336, 275, 734, 272, 702, 63, 1452, 8, 552, 8, 88, 395, 822, 8, 72, 430, 339, 327, 1379, 3486, 1930, 272, 282, 275, 980, 14, 5605, 8, 709, 9, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 12, 1616, 9, 272, 11354, 14, 2537, 14, 479, 63, 2052, 8, 1590, 14, 452, 8, 72, 508, 394, 59, 16, 2459, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 22209, 837, 272, 408, 774, 15379, 3462, 365, 3211, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 702, 63, 1452, 8, 88, 59, 17, 61, 446, 671, 59, 16, 467, 336, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 22384, 837, 272, 408, 774, 626, 1072, 666, 25113, 2839, 282, 510, 13463, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 11354, 14, 2537, 14, 479, 63, 4398, 63, 1452, 8, 1838, 8, 72, 395, 413, 9, 272, 11354, 14, 2537, 14, 479, 63, 2003, 63, 1452, 8, 72, 14, 988, 1062, 413, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 11329, 837, 272, 408, 774, 2517, 8929, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 12, 3388, 9, 272, 702, 63, 1452, 8, 552, 8, 88, 395, 3388, 9, 421, 199, 318, 511, 63, 559, 63, 475, 63, 1508, 890, 837, 272, 408, 774, 5953, 402, 16279, 63, 475, 63, 1508, 890, 1041, 272, 286, 374, 275, 3474, 14, 21, 12, 1275, 21, 467, 1779, 359, 17, 14, 821, 12, 413, 14, 21, 2677, 339, 946, 2492, 275, 359, 17, 12, 413, 14, 21, 61, 339, 3503, 63, 1508, 890, 275, 980, 14, 1144, 4038, 14, 21, 12, 413, 467, 3044, 26496, 821, 12, 378, 3934, 339, 511, 63, 1508, 890, 275, 3778, 14, 559, 63, 475, 63, 1508, 890, 8, 67, 374, 12, 946, 2492, 9, 272, 29340, 14, 479, 63, 1144, 63, 1452, 8, 6514, 63, 1508, 890, 12, 511, 63, 1508, 890, 9, 421, 199, 318, 511, 63, 3424, 292, 300, 323, 837, 272, 408, 774, 3164, 477, 14997, 1542, 1041, 272, 734, 17, 275, 3778, 14, 3424, 292, 300, 323, 480, 581, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 17, 12, 17048, 2194, 12, 1275, 821, 12, 1275, 821, 430, 339, 734, 18, 275, 3778, 14, 3424, 292, 300, 323, 10064, 383, 1665, 383, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 18, 12, 17048, 821, 12, 1275, 2194, 12, 1275, 821, 430, 339, 734, 19, 275, 3778, 14, 3424, 292, 300, 323, 1332, 16, 12, 378, 12, 413, 395, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 19, 12, 17048, 821, 12, 1275, 821, 12, 1275, 2194, 430, 339, 734, 20, 275, 3778, 14, 3424, 292, 300, 323, 480, 581, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 20, 12, 17048, 2194, 12, 1275, 821, 12, 1275, 821, 430, 421, 199, 32, 3536, 8, 3393, 9, 199, 318, 511, 63, 3424, 292, 1542, 63, 4469, 837, 272, 408, 774, 626, 299, 319, 9682, 402, 359, 16, 12, 413, 61, 6534, 1919, 1041, 272, 3778, 14, 3424, 292, 300, 323, 480, 6304, 401, 5238, 9, 421, 199, 318, 511, 63, 14997, 300, 323, 837, 272, 408, 774, 10238, 402, 21845, 1542, 805, 1041, 272, 734, 275, 3778, 14, 14997, 300, 323, 1332, 14, 2194, 12, 1275, 821, 12, 1275, 821, 430, 272, 702, 63, 1452, 8, 548, 12, 334, 17, 12, 378, 12, 378, 430, 421, 199, 318, 511, 63, 9962, 82, 837, 272, 408, 774, 314, 473, 26779, 805, 1041, 272, 282, 275, 980, 14, 5605, 8, 21, 9, 272, 284, 16596, 275, 3778, 14, 9962, 82, 8, 65, 9, 272, 702, 63, 1452, 8, 9962, 82, 12, 499, 9, 421, 199, 533, 1379, 5058, 1132, 7535, 8, 10711, 1746, 304, 339, 27613, 275, 2097, 3039, 401, 298, 1019, 401, 298, 8305, 401, 298, 2119, 937, 272, 6890, 63, 19564, 275, 2097, 2119, 401, 298, 1019, 937, 272, 6506, 63, 19564, 275, 2097, 3039, 401, 298, 8305, 937, 339, 3268, 275, 1616, 272, 3379, 63, 3124, 275, 1689, 548, 3079, 401, 378, 9, 272, 3268, 63, 3124, 275, 1689, 548, 3079, 401, 3268, 9, 339, 347, 511, 63, 271, 681, 1132, 8, 277, 304, 267, 289, 12, 2185, 275, 4488, 14, 21430, 342, 267, 367, 5366, 315, 291, 14, 19564, 26, 288, 13377, 14, 479, 63, 2052, 8, 1219, 14, 681, 3746, 59, 2441, 1055, 362, 63, 6604, 1012, 398, 3778, 14, 271, 681, 1132, 342, 267, 367, 5366, 315, 291, 14, 7837, 63, 19564, 26, 288, 13377, 14, 479, 63, 2052, 26428, 1219 ]
[ 2925, 367, 25174, 15841, 1041, 199, 646, 3598, 199, 646, 5549, 199, 646, 5145, 199, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 11354, 199, 646, 11354, 14, 2537, 465, 13377, 199, 504, 11354, 14, 2537, 492, 702, 63, 1452, 12, 6534, 199, 646, 2680, 14, 4776, 465, 29340, 199, 646, 10634, 14, 1974, 14, 4776, 465, 299, 3583, 199, 199, 504, 7065, 14, 1023, 492, 18462, 199, 15718, 63, 1989, 63, 7206, 530, 2551, 275, 18462, 8, 8961, 855, 1023, 3368, 2356, 298, 16, 14, 1046, 2, 199, 199, 504, 10634, 14, 1974, 14, 4776, 492, 2784, 199, 199, 893, 26, 272, 687, 9922, 20, 492, 17132, 199, 2590, 3545, 26, 272, 17132, 275, 488, 199, 199, 504, 1275, 492, 14794, 1746, 199, 504, 2508, 492, 3778, 12, 4819, 1494, 199, 504, 2508, 1208, 492, 664, 63, 5214, 63, 1247, 12, 2248, 63, 5214, 421, 199, 65, 63, 4791, 275, 980, 14, 2355, 14, 10843, 8, 1960, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 4316, 83, 837, 272, 408, 774, 314, 805, 370, 372, 4681, 2798, 1249, 367, 299, 11821, 13612, 1041, 272, 734, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 702, 63, 1452, 8, 552, 8, 548, 395, 650, 9, 272, 671, 12, 394, 12, 336, 275, 734, 272, 702, 63, 1452, 8, 552, 8, 88, 395, 822, 8, 72, 430, 339, 327, 1379, 3486, 1930, 272, 282, 275, 980, 14, 5605, 8, 709, 9, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 12, 1616, 9, 272, 11354, 14, 2537, 14, 479, 63, 2052, 8, 1590, 14, 452, 8, 72, 508, 394, 59, 16, 2459, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 22209, 837, 272, 408, 774, 15379, 3462, 365, 3211, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 702, 63, 1452, 8, 88, 59, 17, 61, 446, 671, 59, 16, 467, 336, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 22384, 837, 272, 408, 774, 626, 1072, 666, 25113, 2839, 282, 510, 13463, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 9, 272, 11354, 14, 2537, 14, 479, 63, 4398, 63, 1452, 8, 1838, 8, 72, 395, 413, 9, 272, 11354, 14, 2537, 14, 479, 63, 2003, 63, 1452, 8, 72, 14, 988, 1062, 413, 9, 421, 199, 318, 511, 63, 31842, 63, 11141, 63, 11329, 837, 272, 408, 774, 2517, 8929, 1041, 272, 671, 12, 394, 12, 336, 275, 3778, 14, 31842, 63, 11141, 8, 65, 63, 4791, 12, 3388, 9, 272, 702, 63, 1452, 8, 552, 8, 88, 395, 3388, 9, 421, 199, 318, 511, 63, 559, 63, 475, 63, 1508, 890, 837, 272, 408, 774, 5953, 402, 16279, 63, 475, 63, 1508, 890, 1041, 272, 286, 374, 275, 3474, 14, 21, 12, 1275, 21, 467, 1779, 359, 17, 14, 821, 12, 413, 14, 21, 2677, 339, 946, 2492, 275, 359, 17, 12, 413, 14, 21, 61, 339, 3503, 63, 1508, 890, 275, 980, 14, 1144, 4038, 14, 21, 12, 413, 467, 3044, 26496, 821, 12, 378, 3934, 339, 511, 63, 1508, 890, 275, 3778, 14, 559, 63, 475, 63, 1508, 890, 8, 67, 374, 12, 946, 2492, 9, 272, 29340, 14, 479, 63, 1144, 63, 1452, 8, 6514, 63, 1508, 890, 12, 511, 63, 1508, 890, 9, 421, 199, 318, 511, 63, 3424, 292, 300, 323, 837, 272, 408, 774, 3164, 477, 14997, 1542, 1041, 272, 734, 17, 275, 3778, 14, 3424, 292, 300, 323, 480, 581, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 17, 12, 17048, 2194, 12, 1275, 821, 12, 1275, 821, 430, 339, 734, 18, 275, 3778, 14, 3424, 292, 300, 323, 10064, 383, 1665, 383, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 18, 12, 17048, 821, 12, 1275, 2194, 12, 1275, 821, 430, 339, 734, 19, 275, 3778, 14, 3424, 292, 300, 323, 1332, 16, 12, 378, 12, 413, 395, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 19, 12, 17048, 821, 12, 1275, 821, 12, 1275, 2194, 430, 339, 734, 20, 275, 3778, 14, 3424, 292, 300, 323, 480, 581, 401, 1275, 21, 9, 272, 702, 63, 1452, 8, 548, 20, 12, 17048, 2194, 12, 1275, 821, 12, 1275, 821, 430, 421, 199, 32, 3536, 8, 3393, 9, 199, 318, 511, 63, 3424, 292, 1542, 63, 4469, 837, 272, 408, 774, 626, 299, 319, 9682, 402, 359, 16, 12, 413, 61, 6534, 1919, 1041, 272, 3778, 14, 3424, 292, 300, 323, 480, 6304, 401, 5238, 9, 421, 199, 318, 511, 63, 14997, 300, 323, 837, 272, 408, 774, 10238, 402, 21845, 1542, 805, 1041, 272, 734, 275, 3778, 14, 14997, 300, 323, 1332, 14, 2194, 12, 1275, 821, 12, 1275, 821, 430, 272, 702, 63, 1452, 8, 548, 12, 334, 17, 12, 378, 12, 378, 430, 421, 199, 318, 511, 63, 9962, 82, 837, 272, 408, 774, 314, 473, 26779, 805, 1041, 272, 282, 275, 980, 14, 5605, 8, 21, 9, 272, 284, 16596, 275, 3778, 14, 9962, 82, 8, 65, 9, 272, 702, 63, 1452, 8, 9962, 82, 12, 499, 9, 421, 199, 533, 1379, 5058, 1132, 7535, 8, 10711, 1746, 304, 339, 27613, 275, 2097, 3039, 401, 298, 1019, 401, 298, 8305, 401, 298, 2119, 937, 272, 6890, 63, 19564, 275, 2097, 2119, 401, 298, 1019, 937, 272, 6506, 63, 19564, 275, 2097, 3039, 401, 298, 8305, 937, 339, 3268, 275, 1616, 272, 3379, 63, 3124, 275, 1689, 548, 3079, 401, 378, 9, 272, 3268, 63, 3124, 275, 1689, 548, 3079, 401, 3268, 9, 339, 347, 511, 63, 271, 681, 1132, 8, 277, 304, 267, 289, 12, 2185, 275, 4488, 14, 21430, 342, 267, 367, 5366, 315, 291, 14, 19564, 26, 288, 13377, 14, 479, 63, 2052, 8, 1219, 14, 681, 3746, 59, 2441, 1055, 362, 63, 6604, 1012, 398, 3778, 14, 271, 681, 1132, 342, 267, 367, 5366, 315, 291, 14, 7837, 63, 19564, 26, 288, 13377, 14, 479, 63, 2052, 26428, 1219, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
livc/Paddle
demo/traffic_prediction/gen_result.py
10
1702
# Copyright (c) 2016 PaddlePaddle Authors, 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. res = [] with open('./rank-00000') as f: for line in f: pred = map(int, line.strip('\r\n;').split(";")) #raw prediction range from 0 to 3 res.append([i + 1 for i in pred]) file_name = open('./data/pred.list').read().strip('\r\n') FORECASTING_NUM = 24 header = [ 'id', '201604200805', '201604200810', '201604200815', '201604200820', '201604200825', '201604200830', '201604200835', '201604200840', '201604200845', '201604200850', '201604200855', '201604200900', '201604200905', '201604200910', '201604200915', '201604200920', '201604200925', '201604200930', '201604200935', '201604200940', '201604200945', '201604200950', '201604200955', '201604201000', ] ################### ## To CSV format ## ################### with open(file_name) as f: f.next() print ','.join(header) for row_num, line in enumerate(f): fields = line.rstrip('\r\n').split(',') linkid = fields[0] print linkid + ',' + ','.join(map(str, res[row_num]))
apache-2.0
[ 3, 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 12, 3277, 14, 2900, 5924, 5702, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 470, 275, 942, 199, 1045, 1551, 17371, 4648, 13, 5345, 358, 465, 289, 26, 272, 367, 1004, 315, 289, 26, 267, 8869, 275, 2341, 8, 442, 12, 1004, 14, 1913, 2258, 82, 60, 78, 27, 1959, 1294, 480, 27, 2237, 267, 327, 1773, 12044, 1425, 687, 378, 370, 650, 267, 522, 14, 740, 779, 73, 435, 413, 367, 284, 315, 8869, 566, 199, 199, 493, 63, 354, 275, 1551, 17371, 576, 15, 5991, 14, 513, 1959, 739, 1252, 1913, 2258, 82, 60, 78, 358, 199, 199, 18155, 18898, 1206, 63, 7125, 275, 5504, 199, 1291, 275, 359, 272, 283, 344, 297, 272, 283, 9261, 966, 1840, 13027, 297, 272, 283, 9261, 966, 9300, 709, 297, 272, 283, 9261, 966, 9300, 1046, 297, 272, 283, 9261, 966, 9300, 1165, 297, 272, 283, 9261, 966, 9300, 821, 297, 272, 283, 9261, 966, 9300, 1216, 297, 272, 283, 9261, 966, 9300, 1276, 297, 272, 283, 9261, 966, 1840, 13462, 297, 272, 283, 9261, 966, 1840, 16963, 297, 272, 283, 9261, 966, 9300, 1400, 297, 272, 283, 9261, 966, 9300, 1229, 297, 272, 283, 9261, 966, 8664, 383, 297, 272, 283, 9261, 966, 8664, 1717, 297, 272, 283, 9261, 966, 8664, 709, 297, 272, 283, 9261, 966, 8664, 1046, 297, 272, 283, 9261, 966, 8664, 1165, 297, 272, 283, 9261, 966, 8664, 821, 297, 272, 283, 9261, 966, 8664, 1216, 297, 272, 283, 9261, 966, 8664, 1276, 297, 272, 283, 9261, 966, 8664, 2167, 297, 272, 283, 9261, 966, 8664, 2322, 297, 272, 283, 9261, 966, 8664, 1400, 297, 272, 283, 9261, 966, 8664, 1229, 297, 272, 283, 9261, 966, 1797, 1493, 297, 199, 61, 199, 749, 5680, 199, 309, 4005, 14689, 1475, 925, 199, 749, 5680, 199, 1045, 1551, 8, 493, 63, 354, 9, 465, 289, 26, 272, 289, 14, 2184, 342, 272, 870, 12814, 904, 8, 1291, 9, 272, 367, 1962, 63, 1507, 12, 1004, 315, 3874, 8, 70, 304, 267, 1504, 275, 1004, 14, 6735, 2258, 82, 60, 78, 1959, 1294, 11917, 267, 2142, 344, 275, 1504, 59, 16, 61, 267, 870, 2142, 344, 435, 13647, 435, 12814, 904, 8, 1130, 8, 495, 12, 522, 59, 1143, 63, 1507, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 7800, 510, 20101, 48, 20101, 6642, 12, 3277, 14, 2900, 5924, 5702, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 470, 275, 942, 199, 1045, 1551, 17371, 4648, 13, 5345, 358, 465, 289, 26, 272, 367, 1004, 315, 289, 26, 267, 8869, 275, 2341, 8, 442, 12, 1004, 14, 1913, 2258, 82, 60, 78, 27, 1959, 1294, 480, 27, 2237, 267, 327, 1773, 12044, 1425, 687, 378, 370, 650, 267, 522, 14, 740, 779, 73, 435, 413, 367, 284, 315, 8869, 566, 199, 199, 493, 63, 354, 275, 1551, 17371, 576, 15, 5991, 14, 513, 1959, 739, 1252, 1913, 2258, 82, 60, 78, 358, 199, 199, 18155, 18898, 1206, 63, 7125, 275, 5504, 199, 1291, 275, 359, 272, 283, 344, 297, 272, 283, 9261, 966, 1840, 13027, 297, 272, 283, 9261, 966, 9300, 709, 297, 272, 283, 9261, 966, 9300, 1046, 297, 272, 283, 9261, 966, 9300, 1165, 297, 272, 283, 9261, 966, 9300, 821, 297, 272, 283, 9261, 966, 9300, 1216, 297, 272, 283, 9261, 966, 9300, 1276, 297, 272, 283, 9261, 966, 1840, 13462, 297, 272, 283, 9261, 966, 1840, 16963, 297, 272, 283, 9261, 966, 9300, 1400, 297, 272, 283, 9261, 966, 9300, 1229, 297, 272, 283, 9261, 966, 8664, 383, 297, 272, 283, 9261, 966, 8664, 1717, 297, 272, 283, 9261, 966, 8664, 709, 297, 272, 283, 9261, 966, 8664, 1046, 297, 272, 283, 9261, 966, 8664, 1165, 297, 272, 283, 9261, 966, 8664, 821, 297, 272, 283, 9261, 966, 8664, 1216, 297, 272, 283, 9261, 966, 8664, 1276, 297, 272, 283, 9261, 966, 8664, 2167, 297, 272, 283, 9261, 966, 8664, 2322, 297, 272, 283, 9261, 966, 8664, 1400, 297, 272, 283, 9261, 966, 8664, 1229, 297, 272, 283, 9261, 966, 1797, 1493, 297, 199, 61, 199, 749, 5680, 199, 309, 4005, 14689, 1475, 925, 199, 749, 5680, 199, 1045, 1551, 8, 493, 63, 354, 9, 465, 289, 26, 272, 289, 14, 2184, 342, 272, 870, 12814, 904, 8, 1291, 9, 272, 367, 1962, 63, 1507, 12, 1004, 315, 3874, 8, 70, 304, 267, 1504, 275, 1004, 14, 6735, 2258, 82, 60, 78, 1959, 1294, 11917, 267, 2142, 344, 275, 1504, 59, 16, 61, 267, 870, 2142, 344, 435, 13647, 435, 12814, 904, 8, 1130, 8, 495, 12, 522, 59, 1143, 63, 1507, 2459, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 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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 ]
mcus/SickRage
lib/cachecontrol/caches/file_cache.py
56
3508
import hashlib import os from lockfile import LockFile from lockfile.mkdirlockfile import MkdirLockFile from ..cache import BaseCache from ..controller import CacheController def _secure_open_write(filename, fmode): # We only want to write to this file, so open it in write only mode flags = os.O_WRONLY # os.O_CREAT | os.O_EXCL will fail if the file already exists, so we only # will open *new* files. # We specify this because we want to ensure that the mode we pass is the # mode of the file. flags |= os.O_CREAT | os.O_EXCL # Do not follow symlinks to prevent someone from making a symlink that # we follow and insecurely open a cache file. if hasattr(os, "O_NOFOLLOW"): flags |= os.O_NOFOLLOW # On Windows we'll mark this file as binary if hasattr(os, "O_BINARY"): flags |= os.O_BINARY # Before we open our file, we want to delete any existing file that is # there try: os.remove(filename) except (IOError, OSError): # The file must not exist already, so we can just skip ahead to opening pass # Open our file, the use of os.O_CREAT | os.O_EXCL will ensure that if a # race condition happens between the os.remove and this line, that an # error will be raised. Because we utilize a lockfile this should only # happen if someone is attempting to attack us. fd = os.open(filename, flags, fmode) try: return os.fdopen(fd, "wb") except: # An error occurred wrapping our FD in a file object os.close(fd) raise class FileCache(BaseCache): def __init__(self, directory, forever=False, filemode=0o0600, dirmode=0o0700, use_dir_lock=None, lock_class=None): if use_dir_lock is not None and lock_class is not None: raise ValueError("Cannot use use_dir_lock and lock_class together") if use_dir_lock: lock_class = MkdirLockFile if lock_class is None: lock_class = LockFile self.directory = directory self.forever = forever self.filemode = filemode self.dirmode = dirmode self.lock_class = lock_class @staticmethod def encode(x): return hashlib.sha224(x.encode()).hexdigest() def _fn(self, name): # NOTE: This method should not change as some may depend on it. # See: https://github.com/ionrock/cachecontrol/issues/63 hashed = self.encode(name) parts = list(hashed[:5]) + [hashed] return os.path.join(self.directory, *parts) def get(self, key): name = self._fn(key) if not os.path.exists(name): return None with open(name, 'rb') as fh: return fh.read() def set(self, key, value): name = self._fn(key) # Make sure the directory exists try: os.makedirs(os.path.dirname(name), self.dirmode) except (IOError, OSError): pass with self.lock_class(name) as lock: # Write our actual file with _secure_open_write(lock.path, self.filemode) as fh: fh.write(value) def delete(self, key): name = self._fn(key) if not self.forever: os.remove(name) def url_to_file_path(url, filecache): """Return the file cache path based on the URL. This does not ensure the file exists! """ key = CacheController.cache_url(url) return filecache._fn(key)
gpl-3.0
[ 646, 8337, 199, 646, 747, 199, 199, 504, 4650, 493, 492, 15536, 1173, 199, 504, 4650, 493, 14, 8215, 26204, 492, 603, 75, 694, 6432, 1173, 199, 199, 504, 2508, 1637, 492, 3523, 4437, 199, 504, 2508, 5538, 492, 11977, 7506, 421, 199, 318, 485, 7817, 63, 1490, 63, 952, 8, 1501, 12, 289, 632, 304, 272, 327, 2136, 1454, 2934, 370, 2218, 370, 642, 570, 12, 880, 1551, 652, 315, 2218, 1454, 818, 272, 3285, 275, 747, 14, 47, 63, 6524, 10452, 339, 327, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 911, 2449, 340, 314, 570, 2575, 3495, 12, 880, 781, 1454, 272, 327, 221, 911, 1551, 627, 1222, 10, 1584, 14, 272, 327, 2136, 4165, 642, 2952, 781, 2934, 370, 4868, 626, 314, 818, 781, 986, 365, 314, 272, 327, 818, 402, 314, 570, 14, 272, 3285, 8901, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 339, 327, 4226, 440, 2035, 19891, 370, 7981, 17122, 687, 10663, 282, 15296, 626, 272, 327, 781, 2035, 436, 26097, 590, 1551, 282, 2581, 570, 14, 272, 340, 2688, 8, 736, 12, 298, 47, 63, 2826, 38, 29905, 2349, 267, 3285, 8901, 747, 14, 47, 63, 2826, 38, 29905, 339, 327, 4068, 5417, 781, 7171, 2216, 642, 570, 465, 3366, 272, 340, 2688, 8, 736, 12, 298, 47, 63, 13246, 2349, 267, 3285, 8901, 747, 14, 47, 63, 13246, 339, 327, 21467, 781, 1551, 4154, 570, 12, 781, 2934, 370, 3145, 1263, 3411, 570, 626, 365, 272, 327, 2337, 272, 862, 26, 267, 747, 14, 2168, 8, 1501, 9, 272, 871, 334, 13760, 12, 6440, 304, 267, 327, 710, 570, 1471, 440, 2187, 2575, 12, 880, 781, 883, 2951, 3372, 23417, 370, 13618, 267, 986, 339, 327, 3232, 4154, 570, 12, 314, 675, 402, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 911, 4868, 626, 340, 282, 272, 327, 21209, 5558, 10986, 3382, 314, 747, 14, 2168, 436, 642, 1004, 12, 626, 376, 272, 327, 1125, 911, 506, 4915, 14, 13821, 781, 7678, 13559, 282, 4650, 493, 642, 1077, 1454, 272, 327, 5992, 340, 17122, 365, 19595, 370, 23326, 2739, 14, 272, 6111, 275, 747, 14, 1490, 8, 1501, 12, 3285, 12, 289, 632, 9, 272, 862, 26, 267, 372, 747, 14, 23140, 8, 2592, 12, 298, 6603, 531, 272, 871, 26, 267, 327, 1626, 1125, 8920, 19696, 4154, 481, 36, 315, 282, 570, 909, 267, 747, 14, 1600, 8, 2592, 9, 267, 746, 421, 199, 533, 3814, 4437, 8, 1563, 4437, 304, 272, 347, 636, 826, 721, 277, 12, 2082, 12, 28688, 29, 797, 12, 32429, 29, 16, 79, 1690, 383, 12, 326, 2935, 632, 29, 16, 79, 1780, 383, 12, 675, 63, 694, 63, 831, 29, 403, 12, 4650, 63, 533, 29, 403, 304, 398, 340, 675, 63, 694, 63, 831, 365, 440, 488, 436, 4650, 63, 533, 365, 440, 488, 26, 288, 746, 1722, 480, 6612, 675, 675, 63, 694, 63, 831, 436, 4650, 63, 533, 10451, 531, 398, 340, 675, 63, 694, 63, 831, 26, 288, 4650, 63, 533, 275, 603, 75, 694, 6432, 1173, 398, 340, 4650, 63, 533, 365, 488, 26, 288, 4650, 63, 533, 275, 15536, 1173, 398, 291, 14, 3619, 275, 2082, 267, 291, 14, 21327, 275, 28688, 267, 291, 14, 493, 632, 275, 32429, 267, 291, 14, 694, 632, 275, 2935, 632, 267, 291, 14, 831, 63, 533, 275, 4650, 63, 533, 2378, 768, 4639, 272, 347, 3752, 8, 88, 304, 267, 372, 8337, 14, 4835, 8731, 8, 88, 14, 2143, 8801, 11453, 342, 339, 347, 485, 2324, 8, 277, 12, 536, 304, 267, 327, 6944, 26, 961, 1083, 1077, 440, 1570, 465, 2005, 1443, 11687, 641, 652, 14, 267, 327, 755, 1666, 26, 4178, 921, 5031, 14, 957, 15, 1636, 24892, 15, 1637, 2785, 15, 10115, 15, 2766, 267, 19871, 275, 291, 14, 2143, 8, 354, 9, 267, 4184, 275, 769, 8, 26368, 1491, 21, 566, 435, 359, 26368, 61, 267, 372, 747, 14, 515, 14, 904, 8, 277, 14, 3619, 12, 627, 4181, 9, 339, 347, 664, 8, 277, 12, 790, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 354, 304, 288, 372, 488, 398, 543, 1551, 8, 354, 12, 283, 4848, 358, 465, 11155, 26, 288, 372, 11155, 14, 739, 342, 339, 347, 663, 8, 277, 12, 790, 12, 574, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 398, 327, 4155, 3238, 314, 2082, 3495, 267, 862, 26, 288, 747, 14, 8347, 8, 736, 14, 515, 14, 3475, 8, 354, 395, 291, 14, 694, 632, 9, 267, 871, 334, 13760, 12, 6440, 304, 288, 986, 398, 543, 291, 14, 831, 63, 533, 8, 354, 9, 465, 4650, 26, 288, 327, 6990, 4154, 3503, 570, 288, 543, 485, 7817, 63, 1490, 63, 952, 8, 831, 14, 515, 12, 291, 14, 493, 632, 9, 465, 11155, 26, 355, 11155, 14, 952, 8, 585, 9, 339, 347, 3145, 8, 277, 12, 790, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 267, 340, 440, 291, 14, 21327, 26, 288, 747, 14, 2168, 8, 354, 9, 421, 199, 318, 1166, 63, 475, 63, 493, 63, 515, 8, 633, 12, 570, 1637, 304, 272, 408, 1767, 314, 570, 2581, 931, 4079, 641, 314, 2851, 14, 339, 961, 1630, 440, 4868, 314, 570, 3495, 1, 272, 408, 272, 790, 275, 11977, 7506, 14, 1637, 63, 633, 8, 633, 9, 272, 372, 570, 1637, 423, 2324, 8, 498, 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 ]
[ 8337, 199, 646, 747, 199, 199, 504, 4650, 493, 492, 15536, 1173, 199, 504, 4650, 493, 14, 8215, 26204, 492, 603, 75, 694, 6432, 1173, 199, 199, 504, 2508, 1637, 492, 3523, 4437, 199, 504, 2508, 5538, 492, 11977, 7506, 421, 199, 318, 485, 7817, 63, 1490, 63, 952, 8, 1501, 12, 289, 632, 304, 272, 327, 2136, 1454, 2934, 370, 2218, 370, 642, 570, 12, 880, 1551, 652, 315, 2218, 1454, 818, 272, 3285, 275, 747, 14, 47, 63, 6524, 10452, 339, 327, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 911, 2449, 340, 314, 570, 2575, 3495, 12, 880, 781, 1454, 272, 327, 221, 911, 1551, 627, 1222, 10, 1584, 14, 272, 327, 2136, 4165, 642, 2952, 781, 2934, 370, 4868, 626, 314, 818, 781, 986, 365, 314, 272, 327, 818, 402, 314, 570, 14, 272, 3285, 8901, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 339, 327, 4226, 440, 2035, 19891, 370, 7981, 17122, 687, 10663, 282, 15296, 626, 272, 327, 781, 2035, 436, 26097, 590, 1551, 282, 2581, 570, 14, 272, 340, 2688, 8, 736, 12, 298, 47, 63, 2826, 38, 29905, 2349, 267, 3285, 8901, 747, 14, 47, 63, 2826, 38, 29905, 339, 327, 4068, 5417, 781, 7171, 2216, 642, 570, 465, 3366, 272, 340, 2688, 8, 736, 12, 298, 47, 63, 13246, 2349, 267, 3285, 8901, 747, 14, 47, 63, 13246, 339, 327, 21467, 781, 1551, 4154, 570, 12, 781, 2934, 370, 3145, 1263, 3411, 570, 626, 365, 272, 327, 2337, 272, 862, 26, 267, 747, 14, 2168, 8, 1501, 9, 272, 871, 334, 13760, 12, 6440, 304, 267, 327, 710, 570, 1471, 440, 2187, 2575, 12, 880, 781, 883, 2951, 3372, 23417, 370, 13618, 267, 986, 339, 327, 3232, 4154, 570, 12, 314, 675, 402, 747, 14, 47, 63, 32120, 1204, 747, 14, 47, 63, 29647, 911, 4868, 626, 340, 282, 272, 327, 21209, 5558, 10986, 3382, 314, 747, 14, 2168, 436, 642, 1004, 12, 626, 376, 272, 327, 1125, 911, 506, 4915, 14, 13821, 781, 7678, 13559, 282, 4650, 493, 642, 1077, 1454, 272, 327, 5992, 340, 17122, 365, 19595, 370, 23326, 2739, 14, 272, 6111, 275, 747, 14, 1490, 8, 1501, 12, 3285, 12, 289, 632, 9, 272, 862, 26, 267, 372, 747, 14, 23140, 8, 2592, 12, 298, 6603, 531, 272, 871, 26, 267, 327, 1626, 1125, 8920, 19696, 4154, 481, 36, 315, 282, 570, 909, 267, 747, 14, 1600, 8, 2592, 9, 267, 746, 421, 199, 533, 3814, 4437, 8, 1563, 4437, 304, 272, 347, 636, 826, 721, 277, 12, 2082, 12, 28688, 29, 797, 12, 32429, 29, 16, 79, 1690, 383, 12, 326, 2935, 632, 29, 16, 79, 1780, 383, 12, 675, 63, 694, 63, 831, 29, 403, 12, 4650, 63, 533, 29, 403, 304, 398, 340, 675, 63, 694, 63, 831, 365, 440, 488, 436, 4650, 63, 533, 365, 440, 488, 26, 288, 746, 1722, 480, 6612, 675, 675, 63, 694, 63, 831, 436, 4650, 63, 533, 10451, 531, 398, 340, 675, 63, 694, 63, 831, 26, 288, 4650, 63, 533, 275, 603, 75, 694, 6432, 1173, 398, 340, 4650, 63, 533, 365, 488, 26, 288, 4650, 63, 533, 275, 15536, 1173, 398, 291, 14, 3619, 275, 2082, 267, 291, 14, 21327, 275, 28688, 267, 291, 14, 493, 632, 275, 32429, 267, 291, 14, 694, 632, 275, 2935, 632, 267, 291, 14, 831, 63, 533, 275, 4650, 63, 533, 2378, 768, 4639, 272, 347, 3752, 8, 88, 304, 267, 372, 8337, 14, 4835, 8731, 8, 88, 14, 2143, 8801, 11453, 342, 339, 347, 485, 2324, 8, 277, 12, 536, 304, 267, 327, 6944, 26, 961, 1083, 1077, 440, 1570, 465, 2005, 1443, 11687, 641, 652, 14, 267, 327, 755, 1666, 26, 4178, 921, 5031, 14, 957, 15, 1636, 24892, 15, 1637, 2785, 15, 10115, 15, 2766, 267, 19871, 275, 291, 14, 2143, 8, 354, 9, 267, 4184, 275, 769, 8, 26368, 1491, 21, 566, 435, 359, 26368, 61, 267, 372, 747, 14, 515, 14, 904, 8, 277, 14, 3619, 12, 627, 4181, 9, 339, 347, 664, 8, 277, 12, 790, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 267, 340, 440, 747, 14, 515, 14, 2444, 8, 354, 304, 288, 372, 488, 398, 543, 1551, 8, 354, 12, 283, 4848, 358, 465, 11155, 26, 288, 372, 11155, 14, 739, 342, 339, 347, 663, 8, 277, 12, 790, 12, 574, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 398, 327, 4155, 3238, 314, 2082, 3495, 267, 862, 26, 288, 747, 14, 8347, 8, 736, 14, 515, 14, 3475, 8, 354, 395, 291, 14, 694, 632, 9, 267, 871, 334, 13760, 12, 6440, 304, 288, 986, 398, 543, 291, 14, 831, 63, 533, 8, 354, 9, 465, 4650, 26, 288, 327, 6990, 4154, 3503, 570, 288, 543, 485, 7817, 63, 1490, 63, 952, 8, 831, 14, 515, 12, 291, 14, 493, 632, 9, 465, 11155, 26, 355, 11155, 14, 952, 8, 585, 9, 339, 347, 3145, 8, 277, 12, 790, 304, 267, 536, 275, 291, 423, 2324, 8, 498, 9, 267, 340, 440, 291, 14, 21327, 26, 288, 747, 14, 2168, 8, 354, 9, 421, 199, 318, 1166, 63, 475, 63, 493, 63, 515, 8, 633, 12, 570, 1637, 304, 272, 408, 1767, 314, 570, 2581, 931, 4079, 641, 314, 2851, 14, 339, 961, 1630, 440, 4868, 314, 570, 3495, 1, 272, 408, 272, 790, 275, 11977, 7506, 14, 1637, 63, 633, 8, 633, 9, 272, 372, 570, 1637, 423, 2324, 8, 498, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
lucashmorais/x-Bench
mozmill-env/python/Lib/io.py
53
3321
"""The io module provides the Python interfaces to stream handling. The builtin open function is defined in this module. At the top of the I/O hierarchy is the abstract base class IOBase. It defines the basic interface to a stream. Note, however, that there is no separation between reading and writing to streams; implementations are allowed to raise an IOError if they do not support a given operation. Extending IOBase is RawIOBase which deals simply with the reading and writing of raw bytes to a stream. FileIO subclasses RawIOBase to provide an interface to OS files. BufferedIOBase deals with buffering on a raw byte stream (RawIOBase). Its subclasses, BufferedWriter, BufferedReader, and BufferedRWPair buffer streams that are readable, writable, and both respectively. BufferedRandom provides a buffered interface to random access streams. BytesIO is a simple stream of in-memory bytes. Another IOBase subclass, TextIOBase, deals with the encoding and decoding of streams into text. TextIOWrapper, which extends it, is a buffered text interface to a buffered raw stream (`BufferedIOBase`). Finally, StringIO is a in-memory stream for text. Argument names are not part of the specification, and only the arguments of open() are intended to be used as keyword arguments. data: DEFAULT_BUFFER_SIZE An int containing the default buffer size used by the module's buffered I/O classes. open() uses the file's blksize (as obtained by os.stat) if possible. """ # New I/O library conforming to PEP 3116. __author__ = ("Guido van Rossum <guido@python.org>, " "Mike Verdone <mike.verdone@gmail.com>, " "Mark Russell <mark.russell@zen.co.uk>, " "Antoine Pitrou <solipsis@pitrou.net>, " "Amaury Forgeot d'Arc <amauryfa@gmail.com>, " "Benjamin Peterson <benjamin@python.org>") __all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO", "BytesIO", "StringIO", "BufferedIOBase", "BufferedReader", "BufferedWriter", "BufferedRWPair", "BufferedRandom", "TextIOBase", "TextIOWrapper", "UnsupportedOperation", "SEEK_SET", "SEEK_CUR", "SEEK_END"] import _io import abc from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation, open, FileIO, BytesIO, StringIO, BufferedReader, BufferedWriter, BufferedRWPair, BufferedRandom, IncrementalNewlineDecoder, TextIOWrapper) OpenWrapper = _io.open # for compatibility with _pyio # for seek() SEEK_SET = 0 SEEK_CUR = 1 SEEK_END = 2 # Declaring ABCs in C is tricky so we do it here. # Method descriptions and default implementations are inherited from the C # version however. class IOBase(_io._IOBase): __metaclass__ = abc.ABCMeta __doc__ = _io._IOBase.__doc__ class RawIOBase(_io._RawIOBase, IOBase): __doc__ = _io._RawIOBase.__doc__ class BufferedIOBase(_io._BufferedIOBase, IOBase): __doc__ = _io._BufferedIOBase.__doc__ class TextIOBase(_io._TextIOBase, IOBase): __doc__ = _io._TextIOBase.__doc__ RawIOBase.register(FileIO) for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom, BufferedRWPair): BufferedIOBase.register(klass) for klass in (StringIO, TextIOWrapper): TextIOBase.register(klass) del klass
mit
[ 624, 1918, 5890, 859, 6571, 314, 2018, 8386, 370, 2547, 7252, 14, 710, 199, 5351, 1551, 805, 365, 3247, 315, 642, 859, 14, 199, 199, 1271, 314, 2746, 402, 314, 473, 15, 47, 14446, 365, 314, 9006, 1300, 1021, 5004, 1563, 14, 2779, 199, 14334, 314, 5678, 3217, 370, 282, 2547, 14, 3390, 12, 13432, 12, 626, 2337, 365, 949, 199, 6175, 425, 3382, 7664, 436, 3575, 370, 13788, 27, 12591, 787, 199, 6541, 370, 746, 376, 5925, 340, 2985, 886, 440, 2291, 282, 1627, 3439, 14, 199, 199, 4377, 1098, 5004, 1563, 365, 13480, 23413, 1314, 477, 2551, 9329, 543, 314, 7664, 436, 199, 14827, 402, 3066, 2783, 370, 282, 2547, 14, 3814, 2090, 9180, 13480, 23413, 370, 5647, 199, 290, 3217, 370, 4403, 1584, 14, 199, 199, 23139, 23413, 477, 2551, 543, 21033, 641, 282, 3066, 3696, 2547, 334, 7963, 23413, 680, 22940, 199, 19094, 12, 26832, 6261, 12, 26832, 5929, 12, 436, 26832, 25438, 12882, 3335, 199, 11231, 626, 787, 12701, 12, 17267, 12, 436, 3865, 17342, 14, 199, 23139, 3883, 6571, 282, 20224, 3217, 370, 2196, 2879, 199, 11231, 14, 11808, 365, 282, 3486, 2547, 402, 315, 13, 4844, 2783, 14, 199, 199, 23296, 5004, 1563, 5516, 12, 4516, 23413, 12, 477, 2551, 543, 314, 2644, 436, 15952, 199, 1618, 13788, 1901, 1318, 14, 4516, 29365, 12, 1314, 16879, 652, 12, 365, 282, 20224, 1318, 199, 3266, 370, 282, 20224, 3066, 2547, 13493, 23139, 23413, 14963, 19177, 12, 5228, 199, 374, 282, 315, 13, 4844, 2547, 367, 1318, 14, 199, 199, 5201, 1561, 787, 440, 1777, 402, 314, 8929, 12, 436, 1454, 314, 2368, 199, 1618, 1551, 342, 787, 11619, 370, 506, 1202, 465, 4252, 2368, 14, 199, 199, 576, 26, 199, 199, 3472, 63, 10960, 63, 4305, 8410, 1626, 1109, 3035, 314, 849, 3335, 1568, 1202, 701, 314, 859, 1159, 20224, 2043, 473, 15, 47, 3992, 14, 1551, 342, 4440, 314, 570, 1159, 22742, 890, 334, 305, 15884, 701, 747, 14, 3736, 9, 340, 2043, 3962, 14, 199, 624, 199, 3, 7053, 473, 15, 47, 3555, 26449, 316, 370, 13663, 650, 7524, 14, 199, 199, 363, 2502, 363, 275, 1689, 18834, 79, 20744, 6848, 385, 453, 665, 9473, 79, 32, 1548, 14, 1308, 6244, 298, 1598, 298, 45, 7455, 5444, 4456, 665, 2664, 415, 14, 422, 4456, 32, 6799, 14, 957, 6244, 298, 1598, 298, 6470, 820, 527, 23235, 665, 1657, 14, 20791, 23235, 32, 5193, 14, 331, 14, 3210, 6244, 298, 1598, 298, 33, 29680, 1132, 510, 390, 7930, 665, 1152, 3587, 2316, 32, 80, 390, 7930, 14, 846, 6244, 298, 1598, 298, 33, 391, 18359, 2104, 303, 357, 366, 7, 27604, 665, 14541, 18359, 667, 32, 6799, 14, 957, 6244, 298, 1598, 298, 31231, 16997, 262, 22912, 834, 665, 18486, 16997, 262, 32, 1548, 14, 1308, 9579, 199, 199, 363, 452, 363, 275, 2097, 27132, 13760, 401, 298, 1490, 401, 298, 23413, 401, 298, 7963, 23413, 401, 298, 26126, 401, 1779, 298, 15466, 401, 298, 6424, 401, 298, 23139, 23413, 401, 1779, 298, 23139, 5929, 401, 298, 23139, 6261, 401, 298, 23139, 25438, 12882, 401, 1779, 298, 23139, 3883, 401, 298, 1872, 23413, 401, 298, 1872, 29365, 401, 1779, 298, 12647, 6044, 401, 298, 18439, 63, 3597, 401, 298, 18439, 63, 7013, 401, 298, 18439, 63, 3902, 937, 421, 199, 646, 485, 2308, 199, 646, 13022, 199, 199, 504, 485, 2308, 492, 334, 3472, 63, 10960, 63, 4305, 12, 8651, 316, 13760, 12, 19022, 6044, 12, 326, 1551, 12, 3814, 2090, 12, 11808, 12, 5228, 12, 26832, 5929, 12, 326, 26832, 6261, 12, 26832, 25438, 12882, 12, 26832, 3883, 12, 326, 14684, 4665, 604, 8326, 12, 4516, 29365, 9, 199, 199, 4299, 4590, 275, 485, 2308, 14, 1490, 327, 367, 7163, 543, 485, 647, 2308, 199, 199, 3, 367, 12005, 342, 199, 18439, 63, 3597, 275, 378, 199, 18439, 63, 7013, 275, 413, 199, 18439, 63, 3902, 275, 499, 199, 199, 3, 1487, 4925, 316, 17281, 83, 315, 445, 365, 32553, 880, 781, 886, 652, 2348, 14, 199, 3, 9075, 18714, 436, 849, 12591, 787, 12623, 687, 314, 445, 199, 3, 1015, 13432, 14, 199, 533, 5004, 1563, 1547, 2308, 423, 23413, 304, 272, 636, 6577, 363, 275, 13022, 14, 22254, 272, 636, 1301, 363, 275, 485, 2308, 423, 23413, 855, 1301, 363, 199, 199, 533, 13480, 23413, 1547, 2308, 423, 7963, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 7963, 23413, 855, 1301, 363, 199, 199, 533, 26832, 23413, 1547, 2308, 423, 23139, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 23139, 23413, 855, 1301, 363, 199, 199, 533, 4516, 23413, 1547, 2308, 423, 1872, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 1872, 23413, 855, 1301, 363, 199, 199, 7963, 23413, 14, 2683, 8, 26126, 9, 199, 199, 509, 8531, 315, 334, 15466, 12, 26832, 5929, 12, 26832, 6261, 12, 26832, 3883, 12, 1598, 26832, 25438, 12882, 304, 272, 26832, 23413, 14, 2683, 8, 11645, 9, 199, 199, 509, 8531, 315, 334, 6424, 12, 4516, 29365, 304, 272, 4516, 23413, 14, 2683, 8, 11645, 9, 199, 2264, 8531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1918, 5890, 859, 6571, 314, 2018, 8386, 370, 2547, 7252, 14, 710, 199, 5351, 1551, 805, 365, 3247, 315, 642, 859, 14, 199, 199, 1271, 314, 2746, 402, 314, 473, 15, 47, 14446, 365, 314, 9006, 1300, 1021, 5004, 1563, 14, 2779, 199, 14334, 314, 5678, 3217, 370, 282, 2547, 14, 3390, 12, 13432, 12, 626, 2337, 365, 949, 199, 6175, 425, 3382, 7664, 436, 3575, 370, 13788, 27, 12591, 787, 199, 6541, 370, 746, 376, 5925, 340, 2985, 886, 440, 2291, 282, 1627, 3439, 14, 199, 199, 4377, 1098, 5004, 1563, 365, 13480, 23413, 1314, 477, 2551, 9329, 543, 314, 7664, 436, 199, 14827, 402, 3066, 2783, 370, 282, 2547, 14, 3814, 2090, 9180, 13480, 23413, 370, 5647, 199, 290, 3217, 370, 4403, 1584, 14, 199, 199, 23139, 23413, 477, 2551, 543, 21033, 641, 282, 3066, 3696, 2547, 334, 7963, 23413, 680, 22940, 199, 19094, 12, 26832, 6261, 12, 26832, 5929, 12, 436, 26832, 25438, 12882, 3335, 199, 11231, 626, 787, 12701, 12, 17267, 12, 436, 3865, 17342, 14, 199, 23139, 3883, 6571, 282, 20224, 3217, 370, 2196, 2879, 199, 11231, 14, 11808, 365, 282, 3486, 2547, 402, 315, 13, 4844, 2783, 14, 199, 199, 23296, 5004, 1563, 5516, 12, 4516, 23413, 12, 477, 2551, 543, 314, 2644, 436, 15952, 199, 1618, 13788, 1901, 1318, 14, 4516, 29365, 12, 1314, 16879, 652, 12, 365, 282, 20224, 1318, 199, 3266, 370, 282, 20224, 3066, 2547, 13493, 23139, 23413, 14963, 19177, 12, 5228, 199, 374, 282, 315, 13, 4844, 2547, 367, 1318, 14, 199, 199, 5201, 1561, 787, 440, 1777, 402, 314, 8929, 12, 436, 1454, 314, 2368, 199, 1618, 1551, 342, 787, 11619, 370, 506, 1202, 465, 4252, 2368, 14, 199, 199, 576, 26, 199, 199, 3472, 63, 10960, 63, 4305, 8410, 1626, 1109, 3035, 314, 849, 3335, 1568, 1202, 701, 314, 859, 1159, 20224, 2043, 473, 15, 47, 3992, 14, 1551, 342, 4440, 314, 570, 1159, 22742, 890, 334, 305, 15884, 701, 747, 14, 3736, 9, 340, 2043, 3962, 14, 199, 624, 199, 3, 7053, 473, 15, 47, 3555, 26449, 316, 370, 13663, 650, 7524, 14, 199, 199, 363, 2502, 363, 275, 1689, 18834, 79, 20744, 6848, 385, 453, 665, 9473, 79, 32, 1548, 14, 1308, 6244, 298, 1598, 298, 45, 7455, 5444, 4456, 665, 2664, 415, 14, 422, 4456, 32, 6799, 14, 957, 6244, 298, 1598, 298, 6470, 820, 527, 23235, 665, 1657, 14, 20791, 23235, 32, 5193, 14, 331, 14, 3210, 6244, 298, 1598, 298, 33, 29680, 1132, 510, 390, 7930, 665, 1152, 3587, 2316, 32, 80, 390, 7930, 14, 846, 6244, 298, 1598, 298, 33, 391, 18359, 2104, 303, 357, 366, 7, 27604, 665, 14541, 18359, 667, 32, 6799, 14, 957, 6244, 298, 1598, 298, 31231, 16997, 262, 22912, 834, 665, 18486, 16997, 262, 32, 1548, 14, 1308, 9579, 199, 199, 363, 452, 363, 275, 2097, 27132, 13760, 401, 298, 1490, 401, 298, 23413, 401, 298, 7963, 23413, 401, 298, 26126, 401, 1779, 298, 15466, 401, 298, 6424, 401, 298, 23139, 23413, 401, 1779, 298, 23139, 5929, 401, 298, 23139, 6261, 401, 298, 23139, 25438, 12882, 401, 1779, 298, 23139, 3883, 401, 298, 1872, 23413, 401, 298, 1872, 29365, 401, 1779, 298, 12647, 6044, 401, 298, 18439, 63, 3597, 401, 298, 18439, 63, 7013, 401, 298, 18439, 63, 3902, 937, 421, 199, 646, 485, 2308, 199, 646, 13022, 199, 199, 504, 485, 2308, 492, 334, 3472, 63, 10960, 63, 4305, 12, 8651, 316, 13760, 12, 19022, 6044, 12, 326, 1551, 12, 3814, 2090, 12, 11808, 12, 5228, 12, 26832, 5929, 12, 326, 26832, 6261, 12, 26832, 25438, 12882, 12, 26832, 3883, 12, 326, 14684, 4665, 604, 8326, 12, 4516, 29365, 9, 199, 199, 4299, 4590, 275, 485, 2308, 14, 1490, 327, 367, 7163, 543, 485, 647, 2308, 199, 199, 3, 367, 12005, 342, 199, 18439, 63, 3597, 275, 378, 199, 18439, 63, 7013, 275, 413, 199, 18439, 63, 3902, 275, 499, 199, 199, 3, 1487, 4925, 316, 17281, 83, 315, 445, 365, 32553, 880, 781, 886, 652, 2348, 14, 199, 3, 9075, 18714, 436, 849, 12591, 787, 12623, 687, 314, 445, 199, 3, 1015, 13432, 14, 199, 533, 5004, 1563, 1547, 2308, 423, 23413, 304, 272, 636, 6577, 363, 275, 13022, 14, 22254, 272, 636, 1301, 363, 275, 485, 2308, 423, 23413, 855, 1301, 363, 199, 199, 533, 13480, 23413, 1547, 2308, 423, 7963, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 7963, 23413, 855, 1301, 363, 199, 199, 533, 26832, 23413, 1547, 2308, 423, 23139, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 23139, 23413, 855, 1301, 363, 199, 199, 533, 4516, 23413, 1547, 2308, 423, 1872, 23413, 12, 5004, 1563, 304, 272, 636, 1301, 363, 275, 485, 2308, 423, 1872, 23413, 855, 1301, 363, 199, 199, 7963, 23413, 14, 2683, 8, 26126, 9, 199, 199, 509, 8531, 315, 334, 15466, 12, 26832, 5929, 12, 26832, 6261, 12, 26832, 3883, 12, 1598, 26832, 25438, 12882, 304, 272, 26832, 23413, 14, 2683, 8, 11645, 9, 199, 199, 509, 8531, 315, 334, 6424, 12, 4516, 29365, 304, 272, 4516, 23413, 14, 2683, 8, 11645, 9, 199, 2264, 8531, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
fduraffourg/servo
tests/wpt/web-platform-tests/tools/pywebsocket/src/mod_pywebsocket/util.py
497
13858
# Copyright 2011, 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. """WebSocket utilities. """ import array import errno # Import hash classes from a module available and recommended for each Python # version and re-export those symbol. Use sha and md5 module in Python 2.4, and # hashlib module in Python 2.6. try: import hashlib md5_hash = hashlib.md5 sha1_hash = hashlib.sha1 except ImportError: import md5 import sha md5_hash = md5.md5 sha1_hash = sha.sha import StringIO import logging import os import re import socket import traceback import zlib try: from mod_pywebsocket import fast_masking except ImportError: pass def get_stack_trace(): """Get the current stack trace as string. This is needed to support Python 2.3. TODO: Remove this when we only support Python 2.4 and above. Use traceback.format_exc instead. """ out = StringIO.StringIO() traceback.print_exc(file=out) return out.getvalue() def prepend_message_to_exception(message, exc): """Prepend message to the exception.""" exc.args = (message + str(exc),) return def __translate_interp(interp, cygwin_path): """Translate interp program path for Win32 python to run cygwin program (e.g. perl). Note that it doesn't support path that contains space, which is typically true for Unix, where #!-script is written. For Win32 python, cygwin_path is a directory of cygwin binaries. Args: interp: interp command line cygwin_path: directory name of cygwin binary, or None Returns: translated interp command line. """ if not cygwin_path: return interp m = re.match('^[^ ]*/([^ ]+)( .*)?', interp) if m: cmd = os.path.join(cygwin_path, m.group(1)) return cmd + m.group(2) return interp def get_script_interp(script_path, cygwin_path=None): """Gets #!-interpreter command line from the script. It also fixes command path. When Cygwin Python is used, e.g. in WebKit, it could run "/usr/bin/perl -wT hello.pl". When Win32 Python is used, e.g. in Chromium, it couldn't. So, fix "/usr/bin/perl" to "<cygwin_path>\perl.exe". Args: script_path: pathname of the script cygwin_path: directory name of cygwin binary, or None Returns: #!-interpreter command line, or None if it is not #!-script. """ fp = open(script_path) line = fp.readline() fp.close() m = re.match('^#!(.*)', line) if m: return __translate_interp(m.group(1), cygwin_path) return None def wrap_popen3_for_win(cygwin_path): """Wrap popen3 to support #!-script on Windows. Args: cygwin_path: path for cygwin binary if command path is needed to be translated. None if no translation required. """ __orig_popen3 = os.popen3 def __wrap_popen3(cmd, mode='t', bufsize=-1): cmdline = cmd.split(' ') interp = get_script_interp(cmdline[0], cygwin_path) if interp: cmd = interp + ' ' + cmd return __orig_popen3(cmd, mode, bufsize) os.popen3 = __wrap_popen3 def hexify(s): return ' '.join(map(lambda x: '%02x' % ord(x), s)) def get_class_logger(o): return logging.getLogger( '%s.%s' % (o.__class__.__module__, o.__class__.__name__)) class NoopMasker(object): """A masking object that has the same interface as RepeatedXorMasker but just returns the string passed in without making any change. """ def __init__(self): pass def mask(self, s): return s class RepeatedXorMasker(object): """A masking object that applies XOR on the string given to mask method with the masking bytes given to the constructor repeatedly. This object remembers the position in the masking bytes the last mask method call ended and resumes from that point on the next mask method call. """ def __init__(self, masking_key): self._masking_key = masking_key self._masking_key_index = 0 def _mask_using_swig(self, s): masked_data = fast_masking.mask( s, self._masking_key, self._masking_key_index) self._masking_key_index = ( (self._masking_key_index + len(s)) % len(self._masking_key)) return masked_data def _mask_using_array(self, s): result = array.array('B') result.fromstring(s) # Use temporary local variables to eliminate the cost to access # attributes masking_key = map(ord, self._masking_key) masking_key_size = len(masking_key) masking_key_index = self._masking_key_index for i in xrange(len(result)): result[i] ^= masking_key[masking_key_index] masking_key_index = (masking_key_index + 1) % masking_key_size self._masking_key_index = masking_key_index return result.tostring() if 'fast_masking' in globals(): mask = _mask_using_swig else: mask = _mask_using_array # By making wbits option negative, we can suppress CMF/FLG (2 octet) and # ADLER32 (4 octet) fields of zlib so that we can use zlib module just as # deflate library. DICTID won't be added as far as we don't set dictionary. # LZ77 window of 32K will be used for both compression and decompression. # For decompression, we can just use 32K to cover any windows size. For # compression, we use 32K so receivers must use 32K. # # Compression level is Z_DEFAULT_COMPRESSION. We don't have to match level # to decode. # # See zconf.h, deflate.cc, inflate.cc of zlib library, and zlibmodule.c of # Python. See also RFC1950 (ZLIB 3.3). class _Deflater(object): def __init__(self, window_bits): self._logger = get_class_logger(self) self._compress = zlib.compressobj( zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -window_bits) def compress(self, bytes): compressed_bytes = self._compress.compress(bytes) self._logger.debug('Compress input %r', bytes) self._logger.debug('Compress result %r', compressed_bytes) return compressed_bytes def compress_and_flush(self, bytes): compressed_bytes = self._compress.compress(bytes) compressed_bytes += self._compress.flush(zlib.Z_SYNC_FLUSH) self._logger.debug('Compress input %r', bytes) self._logger.debug('Compress result %r', compressed_bytes) return compressed_bytes def compress_and_finish(self, bytes): compressed_bytes = self._compress.compress(bytes) compressed_bytes += self._compress.flush(zlib.Z_FINISH) self._logger.debug('Compress input %r', bytes) self._logger.debug('Compress result %r', compressed_bytes) return compressed_bytes class _Inflater(object): def __init__(self, window_bits): self._logger = get_class_logger(self) self._window_bits = window_bits self._unconsumed = '' self.reset() def decompress(self, size): if not (size == -1 or size > 0): raise Exception('size must be -1 or positive') data = '' while True: if size == -1: data += self._decompress.decompress(self._unconsumed) # See Python bug http://bugs.python.org/issue12050 to # understand why the same code cannot be used for updating # self._unconsumed for here and else block. self._unconsumed = '' else: data += self._decompress.decompress( self._unconsumed, size - len(data)) self._unconsumed = self._decompress.unconsumed_tail if self._decompress.unused_data: # Encountered a last block (i.e. a block with BFINAL = 1) and # found a new stream (unused_data). We cannot use the same # zlib.Decompress object for the new stream. Create a new # Decompress object to decompress the new one. # # It's fine to ignore unconsumed_tail if unused_data is not # empty. self._unconsumed = self._decompress.unused_data self.reset() if size >= 0 and len(data) == size: # data is filled. Don't call decompress again. break else: # Re-invoke Decompress.decompress to try to decompress all # available bytes before invoking read which blocks until # any new byte is available. continue else: # Here, since unused_data is empty, even if unconsumed_tail is # not empty, bytes of requested length are already in data. We # don't have to "continue" here. break if data: self._logger.debug('Decompressed %r', data) return data def append(self, data): self._logger.debug('Appended %r', data) self._unconsumed += data def reset(self): self._logger.debug('Reset') self._decompress = zlib.decompressobj(-self._window_bits) # Compresses/decompresses given octets using the method introduced in RFC1979. class _RFC1979Deflater(object): """A compressor class that applies DEFLATE to given byte sequence and flushes using the algorithm described in the RFC1979 section 2.1. """ def __init__(self, window_bits, no_context_takeover): self._deflater = None if window_bits is None: window_bits = zlib.MAX_WBITS self._window_bits = window_bits self._no_context_takeover = no_context_takeover def filter(self, bytes, end=True, bfinal=False): if self._deflater is None: self._deflater = _Deflater(self._window_bits) if bfinal: result = self._deflater.compress_and_finish(bytes) # Add a padding block with BFINAL = 0 and BTYPE = 0. result = result + chr(0) self._deflater = None return result result = self._deflater.compress_and_flush(bytes) if end: # Strip last 4 octets which is LEN and NLEN field of a # non-compressed block added for Z_SYNC_FLUSH. result = result[:-4] if self._no_context_takeover and end: self._deflater = None return result class _RFC1979Inflater(object): """A decompressor class for byte sequence compressed and flushed following the algorithm described in the RFC1979 section 2.1. """ def __init__(self, window_bits=zlib.MAX_WBITS): self._inflater = _Inflater(window_bits) def filter(self, bytes): # Restore stripped LEN and NLEN field of a non-compressed block added # for Z_SYNC_FLUSH. self._inflater.append(bytes + '\x00\x00\xff\xff') return self._inflater.decompress(-1) class DeflateSocket(object): """A wrapper class for socket object to intercept send and recv to perform deflate compression and decompression transparently. """ # Size of the buffer passed to recv to receive compressed data. _RECV_SIZE = 4096 def __init__(self, socket): self._socket = socket self._logger = get_class_logger(self) self._deflater = _Deflater(zlib.MAX_WBITS) self._inflater = _Inflater(zlib.MAX_WBITS) def recv(self, size): """Receives data from the socket specified on the construction up to the specified size. Once any data is available, returns it even if it's smaller than the specified size. """ # TODO(tyoshino): Allow call with size=0. It should block until any # decompressed data is available. if size <= 0: raise Exception('Non-positive size passed') while True: data = self._inflater.decompress(size) if len(data) != 0: return data read_data = self._socket.recv(DeflateSocket._RECV_SIZE) if not read_data: return '' self._inflater.append(read_data) def sendall(self, bytes): self.send(bytes) def send(self, bytes): self._socket.sendall(self._deflater.compress_and_flush(bytes)) return len(bytes) # vi:sts=4 sw=4 et
mpl-2.0
[ 3, 1898, 7760, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 18477, 15841, 14, 199, 624, 421, 199, 646, 1625, 199, 646, 7554, 199, 199, 3, 3161, 2631, 3992, 687, 282, 859, 2808, 436, 14318, 367, 1924, 2018, 199, 3, 1015, 436, 295, 13, 3790, 5204, 5272, 14, 3645, 7793, 436, 6128, 21, 859, 315, 2018, 499, 14, 20, 12, 436, 199, 3, 8337, 859, 315, 2018, 499, 14, 22, 14, 199, 893, 26, 272, 492, 8337, 272, 6128, 21, 63, 2227, 275, 8337, 14, 1064, 21, 272, 7793, 17, 63, 2227, 275, 8337, 14, 4835, 17, 199, 2590, 3545, 26, 272, 492, 6128, 21, 272, 492, 7793, 272, 6128, 21, 63, 2227, 275, 6128, 21, 14, 1064, 21, 272, 7793, 17, 63, 2227, 275, 7793, 14, 4835, 199, 199, 646, 5228, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 2838, 199, 646, 5190, 199, 646, 12472, 199, 199, 893, 26, 272, 687, 3413, 63, 21387, 492, 7377, 63, 2629, 316, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 664, 63, 2340, 63, 3446, 837, 272, 408, 1002, 314, 1453, 3464, 3307, 465, 1059, 14, 339, 961, 365, 4346, 370, 2291, 2018, 499, 14, 19, 14, 272, 3254, 26, 5852, 642, 1380, 781, 1454, 2291, 2018, 499, 14, 20, 436, 3432, 14, 881, 3645, 5190, 14, 908, 63, 2804, 3140, 14, 272, 408, 339, 734, 275, 5228, 14, 6424, 342, 272, 5190, 14, 1361, 63, 2804, 8, 493, 29, 548, 9, 272, 372, 734, 14, 7150, 342, 421, 199, 318, 18213, 63, 1188, 63, 475, 63, 1971, 8, 1188, 12, 3178, 304, 272, 408, 24001, 500, 1245, 370, 314, 1919, 1041, 339, 3178, 14, 589, 275, 334, 1188, 435, 620, 8, 2804, 16945, 272, 372, 421, 199, 318, 636, 5275, 63, 14252, 8, 14252, 12, 23941, 63, 515, 304, 272, 408, 18355, 23716, 2240, 931, 367, 13036, 708, 2366, 370, 1255, 23941, 2240, 272, 334, 69, 14, 71, 14, 1126, 76, 680, 221, 3390, 626, 652, 3181, 1133, 2291, 931, 626, 3509, 4601, 12, 272, 1314, 365, 13609, 2549, 367, 13074, 12, 2382, 327, 1, 13, 1579, 365, 5313, 14, 272, 2104, 13036, 708, 2366, 12, 23941, 63, 515, 365, 282, 2082, 402, 23941, 21984, 14, 339, 3033, 26, 489, 23716, 26, 23716, 1414, 1004, 489, 23941, 63, 515, 26, 2082, 536, 402, 23941, 3366, 12, 503, 488, 272, 1803, 26, 489, 14598, 23716, 1414, 1004, 14, 272, 408, 272, 340, 440, 23941, 63, 515, 26, 267, 372, 23716, 272, 333, 275, 295, 14, 1431, 9097, 4735, 1622, 15870, 7059, 1622, 29653, 23076, 5547, 297, 23716, 9, 272, 340, 333, 26, 267, 2088, 275, 747, 14, 515, 14, 904, 8, 16680, 63, 515, 12, 333, 14, 923, 8, 17, 430, 267, 372, 2088, 435, 333, 14, 923, 8, 18, 9, 272, 372, 23716, 421, 199, 318, 664, 63, 1579, 63, 14252, 8, 1579, 63, 515, 12, 23941, 63, 515, 29, 403, 304, 272, 408, 14426, 327, 1, 13, 20244, 1414, 1004, 687, 314, 2884, 14, 339, 2779, 2597, 25079, 1414, 931, 14, 221, 3979, 445, 18313, 2018, 365, 1202, 12, 325, 14, 71, 14, 315, 6001, 14591, 12, 272, 652, 4293, 1255, 3286, 2647, 15, 1393, 15, 22805, 446, 87, 52, 16509, 14, 1168, 1674, 272, 3979, 13036, 708, 2018, 365, 1202, 12, 325, 14, 71, 14, 315, 12051, 12, 652, 21554, 1133, 14, 221, 2002, 12, 5325, 272, 3286, 2647, 15, 1393, 15, 22805, 2, 370, 3886, 16680, 63, 515, 3072, 22805, 14, 5803, 1674, 339, 3033, 26, 489, 2884, 63, 515, 26, 11776, 402, 314, 2884, 489, 23941, 63, 515, 26, 2082, 536, 402, 23941, 3366, 12, 503, 488, 272, 1803, 26, 489, 327, 1, 13, 20244, 1414, 1004, 12, 503, 488, 340, 652, 365, 440, 327, 1, 13, 1579, 14, 272, 408, 272, 4090, 275, 1551, 8, 1579, 63, 515, 9, 272, 1004, 275, 4090, 14, 6407, 342, 272, 4090, 14, 1600, 342, 272, 333, 275, 295, 14, 1431, 9097, 3168, 19276, 3196, 1004, 9, 272, 340, 333, 26, 267, 372, 636, 5275, 63, 14252, 8, 77, 14, 923, 8, 17, 395, 23941, 63, 515, 9, 272, 372, 488, 421, 199, 318, 4816, 63, 12207, 19, 63, 509, 63, 2676, 8, 16680, 63, 515, 304, 272, 408, 15991, 17758, 19, 370, 2291, 327, 1, 13 ]
[ 1898, 7760, 12, 4475, 3277, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 199, 3, 7100, 12, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 199, 3, 7647, 26, 199, 3, 199, 3, 258, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 258, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 199, 3, 4248, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 199, 3, 315, 314, 3794, 436, 15, 269, 1163, 8418, 2741, 543, 314, 199, 3, 4084, 14, 199, 3, 258, 627, 11443, 314, 536, 402, 4475, 3277, 14, 6590, 314, 1561, 402, 2399, 199, 3, 8417, 1443, 506, 1202, 370, 10692, 503, 10016, 7585, 7131, 687, 199, 3, 642, 2032, 1928, 2488, 6791, 5313, 4983, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 199, 3, 298, 1179, 2281, 2, 2401, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 2334, 5292, 2990, 1634, 3169, 2401, 3092, 2381, 199, 3, 437, 3115, 3104, 9315, 9706, 14, 1621, 4825, 6461, 7000, 2334, 5877, 199, 3, 11489, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 9716, 12, 199, 3, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 199, 3, 5471, 2296, 12, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 199, 3, 7126, 12, 1549, 9206, 27, 1549, 9748, 9831, 9, 9802, 9817, 2401, 5258, 1821, 199, 3, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 5603, 12, 1549, 7056, 199, 3, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 4815, 199, 3, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 421, 199, 624, 18477, 15841, 14, 199, 624, 421, 199, 646, 1625, 199, 646, 7554, 199, 199, 3, 3161, 2631, 3992, 687, 282, 859, 2808, 436, 14318, 367, 1924, 2018, 199, 3, 1015, 436, 295, 13, 3790, 5204, 5272, 14, 3645, 7793, 436, 6128, 21, 859, 315, 2018, 499, 14, 20, 12, 436, 199, 3, 8337, 859, 315, 2018, 499, 14, 22, 14, 199, 893, 26, 272, 492, 8337, 272, 6128, 21, 63, 2227, 275, 8337, 14, 1064, 21, 272, 7793, 17, 63, 2227, 275, 8337, 14, 4835, 17, 199, 2590, 3545, 26, 272, 492, 6128, 21, 272, 492, 7793, 272, 6128, 21, 63, 2227, 275, 6128, 21, 14, 1064, 21, 272, 7793, 17, 63, 2227, 275, 7793, 14, 4835, 199, 199, 646, 5228, 199, 646, 2050, 199, 646, 747, 199, 646, 295, 199, 646, 2838, 199, 646, 5190, 199, 646, 12472, 199, 199, 893, 26, 272, 687, 3413, 63, 21387, 492, 7377, 63, 2629, 316, 199, 2590, 3545, 26, 272, 986, 421, 199, 318, 664, 63, 2340, 63, 3446, 837, 272, 408, 1002, 314, 1453, 3464, 3307, 465, 1059, 14, 339, 961, 365, 4346, 370, 2291, 2018, 499, 14, 19, 14, 272, 3254, 26, 5852, 642, 1380, 781, 1454, 2291, 2018, 499, 14, 20, 436, 3432, 14, 881, 3645, 5190, 14, 908, 63, 2804, 3140, 14, 272, 408, 339, 734, 275, 5228, 14, 6424, 342, 272, 5190, 14, 1361, 63, 2804, 8, 493, 29, 548, 9, 272, 372, 734, 14, 7150, 342, 421, 199, 318, 18213, 63, 1188, 63, 475, 63, 1971, 8, 1188, 12, 3178, 304, 272, 408, 24001, 500, 1245, 370, 314, 1919, 1041, 339, 3178, 14, 589, 275, 334, 1188, 435, 620, 8, 2804, 16945, 272, 372, 421, 199, 318, 636, 5275, 63, 14252, 8, 14252, 12, 23941, 63, 515, 304, 272, 408, 18355, 23716, 2240, 931, 367, 13036, 708, 2366, 370, 1255, 23941, 2240, 272, 334, 69, 14, 71, 14, 1126, 76, 680, 221, 3390, 626, 652, 3181, 1133, 2291, 931, 626, 3509, 4601, 12, 272, 1314, 365, 13609, 2549, 367, 13074, 12, 2382, 327, 1, 13, 1579, 365, 5313, 14, 272, 2104, 13036, 708, 2366, 12, 23941, 63, 515, 365, 282, 2082, 402, 23941, 21984, 14, 339, 3033, 26, 489, 23716, 26, 23716, 1414, 1004, 489, 23941, 63, 515, 26, 2082, 536, 402, 23941, 3366, 12, 503, 488, 272, 1803, 26, 489, 14598, 23716, 1414, 1004, 14, 272, 408, 272, 340, 440, 23941, 63, 515, 26, 267, 372, 23716, 272, 333, 275, 295, 14, 1431, 9097, 4735, 1622, 15870, 7059, 1622, 29653, 23076, 5547, 297, 23716, 9, 272, 340, 333, 26, 267, 2088, 275, 747, 14, 515, 14, 904, 8, 16680, 63, 515, 12, 333, 14, 923, 8, 17, 430, 267, 372, 2088, 435, 333, 14, 923, 8, 18, 9, 272, 372, 23716, 421, 199, 318, 664, 63, 1579, 63, 14252, 8, 1579, 63, 515, 12, 23941, 63, 515, 29, 403, 304, 272, 408, 14426, 327, 1, 13, 20244, 1414, 1004, 687, 314, 2884, 14, 339, 2779, 2597, 25079, 1414, 931, 14, 221, 3979, 445, 18313, 2018, 365, 1202, 12, 325, 14, 71, 14, 315, 6001, 14591, 12, 272, 652, 4293, 1255, 3286, 2647, 15, 1393, 15, 22805, 446, 87, 52, 16509, 14, 1168, 1674, 272, 3979, 13036, 708, 2018, 365, 1202, 12, 325, 14, 71, 14, 315, 12051, 12, 652, 21554, 1133, 14, 221, 2002, 12, 5325, 272, 3286, 2647, 15, 1393, 15, 22805, 2, 370, 3886, 16680, 63, 515, 3072, 22805, 14, 5803, 1674, 339, 3033, 26, 489, 2884, 63, 515, 26, 11776, 402, 314, 2884, 489, 23941, 63, 515, 26, 2082, 536, 402, 23941, 3366, 12, 503, 488, 272, 1803, 26, 489, 327, 1, 13, 20244, 1414, 1004, 12, 503, 488, 340, 652, 365, 440, 327, 1, 13, 1579, 14, 272, 408, 272, 4090, 275, 1551, 8, 1579, 63, 515, 9, 272, 1004, 275, 4090, 14, 6407, 342, 272, 4090, 14, 1600, 342, 272, 333, 275, 295, 14, 1431, 9097, 3168, 19276, 3196, 1004, 9, 272, 340, 333, 26, 267, 372, 636, 5275, 63, 14252, 8, 77, 14, 923, 8, 17, 395, 23941, 63, 515, 9, 272, 372, 488, 421, 199, 318, 4816, 63, 12207, 19, 63, 509, 63, 2676, 8, 16680, 63, 515, 304, 272, 408, 15991, 17758, 19, 370, 2291, 327, 1, 13, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
catapult-project/catapult-csm
third_party/gsutil/third_party/boto/tests/integration/cognito/identity/test_cognito_identity.py
112
2545
# Copyright (c) 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. # from boto.cognito.identity.exceptions import ResourceNotFoundException from tests.integration.cognito import CognitoTest class TestCognitoIdentity(CognitoTest): """ Test Cognitoy identity pools operations since individual Cognito identities require an AWS account ID. """ def test_cognito_identity(self): # Ensure the identity pool is in the list of pools. response = self.cognito_identity.list_identity_pools(max_results=5) expected_identity = {'IdentityPoolId': self.identity_pool_id, 'IdentityPoolName': self.identity_pool_name} self.assertIn(expected_identity, response['IdentityPools']) # Ensure the pool's attributes are as expected. response = self.cognito_identity.describe_identity_pool( identity_pool_id=self.identity_pool_id ) self.assertEqual(response['IdentityPoolName'], self.identity_pool_name) self.assertEqual(response['IdentityPoolId'], self.identity_pool_id) self.assertFalse(response['AllowUnauthenticatedIdentities']) def test_resource_not_found_exception(self): with self.assertRaises(ResourceNotFoundException): # Note the region is us-east-0 which is an invalid region name. self.cognito_identity.describe_identity_pool( identity_pool_id='us-east-0:c09e640-b014-4822-86b9-ec77c40d8d6f' )
bsd-3-clause
[ 3, 1898, 334, 67, 9, 6927, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 199, 504, 6055, 14, 6862, 24308, 14, 5582, 14, 3924, 492, 7337, 22646, 199, 504, 2295, 14, 15092, 14, 6862, 24308, 492, 1849, 784, 24308, 774, 421, 199, 533, 1379, 967, 784, 24308, 10193, 8, 967, 784, 24308, 774, 304, 272, 408, 272, 1379, 1849, 784, 24308, 89, 8503, 20092, 5331, 3967, 8212, 1849, 784, 24308, 6120, 5080, 272, 4409, 376, 10168, 2933, 2870, 14, 272, 408, 272, 347, 511, 63, 6862, 24308, 63, 5582, 8, 277, 304, 267, 327, 7523, 314, 8503, 4203, 365, 315, 314, 769, 402, 20092, 14, 267, 1177, 275, 291, 14, 6862, 24308, 63, 5582, 14, 513, 63, 5582, 63, 12406, 8, 988, 63, 2604, 29, 21, 9, 267, 1420, 63, 5582, 275, 791, 10193, 5453, 1304, 356, 291, 14, 5582, 63, 2293, 63, 344, 12, 2490, 283, 10193, 5453, 985, 356, 291, 14, 5582, 63, 2293, 63, 354, 93, 267, 291, 14, 4080, 8, 2062, 63, 5582, 12, 1177, 459, 10193, 31633, 1105, 398, 327, 7523, 314, 4203, 1159, 3004, 787, 465, 1420, 14, 267, 1177, 275, 291, 14, 6862, 24308, 63, 5582, 14, 11935, 63, 5582, 63, 2293, 8, 288, 8503, 63, 2293, 63, 344, 29, 277, 14, 5582, 63, 2293, 63, 344, 267, 776, 267, 291, 14, 629, 8, 1310, 459, 10193, 5453, 985, 995, 291, 14, 5582, 63, 2293, 63, 354, 9, 267, 291, 14, 629, 8, 1310, 459, 10193, 5453, 1304, 995, 291, 14, 5582, 63, 2293, 63, 344, 9, 267, 291, 14, 3334, 8, 1310, 459, 7852, 1358, 12177, 17062, 5080, 1105, 339, 347, 511, 63, 1927, 63, 1397, 63, 4214, 63, 1971, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4031, 22646, 304, 288, 327, 3390, 314, 4897, 365, 2739, 13, 14346, 13, 16, 1314, 365, 376, 3866, 4897, 536, 14, 288, 291, 14, 6862, 24308, 63, 5582, 14, 11935, 63, 5582, 63, 2293, 8, 355, 8503, 63, 2293, 63, 344, 534, 527, 13, 14346, 13, 16, 26, 67, 1643, 69, 12021, 13, 66, 10752, 13, 2006, 1081, 13, 1184, 66, 25, 13, 825, 1138, 67, 2167, 68, 24, 68, 22, 70, 7, 288, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 6927, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 221, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 199, 3, 199, 199, 504, 6055, 14, 6862, 24308, 14, 5582, 14, 3924, 492, 7337, 22646, 199, 504, 2295, 14, 15092, 14, 6862, 24308, 492, 1849, 784, 24308, 774, 421, 199, 533, 1379, 967, 784, 24308, 10193, 8, 967, 784, 24308, 774, 304, 272, 408, 272, 1379, 1849, 784, 24308, 89, 8503, 20092, 5331, 3967, 8212, 1849, 784, 24308, 6120, 5080, 272, 4409, 376, 10168, 2933, 2870, 14, 272, 408, 272, 347, 511, 63, 6862, 24308, 63, 5582, 8, 277, 304, 267, 327, 7523, 314, 8503, 4203, 365, 315, 314, 769, 402, 20092, 14, 267, 1177, 275, 291, 14, 6862, 24308, 63, 5582, 14, 513, 63, 5582, 63, 12406, 8, 988, 63, 2604, 29, 21, 9, 267, 1420, 63, 5582, 275, 791, 10193, 5453, 1304, 356, 291, 14, 5582, 63, 2293, 63, 344, 12, 2490, 283, 10193, 5453, 985, 356, 291, 14, 5582, 63, 2293, 63, 354, 93, 267, 291, 14, 4080, 8, 2062, 63, 5582, 12, 1177, 459, 10193, 31633, 1105, 398, 327, 7523, 314, 4203, 1159, 3004, 787, 465, 1420, 14, 267, 1177, 275, 291, 14, 6862, 24308, 63, 5582, 14, 11935, 63, 5582, 63, 2293, 8, 288, 8503, 63, 2293, 63, 344, 29, 277, 14, 5582, 63, 2293, 63, 344, 267, 776, 267, 291, 14, 629, 8, 1310, 459, 10193, 5453, 985, 995, 291, 14, 5582, 63, 2293, 63, 354, 9, 267, 291, 14, 629, 8, 1310, 459, 10193, 5453, 1304, 995, 291, 14, 5582, 63, 2293, 63, 344, 9, 267, 291, 14, 3334, 8, 1310, 459, 7852, 1358, 12177, 17062, 5080, 1105, 339, 347, 511, 63, 1927, 63, 1397, 63, 4214, 63, 1971, 8, 277, 304, 267, 543, 291, 14, 1855, 8, 4031, 22646, 304, 288, 327, 3390, 314, 4897, 365, 2739, 13, 14346, 13, 16, 1314, 365, 376, 3866, 4897, 536, 14, 288, 291, 14, 6862, 24308, 63, 5582, 14, 11935, 63, 5582, 63, 2293, 8, 355, 8503, 63, 2293, 63, 344, 534, 527, 13, 14346, 13, 16, 26, 67, 1643, 69, 12021, 13, 66, 10752, 13, 2006, 1081, 13, 1184, 66, 25, 13, 825, 1138, 67, 2167, 68, 24, 68, 22, 70, 7, 288, 776, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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section 8 - Decision Tree Regression/regression_template.py
22
1424
# Regression Template # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:, 1:2].values y = dataset.iloc[:, 2].values # Splitting the dataset into the Training set and Test set """from sklearn.cross_validation import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)""" # Feature Scaling """from sklearn.preprocessing import StandardScaler sc_X = StandardScaler() X_train = sc_X.fit_transform(X_train) X_test = sc_X.transform(X_test) sc_y = StandardScaler() y_train = sc_y.fit_transform(y_train)""" # Fitting the Regression Model to the dataset # Create your regressor here # Predicting a new result y_pred = regressor.predict(6.5) # Visualising the Regression results plt.scatter(X, y, color = 'red') plt.plot(X, regressor.predict(X), color = 'blue') plt.title('Truth or Bluff (Regression Model)') plt.xlabel('Position level') plt.ylabel('Salary') plt.show() # Visualising the Regression results (for higher resolution and smoother curve) X_grid = np.arange(min(X), max(X), 0.1) X_grid = X_grid.reshape((len(X_grid), 1)) plt.scatter(X, y, color = 'red') plt.plot(X_grid, regressor.predict(X_grid), color = 'blue') plt.title('Truth or Bluff (Regression Model)') plt.xlabel('Position level') plt.ylabel('Salary') plt.show()
mit
[ 3, 13262, 5458, 199, 199, 3, 3161, 316, 314, 8363, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 10634, 465, 6454, 199, 199, 3, 3161, 316, 314, 4789, 199, 5214, 275, 6454, 14, 739, 63, 4737, 360, 5625, 63, 27177, 3433, 14, 4737, 358, 199, 56, 275, 4789, 14, 21104, 3981, 413, 26, 18, 1055, 1459, 199, 89, 275, 4789, 14, 21104, 3981, 499, 1055, 1459, 199, 199, 3, 11740, 1337, 314, 4789, 1901, 314, 22859, 663, 436, 1379, 663, 199, 624, 504, 6357, 14, 7925, 63, 6136, 492, 3560, 63, 396, 63, 1294, 199, 56, 63, 2834, 12, 1323, 63, 396, 12, 612, 63, 2834, 12, 612, 63, 396, 275, 3560, 63, 396, 63, 1294, 8, 56, 12, 612, 12, 511, 63, 890, 275, 378, 14, 18, 12, 2196, 63, 929, 275, 378, 9471, 199, 199, 3, 13407, 17619, 316, 199, 624, 504, 6357, 14, 21402, 492, 9739, 24274, 199, 551, 63, 56, 275, 9739, 24274, 342, 199, 56, 63, 2834, 275, 4061, 63, 56, 14, 3269, 63, 4711, 8, 56, 63, 2834, 9, 199, 56, 63, 396, 275, 4061, 63, 56, 14, 4711, 8, 56, 63, 396, 9, 199, 551, 63, 89, 275, 9739, 24274, 342, 199, 89, 63, 2834, 275, 4061, 63, 89, 14, 3269, 63, 4711, 8, 89, 63, 2834, 9471, 199, 199, 3, 25971, 1337, 314, 13262, 5822, 370, 314, 4789, 199, 3, 2790, 2195, 1295, 11686, 2348, 199, 199, 3, 5543, 807, 316, 282, 892, 754, 199, 89, 63, 5991, 275, 1295, 11686, 14, 6892, 8, 22, 14, 21, 9, 199, 199, 3, 14702, 11136, 314, 13262, 2058, 199, 6003, 14, 13512, 8, 56, 12, 612, 12, 3164, 275, 283, 581, 358, 199, 6003, 14, 2798, 8, 56, 12, 1295, 11686, 14, 6892, 8, 56, 395, 3164, 275, 283, 6304, 358, 199, 6003, 14, 1213, 360, 14064, 762, 503, 699, 76, 3043, 334, 13013, 5822, 5942, 199, 6003, 14, 14168, 360, 5625, 2166, 358, 199, 6003, 14, 13849, 360, 27177, 695, 358, 199, 6003, 14, 2384, 342, 199, 199, 3, 14702, 11136, 314, 13262, 2058, 334, 509, 10948, 12401, 436, 308, 573, 1848, 15318, 9, 199, 56, 63, 3825, 275, 980, 14, 5605, 8, 827, 8, 56, 395, 1390, 8, 56, 395, 378, 14, 17, 9, 199, 56, 63, 3825, 275, 1323, 63, 3825, 14, 5217, 1332, 552, 8, 56, 63, 3825, 395, 413, 430, 199, 6003, 14, 13512, 8, 56, 12, 612, 12, 3164, 275, 283, 581, 358, 199, 6003, 14, 2798, 8, 56, 63, 3825, 12, 1295, 11686, 14, 6892, 8, 56, 63, 3825, 395, 3164, 275, 283, 6304, 358, 199, 6003, 14, 1213, 360, 14064, 762, 503, 699, 76, 3043, 334, 13013, 5822, 5942, 199, 6003, 14, 14168, 360, 5625, 2166, 358, 199, 6003, 14, 13849, 360, 27177, 695, 358, 199, 6003, 14, 2384, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 13262, 5458, 199, 199, 3, 3161, 316, 314, 8363, 199, 646, 2680, 465, 980, 199, 646, 8027, 14, 13563, 465, 4488, 199, 646, 10634, 465, 6454, 199, 199, 3, 3161, 316, 314, 4789, 199, 5214, 275, 6454, 14, 739, 63, 4737, 360, 5625, 63, 27177, 3433, 14, 4737, 358, 199, 56, 275, 4789, 14, 21104, 3981, 413, 26, 18, 1055, 1459, 199, 89, 275, 4789, 14, 21104, 3981, 499, 1055, 1459, 199, 199, 3, 11740, 1337, 314, 4789, 1901, 314, 22859, 663, 436, 1379, 663, 199, 624, 504, 6357, 14, 7925, 63, 6136, 492, 3560, 63, 396, 63, 1294, 199, 56, 63, 2834, 12, 1323, 63, 396, 12, 612, 63, 2834, 12, 612, 63, 396, 275, 3560, 63, 396, 63, 1294, 8, 56, 12, 612, 12, 511, 63, 890, 275, 378, 14, 18, 12, 2196, 63, 929, 275, 378, 9471, 199, 199, 3, 13407, 17619, 316, 199, 624, 504, 6357, 14, 21402, 492, 9739, 24274, 199, 551, 63, 56, 275, 9739, 24274, 342, 199, 56, 63, 2834, 275, 4061, 63, 56, 14, 3269, 63, 4711, 8, 56, 63, 2834, 9, 199, 56, 63, 396, 275, 4061, 63, 56, 14, 4711, 8, 56, 63, 396, 9, 199, 551, 63, 89, 275, 9739, 24274, 342, 199, 89, 63, 2834, 275, 4061, 63, 89, 14, 3269, 63, 4711, 8, 89, 63, 2834, 9471, 199, 199, 3, 25971, 1337, 314, 13262, 5822, 370, 314, 4789, 199, 3, 2790, 2195, 1295, 11686, 2348, 199, 199, 3, 5543, 807, 316, 282, 892, 754, 199, 89, 63, 5991, 275, 1295, 11686, 14, 6892, 8, 22, 14, 21, 9, 199, 199, 3, 14702, 11136, 314, 13262, 2058, 199, 6003, 14, 13512, 8, 56, 12, 612, 12, 3164, 275, 283, 581, 358, 199, 6003, 14, 2798, 8, 56, 12, 1295, 11686, 14, 6892, 8, 56, 395, 3164, 275, 283, 6304, 358, 199, 6003, 14, 1213, 360, 14064, 762, 503, 699, 76, 3043, 334, 13013, 5822, 5942, 199, 6003, 14, 14168, 360, 5625, 2166, 358, 199, 6003, 14, 13849, 360, 27177, 695, 358, 199, 6003, 14, 2384, 342, 199, 199, 3, 14702, 11136, 314, 13262, 2058, 334, 509, 10948, 12401, 436, 308, 573, 1848, 15318, 9, 199, 56, 63, 3825, 275, 980, 14, 5605, 8, 827, 8, 56, 395, 1390, 8, 56, 395, 378, 14, 17, 9, 199, 56, 63, 3825, 275, 1323, 63, 3825, 14, 5217, 1332, 552, 8, 56, 63, 3825, 395, 413, 430, 199, 6003, 14, 13512, 8, 56, 12, 612, 12, 3164, 275, 283, 581, 358, 199, 6003, 14, 2798, 8, 56, 63, 3825, 12, 1295, 11686, 14, 6892, 8, 56, 63, 3825, 395, 3164, 275, 283, 6304, 358, 199, 6003, 14, 1213, 360, 14064, 762, 503, 699, 76, 3043, 334, 13013, 5822, 5942, 199, 6003, 14, 14168, 360, 5625, 2166, 358, 199, 6003, 14, 13849, 360, 27177, 695, 358, 199, 6003, 14, 2384, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Marina-Gurrieri/montheme
node_modules/node-sass/node_modules/node-gyp/gyp/tools/pretty_sln.py
1831
5099
#!/usr/bin/env python # Copyright (c) 2012 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. """Prints the information in a sln file in a diffable way. It first outputs each projects in alphabetical order with their dependencies. Then it outputs a possible build order. """ __author__ = 'nsylvain (Nicolas Sylvain)' import os import re import sys import pretty_vcproj def BuildProject(project, built, projects, deps): # if all dependencies are done, we can build it, otherwise we try to build the # dependency. # This is not infinite-recursion proof. for dep in deps[project]: if dep not in built: BuildProject(dep, built, projects, deps) print project built.append(project) def ParseSolution(solution_file): # All projects, their clsid and paths. projects = dict() # A list of dependencies associated with a project. dependencies = dict() # Regular expressions that matches the SLN format. # The first line of a project definition. begin_project = re.compile(r'^Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942' r'}"\) = "(.*)", "(.*)", "(.*)"$') # The last line of a project definition. end_project = re.compile('^EndProject$') # The first line of a dependency list. begin_dep = re.compile( r'ProjectSection\(ProjectDependencies\) = postProject$') # The last line of a dependency list. end_dep = re.compile('EndProjectSection$') # A line describing a dependency. dep_line = re.compile(' *({.*}) = ({.*})$') in_deps = False solution = open(solution_file) for line in solution: results = begin_project.search(line) if results: # Hack to remove icu because the diff is too different. if results.group(1).find('icu') != -1: continue # We remove "_gyp" from the names because it helps to diff them. current_project = results.group(1).replace('_gyp', '') projects[current_project] = [results.group(2).replace('_gyp', ''), results.group(3), results.group(2)] dependencies[current_project] = [] continue results = end_project.search(line) if results: current_project = None continue results = begin_dep.search(line) if results: in_deps = True continue results = end_dep.search(line) if results: in_deps = False continue results = dep_line.search(line) if results and in_deps and current_project: dependencies[current_project].append(results.group(1)) continue # Change all dependencies clsid to name instead. for project in dependencies: # For each dependencies in this project new_dep_array = [] for dep in dependencies[project]: # Look for the project name matching this cldis for project_info in projects: if projects[project_info][1] == dep: new_dep_array.append(project_info) dependencies[project] = sorted(new_dep_array) return (projects, dependencies) def PrintDependencies(projects, deps): print "---------------------------------------" print "Dependencies for all projects" print "---------------------------------------" print "-- --" for (project, dep_list) in sorted(deps.items()): print "Project : %s" % project print "Path : %s" % projects[project][0] if dep_list: for dep in dep_list: print " - %s" % dep print "" print "-- --" def PrintBuildOrder(projects, deps): print "---------------------------------------" print "Build order " print "---------------------------------------" print "-- --" built = [] for (project, _) in sorted(deps.items()): if project not in built: BuildProject(project, built, projects, deps) print "-- --" def PrintVCProj(projects): for project in projects: print "-------------------------------------" print "-------------------------------------" print project print project print project print "-------------------------------------" print "-------------------------------------" project_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[1]), projects[project][2])) pretty = pretty_vcproj argv = [ '', project_path, '$(SolutionDir)=%s\\' % os.path.dirname(sys.argv[1]), ] argv.extend(sys.argv[3:]) pretty.main(argv) def main(): # check if we have exactly 1 parameter. if len(sys.argv) < 2: print 'Usage: %s "c:\\path\\to\\project.sln"' % sys.argv[0] return 1 (projects, deps) = ParseSolution(sys.argv[1]) PrintDependencies(projects, deps) PrintBuildOrder(projects, deps) if '--recursive' in sys.argv: PrintVCProj(projects) return 0 if __name__ == '__main__': sys.exit(main())
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 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, 26113, 314, 2556, 315, 282, 5340, 78, 570, 315, 282, 3915, 461, 4340, 14, 8410, 2779, 1642, 4704, 1924, 11336, 315, 23331, 3294, 1865, 543, 3932, 2043, 5124, 14, 8410, 9442, 652, 4704, 282, 3962, 1900, 1865, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 21320, 6371, 1581, 334, 20959, 761, 305, 5515, 6371, 1581, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 7268, 63, 6737, 5468, 199, 199, 318, 6516, 4761, 8, 1715, 12, 6137, 12, 11336, 12, 10140, 304, 523, 327, 340, 1006, 5124, 787, 4224, 12, 781, 883, 1900, 652, 12, 4257, 781, 862, 370, 1900, 314, 523, 327, 5936, 14, 523, 327, 961, 365, 440, 15258, 13, 21314, 557, 1618, 14, 523, 367, 2657, 315, 10140, 59, 1715, 2189, 272, 340, 2657, 440, 315, 6137, 26, 489, 6516, 4761, 8, 2601, 12, 6137, 12, 11336, 12, 10140, 9, 523, 870, 2199, 523, 6137, 14, 740, 8, 1715, 9, 199, 199, 318, 6077, 24277, 8, 14458, 63, 493, 304, 523, 327, 2900, 11336, 12, 3932, 824, 4148, 436, 3792, 14, 523, 11336, 275, 1211, 342, 819, 327, 437, 769, 402, 5124, 4568, 543, 282, 2199, 14, 523, 5124, 275, 1211, 342, 819, 327, 18528, 8455, 626, 4450, 314, 428, 44, 46, 1475, 14, 523, 327, 710, 1642, 1004, 402, 282, 2199, 5492, 14, 523, 5386, 63, 1715, 275, 295, 14, 2014, 8, 82, 4289, 4761, 60, 13076, 24, 6265, 25, 2089, 34, 24, 13, 24, 34, 20, 33, 13, 845, 36, 16, 13, 24, 36, 845, 13, 383, 33, 16, 35, 3328, 6265, 25, 2260, 7, 2490, 519, 936, 3212, 9, 275, 7340, 2795, 4186, 7340, 2795, 4186, 7340, 2795, 2924, 9988, 523, 327, 710, 2061, 1004, 402, 282, 2199, 5492, 14, 523, 1284, 63, 1715, 275, 295, 14, 2014, 9097, 3005, 4761, 9988, 523, 327, 710, 1642, 1004, 402, 282, 5936, 769, 14, 523, 5386, 63, 2601, 275, 295, 14, 2014, 8, 489, 519, 7, 4761, 8660, 24805, 4761, 11927, 31736, 275, 2963, 4761, 9988, 523, 327, 710, 2061, 1004, 402, 282, 5936, 769, 14, 523, 1284, 63, 2601, 275, 295, 14, 2014, 360, 3005, 4761, 8660, 9988, 523, 327, 437, 1004, 13660, 282, 5936, 14, 523, 2657, 63, 604, 275, 295, 14, 2014, 360, 627, 2561, 2795, 1552, 275, 11459, 2795, 1552, 9988, 819, 315, 63, 5846, 275, 756, 523, 8744, 275, 1551, 8, 14458, 63, 493, 9, 523, 367, 1004, 315, 8744, 26, 272, 2058, 275, 5386, 63, 1715, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 327, 30802, 370, 2813, 284, 15140, 2952, 314, 3915, 365, 4634, 3365, 14, 489, 340, 2058, 14, 923, 8, 17, 680, 1623, 360, 530, 85, 358, 1137, 446, 17, 26, 267, 1980, 489, 327, 2136, 2813, 2668, 6179, 2, 687, 314, 1561, 2952, 652, 22577, 370, 3915, 3062, 14, 489, 1453, 63, 1715, 275, 2058, 14, 923, 8, 17, 680, 1814, 6412, 6179, 297, 4074, 489, 11336, 59, 1818, 63, 1715, 61, 275, 359, 2604, 14, 923, 8, 18, 680, 1814, 6412, 6179, 297, 9929, 3521, 2058, 14, 923, 8, 19, 395, 3521, 2058, 14, 923, 8, 18, 1874, 489, 5124, 59, 1818, 63, 1715, 61, 275, 942, 489, 1980, 339, 2058, 275, 1284, 63, 1715, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 1453, 63, 1715, 275, 488, 489, 1980, 339, 2058, 275, 5386, 63, 2601, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 315, 63, 5846, 275, 715, 489, 1980, 339, 2058, 275, 1284, 63, 2601, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 315, 63, 5846, 275, 756, 489, 1980, 339, 2058, 275, 2657, 63, 604, 14, 1733, 8, 604, 9, 272, 340, 2058, 436, 315, 63, 5846, 436, 1453, 63, 1715, 26, 489, 5124, 59, 1818, 63, 1715, 1055, 740, 8, 2604, 14, 923, 8, 17, 430, 489, 1980, 819, 327, 7743, 1006, 5124, 824, 4148, 370, 536, 3140, 14, 523, 367, 2199, 315, 5124, 26, 272, 327, 2104, 1924, 5124, 315, 642, 2199, 272, 892, 63, 2601, 63, 1144, 275, 942, 272, 367, 2657, 315, 5124, 59, 1715, 2189, 489, 327, 12077, 367, 314, 2199, 536, 4877, 642, 824, 2297, 489, 367, 2199, 63, 815, 315, 11336, 26, 267, 340, 11336, 59, 1715, 63, 815, 1527, 17, 61, 508, 2657, 26, 881, 892, 63, 2601, 63, 1144, 14, 740, 8, 1715, 63, 815, 9, 272, 5124, 59, 1715, 61, 275, 3355, 8, 1222, 63, 2601, 63, 1144, 9, 819, 372, 334, 6776, 12, 5124, 9, 199, 199, 318, 9101, 11927, 8, 6776, 12, 10140, 304, 523, 870, 298, 1444, 12797, 2, 523, 870, 298, 11927, 367, 1006, 11336, 2, 523, 870, 298, 1444, 12797, 2, 523, 870, 4320, 15530, 1553, 2, 819, 367, 334, 1715, 12, 2657, 63, 513, 9, 315, 3355, 8, 5846, 14, 1744, 5109, 272, 870, 298, 4761, 520, 450, 83, 2, 450, 2199, 272, 870, 298, 2042, 520, 450, 83, 2, 450, 11336, 59, 1715, 1527, 16, 61, 272, 340, 2657, 63, 513, 26, 489, 367, 2657, 315, 2657, 63, 513, 26, 267, 870, 298, 221, 446, 450, 83, 2, 450, 2657, 272, 870, 3087, 819, 870, 4320, 15530, 1553, 2, 199, 199, 318, 9101, 3425, 4738, 8, 6776, 12, 10140, 304, 523, 870, 298, 1444, 12797, 2, 523, 870, 298, 3425, 1865, 14960, 298, 523, 870, 298, 1444, 12797, 2, 523, 870, 4320, 15530, 1553, 2, 819, 6137, 275, 942, 523, 367, 334, 1715, 12, 20795, 315, 3355, 8, 5846, 14, 1744, 5109, 272, 340, 2199, 440, 315, 6137, 26, 489, 6516, 4761, 8, 1715, 12, 6137, 12, 11336, 12, 10140, 9, 819, 870, 4320, 15530, 1553, 2, 199, 199, 318, 9101, 9454, 23657, 8, 6776, 304, 819, 367, 2199, 315, 11336, 26, 272, 870, 298, 1444, 9858, 2, 272, 870, 298, 1444, 9858, 2, 272, 870, 2199, 272, 870, 2199, 272, 870, 2199, 272 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 6029, 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, 26113, 314, 2556, 315, 282, 5340, 78, 570, 315, 282, 3915, 461, 4340, 14, 8410, 2779, 1642, 4704, 1924, 11336, 315, 23331, 3294, 1865, 543, 3932, 2043, 5124, 14, 8410, 9442, 652, 4704, 282, 3962, 1900, 1865, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 21320, 6371, 1581, 334, 20959, 761, 305, 5515, 6371, 1581, 3171, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 7268, 63, 6737, 5468, 199, 199, 318, 6516, 4761, 8, 1715, 12, 6137, 12, 11336, 12, 10140, 304, 523, 327, 340, 1006, 5124, 787, 4224, 12, 781, 883, 1900, 652, 12, 4257, 781, 862, 370, 1900, 314, 523, 327, 5936, 14, 523, 327, 961, 365, 440, 15258, 13, 21314, 557, 1618, 14, 523, 367, 2657, 315, 10140, 59, 1715, 2189, 272, 340, 2657, 440, 315, 6137, 26, 489, 6516, 4761, 8, 2601, 12, 6137, 12, 11336, 12, 10140, 9, 523, 870, 2199, 523, 6137, 14, 740, 8, 1715, 9, 199, 199, 318, 6077, 24277, 8, 14458, 63, 493, 304, 523, 327, 2900, 11336, 12, 3932, 824, 4148, 436, 3792, 14, 523, 11336, 275, 1211, 342, 819, 327, 437, 769, 402, 5124, 4568, 543, 282, 2199, 14, 523, 5124, 275, 1211, 342, 819, 327, 18528, 8455, 626, 4450, 314, 428, 44, 46, 1475, 14, 523, 327, 710, 1642, 1004, 402, 282, 2199, 5492, 14, 523, 5386, 63, 1715, 275, 295, 14, 2014, 8, 82, 4289, 4761, 60, 13076, 24, 6265, 25, 2089, 34, 24, 13, 24, 34, 20, 33, 13, 845, 36, 16, 13, 24, 36, 845, 13, 383, 33, 16, 35, 3328, 6265, 25, 2260, 7, 2490, 519, 936, 3212, 9, 275, 7340, 2795, 4186, 7340, 2795, 4186, 7340, 2795, 2924, 9988, 523, 327, 710, 2061, 1004, 402, 282, 2199, 5492, 14, 523, 1284, 63, 1715, 275, 295, 14, 2014, 9097, 3005, 4761, 9988, 523, 327, 710, 1642, 1004, 402, 282, 5936, 769, 14, 523, 5386, 63, 2601, 275, 295, 14, 2014, 8, 489, 519, 7, 4761, 8660, 24805, 4761, 11927, 31736, 275, 2963, 4761, 9988, 523, 327, 710, 2061, 1004, 402, 282, 5936, 769, 14, 523, 1284, 63, 2601, 275, 295, 14, 2014, 360, 3005, 4761, 8660, 9988, 523, 327, 437, 1004, 13660, 282, 5936, 14, 523, 2657, 63, 604, 275, 295, 14, 2014, 360, 627, 2561, 2795, 1552, 275, 11459, 2795, 1552, 9988, 819, 315, 63, 5846, 275, 756, 523, 8744, 275, 1551, 8, 14458, 63, 493, 9, 523, 367, 1004, 315, 8744, 26, 272, 2058, 275, 5386, 63, 1715, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 327, 30802, 370, 2813, 284, 15140, 2952, 314, 3915, 365, 4634, 3365, 14, 489, 340, 2058, 14, 923, 8, 17, 680, 1623, 360, 530, 85, 358, 1137, 446, 17, 26, 267, 1980, 489, 327, 2136, 2813, 2668, 6179, 2, 687, 314, 1561, 2952, 652, 22577, 370, 3915, 3062, 14, 489, 1453, 63, 1715, 275, 2058, 14, 923, 8, 17, 680, 1814, 6412, 6179, 297, 4074, 489, 11336, 59, 1818, 63, 1715, 61, 275, 359, 2604, 14, 923, 8, 18, 680, 1814, 6412, 6179, 297, 9929, 3521, 2058, 14, 923, 8, 19, 395, 3521, 2058, 14, 923, 8, 18, 1874, 489, 5124, 59, 1818, 63, 1715, 61, 275, 942, 489, 1980, 339, 2058, 275, 1284, 63, 1715, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 1453, 63, 1715, 275, 488, 489, 1980, 339, 2058, 275, 5386, 63, 2601, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 315, 63, 5846, 275, 715, 489, 1980, 339, 2058, 275, 1284, 63, 2601, 14, 1733, 8, 604, 9, 272, 340, 2058, 26, 489, 315, 63, 5846, 275, 756, 489, 1980, 339, 2058, 275, 2657, 63, 604, 14, 1733, 8, 604, 9, 272, 340, 2058, 436, 315, 63, 5846, 436, 1453, 63, 1715, 26, 489, 5124, 59, 1818, 63, 1715, 1055, 740, 8, 2604, 14, 923, 8, 17, 430, 489, 1980, 819, 327, 7743, 1006, 5124, 824, 4148, 370, 536, 3140, 14, 523, 367, 2199, 315, 5124, 26, 272, 327, 2104, 1924, 5124, 315, 642, 2199, 272, 892, 63, 2601, 63, 1144, 275, 942, 272, 367, 2657, 315, 5124, 59, 1715, 2189, 489, 327, 12077, 367, 314, 2199, 536, 4877, 642, 824, 2297, 489, 367, 2199, 63, 815, 315, 11336, 26, 267, 340, 11336, 59, 1715, 63, 815, 1527, 17, 61, 508, 2657, 26, 881, 892, 63, 2601, 63, 1144, 14, 740, 8, 1715, 63, 815, 9, 272, 5124, 59, 1715, 61, 275, 3355, 8, 1222, 63, 2601, 63, 1144, 9, 819, 372, 334, 6776, 12, 5124, 9, 199, 199, 318, 9101, 11927, 8, 6776, 12, 10140, 304, 523, 870, 298, 1444, 12797, 2, 523, 870, 298, 11927, 367, 1006, 11336, 2, 523, 870, 298, 1444, 12797, 2, 523, 870, 4320, 15530, 1553, 2, 819, 367, 334, 1715, 12, 2657, 63, 513, 9, 315, 3355, 8, 5846, 14, 1744, 5109, 272, 870, 298, 4761, 520, 450, 83, 2, 450, 2199, 272, 870, 298, 2042, 520, 450, 83, 2, 450, 11336, 59, 1715, 1527, 16, 61, 272, 340, 2657, 63, 513, 26, 489, 367, 2657, 315, 2657, 63, 513, 26, 267, 870, 298, 221, 446, 450, 83, 2, 450, 2657, 272, 870, 3087, 819, 870, 4320, 15530, 1553, 2, 199, 199, 318, 9101, 3425, 4738, 8, 6776, 12, 10140, 304, 523, 870, 298, 1444, 12797, 2, 523, 870, 298, 3425, 1865, 14960, 298, 523, 870, 298, 1444, 12797, 2, 523, 870, 4320, 15530, 1553, 2, 819, 6137, 275, 942, 523, 367, 334, 1715, 12, 20795, 315, 3355, 8, 5846, 14, 1744, 5109, 272, 340, 2199, 440, 315, 6137, 26, 489, 6516, 4761, 8, 1715, 12, 6137, 12, 11336, 12, 10140, 9, 819, 870, 4320, 15530, 1553, 2, 199, 199, 318, 9101, 9454, 23657, 8, 6776, 304, 819, 367, 2199, 315, 11336, 26, 272, 870, 298, 1444, 9858, 2, 272, 870, 298, 1444, 9858, 2, 272, 870, 2199, 272, 870, 2199, 272, 870, 2199, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
ehazon/chrome-app-samples
samples/push-guestbook/guestbook-srv/third_party/apiclient/mimeparse.py
189
6486
# Copyright (C) 2007 Joe Gregorio # # Licensed under the MIT License """MIME-Type Parser This module provides basic functions for handling mime-types. It can handle matching mime-types against a list of media-ranges. See section 14.1 of the HTTP specification [RFC 2616] for a complete explanation. http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1 Contents: - parse_mime_type(): Parses a mime-type into its component parts. - parse_media_range(): Media-ranges are mime-types with wild-cards and a 'q' quality parameter. - quality(): Determines the quality ('q') of a mime-type when compared against a list of media-ranges. - quality_parsed(): Just like quality() except the second parameter must be pre-parsed. - best_match(): Choose the mime-type with the highest quality ('q') from a list of candidates. """ __version__ = '0.1.3' __author__ = 'Joe Gregorio' __email__ = 'joe@bitworking.org' __license__ = 'MIT License' __credits__ = '' def parse_mime_type(mime_type): """Parses a mime-type into its component parts. Carves up a mime-type and returns a tuple of the (type, subtype, params) where 'params' is a dictionary of all the parameters for the media range. For example, the media range 'application/xhtml;q=0.5' would get parsed into: ('application', 'xhtml', {'q', '0.5'}) """ parts = mime_type.split(';') params = dict([tuple([s.strip() for s in param.split('=', 1)])\ for param in parts[1:] ]) full_type = parts[0].strip() # Java URLConnection class sends an Accept header that includes a # single '*'. Turn it into a legal wildcard. if full_type == '*': full_type = '*/*' (type, subtype) = full_type.split('/') return (type.strip(), subtype.strip(), params) def parse_media_range(range): """Parse a media-range into its component parts. Carves up a media range and returns a tuple of the (type, subtype, params) where 'params' is a dictionary of all the parameters for the media range. For example, the media range 'application/*;q=0.5' would get parsed into: ('application', '*', {'q', '0.5'}) In addition this function also guarantees that there is a value for 'q' in the params dictionary, filling it in with a proper default if necessary. """ (type, subtype, params) = parse_mime_type(range) if not params.has_key('q') or not params['q'] or \ not float(params['q']) or float(params['q']) > 1\ or float(params['q']) < 0: params['q'] = '1' return (type, subtype, params) def fitness_and_quality_parsed(mime_type, parsed_ranges): """Find the best match for a mime-type amongst parsed media-ranges. Find the best match for a given mime-type against a list of media_ranges that have already been parsed by parse_media_range(). Returns a tuple of the fitness value and the value of the 'q' quality parameter of the best match, or (-1, 0) if no match was found. Just as for quality_parsed(), 'parsed_ranges' must be a list of parsed media ranges. """ best_fitness = -1 best_fit_q = 0 (target_type, target_subtype, target_params) =\ parse_media_range(mime_type) for (type, subtype, params) in parsed_ranges: type_match = (type == target_type or\ type == '*' or\ target_type == '*') subtype_match = (subtype == target_subtype or\ subtype == '*' or\ target_subtype == '*') if type_match and subtype_match: param_matches = reduce(lambda x, y: x + y, [1 for (key, value) in \ target_params.iteritems() if key != 'q' and \ params.has_key(key) and value == params[key]], 0) fitness = (type == target_type) and 100 or 0 fitness += (subtype == target_subtype) and 10 or 0 fitness += param_matches if fitness > best_fitness: best_fitness = fitness best_fit_q = params['q'] return best_fitness, float(best_fit_q) def quality_parsed(mime_type, parsed_ranges): """Find the best match for a mime-type amongst parsed media-ranges. Find the best match for a given mime-type against a list of media_ranges that have already been parsed by parse_media_range(). Returns the 'q' quality parameter of the best match, 0 if no match was found. This function bahaves the same as quality() except that 'parsed_ranges' must be a list of parsed media ranges. """ return fitness_and_quality_parsed(mime_type, parsed_ranges)[1] def quality(mime_type, ranges): """Return the quality ('q') of a mime-type against a list of media-ranges. Returns the quality 'q' of a mime-type when compared against the media-ranges in ranges. For example: >>> quality('text/html','text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5') 0.7 """ parsed_ranges = [parse_media_range(r) for r in ranges.split(',')] return quality_parsed(mime_type, parsed_ranges) def best_match(supported, header): """Return mime-type with the highest quality ('q') from list of candidates. Takes a list of supported mime-types and finds the best match for all the media-ranges listed in header. The value of header must be a string that conforms to the format of the HTTP Accept: header. The value of 'supported' is a list of mime-types. The list of supported mime-types should be sorted in order of increasing desirability, in case of a situation where there is a tie. >>> best_match(['application/xbel+xml', 'text/xml'], 'text/*;q=0.5,*/*; q=0.1') 'text/xml' """ split_header = _filter_blank(header.split(',')) parsed_header = [parse_media_range(r) for r in split_header] weighted_matches = [] pos = 0 for mime_type in supported: weighted_matches.append((fitness_and_quality_parsed(mime_type, parsed_header), pos, mime_type)) pos += 1 weighted_matches.sort() return weighted_matches[-1][0][1] and weighted_matches[-1][2] or '' def _filter_blank(i): for s in i: if s.strip(): yield s
apache-2.0
[ 3, 1898, 334, 35, 9, 10219, 7135, 69, 29096, 269, 2308, 199, 3, 199, 3, 3909, 1334, 314, 10697, 844, 199, 199, 624, 17057, 13, 804, 10191, 199, 199, 2765, 859, 6571, 5678, 3423, 367, 7252, 6660, 13, 1313, 14, 2779, 883, 2429, 199, 9467, 6660, 13, 1313, 6169, 282, 769, 402, 5898, 13, 8404, 14, 1666, 3420, 4329, 14, 17, 402, 314, 199, 2856, 8929, 359, 14468, 7875, 975, 61, 367, 282, 4890, 17531, 14, 8410, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 13, 3321, 1079, 14, 1360, 3, 3321, 1079, 14, 17, 199, 199, 11383, 26, 199, 446, 2198, 63, 7626, 63, 466, 837, 257, 29968, 282, 6660, 13, 466, 1901, 2399, 3931, 4184, 14, 199, 446, 2198, 63, 4603, 63, 1842, 837, 12300, 13, 8404, 787, 6660, 13, 1313, 543, 336, 668, 13, 13761, 436, 282, 283, 81, 7, 2079, 11030, 2725, 14, 199, 446, 11030, 837, 3698, 22391, 314, 11030, 661, 81, 358, 402, 282, 6660, 13, 466, 1380, 2079, 13524, 6169, 282, 769, 402, 5898, 13, 8404, 14, 199, 446, 11030, 63, 6751, 837, 259, 13870, 2839, 11030, 342, 871, 314, 3499, 2725, 1471, 506, 2079, 876, 13, 6751, 14, 199, 446, 5526, 63, 1431, 837, 263, 29826, 314, 6660, 13, 466, 543, 314, 15356, 11030, 661, 81, 358, 2079, 687, 282, 769, 402, 15101, 14, 199, 624, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 14, 19, 7, 199, 363, 2502, 363, 275, 283, 5691, 69, 29096, 269, 2308, 7, 199, 363, 2123, 363, 275, 283, 20241, 32, 2075, 9818, 14, 1308, 7, 199, 363, 1682, 363, 275, 283, 13965, 844, 7, 199, 363, 22461, 363, 275, 2125, 421, 199, 318, 2198, 63, 7626, 63, 466, 8, 7626, 63, 466, 304, 272, 408, 23400, 282, 6660, 13, 466, 1901, 2399, 3931, 4184, 14, 339, 14243, 2310, 1536, 282, 6660, 13, 466, 436, 2529, 282, 2008, 402, 314, 334, 466, 12, 15686, 12, 1862, 9, 272, 2382, 283, 1162, 7, 365, 282, 2600, 402, 1006, 314, 2633, 367, 314, 5898, 1425, 14, 272, 2104, 2893, 12, 314, 5898, 1425, 283, 3578, 15, 12909, 27, 81, 29, 16, 14, 21, 7, 3955, 664, 4565, 272, 1901, 26, 10817, 661, 3578, 297, 283, 12909, 297, 791, 81, 297, 283, 16, 14, 21, 3071, 2126, 408, 272, 4184, 275, 6660, 63, 466, 14, 1294, 26468, 272, 1862, 275, 1211, 779, 2960, 779, 83, 14, 1913, 342, 367, 308, 315, 1215, 14, 1294, 25283, 413, 3948, 60, 288, 367, 1215, 315, 4184, 59, 17, 2938, 2116, 4794, 272, 2615, 63, 466, 275, 4184, 59, 16, 1055, 1913, 342, 272, 327, 9586, 2851, 3225, 1021, 16178, 376, 15506, 1406, 626, 6952, 282, 272, 327, 2849, 6438, 1370, 16147, 652, 1901, 282, 18393, 16792, 14, 272, 340, 2615, 63, 466, 508, 22969, 267, 2615, 63, 466, 275, 6438, 6331, 7, 272, 334, 466, 12, 15686, 9, 275, 2615, 63, 466, 14, 1294, 7825, 339, 372, 334, 466, 14, 1913, 1062, 15686, 14, 1913, 1062, 1862, 9, 421, 199, 318, 2198, 63, 4603, 63, 1842, 8, 1842, 304, 272, 408, 4003, 282, 5898, 13, 1842, 1901, 2399, 3931, 4184, 14, 339, 14243, 2310, 1536, 282, 5898, 1425, 436, 2529, 282, 2008, 402, 314, 334, 466, 12, 15686, 12, 272, 1862, 9, 2382, 283, 1162, 7, 365, 282, 2600, 402, 1006, 314, 2633, 367, 314, 5898, 272, 1425, 14, 221, 2104, 2893, 12, 314, 5898, 1425, 283, 3578, 6331, 27, 81, 29, 16, 14, 21, 7, 3955, 664, 4565, 272, 1901, 26, 10817, 661, 3578, 297, 24999, 791, 81, 297, 283, 16, 14, 21, 3071, 339, 1010, 10234, 642, 805, 2597, 12072, 397, 626, 2337, 365, 282, 574, 367, 283, 81, 7, 272, 315, 314, 1862, 2600, 12, 32499, 652, 315, 543, 282, 5576, 849, 340, 272, 5784, 14, 272, 408, 272, 334, 466, 12, 15686, 12, 1862, 9, 275, 2198, 63, 7626, 63, 466, 8, 1842, 9, 272, 340, 440, 1862, 14, 1989, 63, 498, 360, 81, 358, 503, 440, 1862, 459, 81, 418, 503, 971, 288, 440, 2069, 8, 1162, 459, 81, 1105, 503, 2069, 8, 1162, 459, 81, 1105, 690, 413, 60, 288, 503, 2069, 8, 1162, 459, 81, 1105, 665, 378, 26, 267, 1862, 459, 81, 418, 275, 283, 17, 7, 339, 372, 334, 466, 12, 15686, 12, 1862, 9, 421, 199, 318, 5542, 4171, 63, 460, 63, 9161, 63, 6751, 8, 7626, 63, 466, 12, 4565, 63, 8404, 304, 272, 408, 6591, 314, 5526, 1336, 367, 282, 6660, 13, 466, 16885, 270, 4565, 5898, 13, 8404, 14, 339, 6668, 314, 5526, 1336, 367, 282, 1627, 6660, 13, 466, 6169, 282, 769, 402, 5898, 63, 8404, 272, 626, 1172, 2575, 2757, 4565, 701, 2198, 63, 4603, 63, 1842, 1252, 1803, 282, 2008, 402, 272, 314, 5542, 4171, 574, 436, 314, 574, 402, 314, 283, 81, 7, 11030, 2725, 402, 314, 5526, 272, 1336, 12, 503, 5868, 17, 12, 378, 9, 340, 949, 1336, 1990, 1911, 14, 13870, 465, 367, 11030, 63, 6751, 1062, 272, 283, 6751, 63, 8404, 7, 1471, 506, 282, 769, 402, 4565, 5898, 12271, 14, 272, 408, 272, 5526, 63, 3269, 4171, 275, 446, 17, 272, 5526, 63, 3269, 63, 81, 275, 378, 272, 334, 1375, 63, 466, 12, 1347, 63, 10512, 12, 1347, 63, 1162, 9, 26447, 288, 2198, 63, 4603, 63, 1842, 8, 7626, 63, 466, 9, 272, 367, 334, 466, 12, 15686, 12, 1862, 9, 315, 4565, 63, 8404, 26, 267, 730, 63, 1431, 275, 334, 466, 508, 1347, 63, 466, 503, 60, 1993, 730, 508, 13626, 503, 60, 1993, 1347, 63, 466, 508, 6438, 358, 267, 15686, 63, 1431, 275, 334, 10512, 508, 1347, 63, 10512, 503, 60, 586, 15686, 508, 13626, 503, 60, 586, 1347, 63, 10512, 508, 6438, 358, 267, 340, 730, 63, 1431, 436, 15686, 63, 1431, 26, 288, 1215, 63, 6742, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 435, 612, 12, 359, 17, 367, 334, 498, 12, 574, 9, 315, 971, 490, 1347, 63, 1162, 14, 4611, 342, 340, 790, 1137, 283, 81, 7, 436, 971, 490, 1862, 14, 1989, 63, 498, 8, 498, 9, 436, 574, 508 ]
[ 1898, 334, 35, 9, 10219, 7135, 69, 29096, 269, 2308, 199, 3, 199, 3, 3909, 1334, 314, 10697, 844, 199, 199, 624, 17057, 13, 804, 10191, 199, 199, 2765, 859, 6571, 5678, 3423, 367, 7252, 6660, 13, 1313, 14, 2779, 883, 2429, 199, 9467, 6660, 13, 1313, 6169, 282, 769, 402, 5898, 13, 8404, 14, 1666, 3420, 4329, 14, 17, 402, 314, 199, 2856, 8929, 359, 14468, 7875, 975, 61, 367, 282, 4890, 17531, 14, 8410, 1455, 921, 1544, 14, 87, 19, 14, 1308, 15, 8548, 4574, 15, 8973, 25807, 15, 8973, 25807, 13, 3321, 1079, 14, 1360, 3, 3321, 1079, 14, 17, 199, 199, 11383, 26, 199, 446, 2198, 63, 7626, 63, 466, 837, 257, 29968, 282, 6660, 13, 466, 1901, 2399, 3931, 4184, 14, 199, 446, 2198, 63, 4603, 63, 1842, 837, 12300, 13, 8404, 787, 6660, 13, 1313, 543, 336, 668, 13, 13761, 436, 282, 283, 81, 7, 2079, 11030, 2725, 14, 199, 446, 11030, 837, 3698, 22391, 314, 11030, 661, 81, 358, 402, 282, 6660, 13, 466, 1380, 2079, 13524, 6169, 282, 769, 402, 5898, 13, 8404, 14, 199, 446, 11030, 63, 6751, 837, 259, 13870, 2839, 11030, 342, 871, 314, 3499, 2725, 1471, 506, 2079, 876, 13, 6751, 14, 199, 446, 5526, 63, 1431, 837, 263, 29826, 314, 6660, 13, 466, 543, 314, 15356, 11030, 661, 81, 358, 2079, 687, 282, 769, 402, 15101, 14, 199, 624, 199, 199, 363, 1023, 363, 275, 283, 16, 14, 17, 14, 19, 7, 199, 363, 2502, 363, 275, 283, 5691, 69, 29096, 269, 2308, 7, 199, 363, 2123, 363, 275, 283, 20241, 32, 2075, 9818, 14, 1308, 7, 199, 363, 1682, 363, 275, 283, 13965, 844, 7, 199, 363, 22461, 363, 275, 2125, 421, 199, 318, 2198, 63, 7626, 63, 466, 8, 7626, 63, 466, 304, 272, 408, 23400, 282, 6660, 13, 466, 1901, 2399, 3931, 4184, 14, 339, 14243, 2310, 1536, 282, 6660, 13, 466, 436, 2529, 282, 2008, 402, 314, 334, 466, 12, 15686, 12, 1862, 9, 272, 2382, 283, 1162, 7, 365, 282, 2600, 402, 1006, 314, 2633, 367, 314, 5898, 1425, 14, 272, 2104, 2893, 12, 314, 5898, 1425, 283, 3578, 15, 12909, 27, 81, 29, 16, 14, 21, 7, 3955, 664, 4565, 272, 1901, 26, 10817, 661, 3578, 297, 283, 12909, 297, 791, 81, 297, 283, 16, 14, 21, 3071, 2126, 408, 272, 4184, 275, 6660, 63, 466, 14, 1294, 26468, 272, 1862, 275, 1211, 779, 2960, 779, 83, 14, 1913, 342, 367, 308, 315, 1215, 14, 1294, 25283, 413, 3948, 60, 288, 367, 1215, 315, 4184, 59, 17, 2938, 2116, 4794, 272, 2615, 63, 466, 275, 4184, 59, 16, 1055, 1913, 342, 272, 327, 9586, 2851, 3225, 1021, 16178, 376, 15506, 1406, 626, 6952, 282, 272, 327, 2849, 6438, 1370, 16147, 652, 1901, 282, 18393, 16792, 14, 272, 340, 2615, 63, 466, 508, 22969, 267, 2615, 63, 466, 275, 6438, 6331, 7, 272, 334, 466, 12, 15686, 9, 275, 2615, 63, 466, 14, 1294, 7825, 339, 372, 334, 466, 14, 1913, 1062, 15686, 14, 1913, 1062, 1862, 9, 421, 199, 318, 2198, 63, 4603, 63, 1842, 8, 1842, 304, 272, 408, 4003, 282, 5898, 13, 1842, 1901, 2399, 3931, 4184, 14, 339, 14243, 2310, 1536, 282, 5898, 1425, 436, 2529, 282, 2008, 402, 314, 334, 466, 12, 15686, 12, 272, 1862, 9, 2382, 283, 1162, 7, 365, 282, 2600, 402, 1006, 314, 2633, 367, 314, 5898, 272, 1425, 14, 221, 2104, 2893, 12, 314, 5898, 1425, 283, 3578, 6331, 27, 81, 29, 16, 14, 21, 7, 3955, 664, 4565, 272, 1901, 26, 10817, 661, 3578, 297, 24999, 791, 81, 297, 283, 16, 14, 21, 3071, 339, 1010, 10234, 642, 805, 2597, 12072, 397, 626, 2337, 365, 282, 574, 367, 283, 81, 7, 272, 315, 314, 1862, 2600, 12, 32499, 652, 315, 543, 282, 5576, 849, 340, 272, 5784, 14, 272, 408, 272, 334, 466, 12, 15686, 12, 1862, 9, 275, 2198, 63, 7626, 63, 466, 8, 1842, 9, 272, 340, 440, 1862, 14, 1989, 63, 498, 360, 81, 358, 503, 440, 1862, 459, 81, 418, 503, 971, 288, 440, 2069, 8, 1162, 459, 81, 1105, 503, 2069, 8, 1162, 459, 81, 1105, 690, 413, 60, 288, 503, 2069, 8, 1162, 459, 81, 1105, 665, 378, 26, 267, 1862, 459, 81, 418, 275, 283, 17, 7, 339, 372, 334, 466, 12, 15686, 12, 1862, 9, 421, 199, 318, 5542, 4171, 63, 460, 63, 9161, 63, 6751, 8, 7626, 63, 466, 12, 4565, 63, 8404, 304, 272, 408, 6591, 314, 5526, 1336, 367, 282, 6660, 13, 466, 16885, 270, 4565, 5898, 13, 8404, 14, 339, 6668, 314, 5526, 1336, 367, 282, 1627, 6660, 13, 466, 6169, 282, 769, 402, 5898, 63, 8404, 272, 626, 1172, 2575, 2757, 4565, 701, 2198, 63, 4603, 63, 1842, 1252, 1803, 282, 2008, 402, 272, 314, 5542, 4171, 574, 436, 314, 574, 402, 314, 283, 81, 7, 11030, 2725, 402, 314, 5526, 272, 1336, 12, 503, 5868, 17, 12, 378, 9, 340, 949, 1336, 1990, 1911, 14, 13870, 465, 367, 11030, 63, 6751, 1062, 272, 283, 6751, 63, 8404, 7, 1471, 506, 282, 769, 402, 4565, 5898, 12271, 14, 272, 408, 272, 5526, 63, 3269, 4171, 275, 446, 17, 272, 5526, 63, 3269, 63, 81, 275, 378, 272, 334, 1375, 63, 466, 12, 1347, 63, 10512, 12, 1347, 63, 1162, 9, 26447, 288, 2198, 63, 4603, 63, 1842, 8, 7626, 63, 466, 9, 272, 367, 334, 466, 12, 15686, 12, 1862, 9, 315, 4565, 63, 8404, 26, 267, 730, 63, 1431, 275, 334, 466, 508, 1347, 63, 466, 503, 60, 1993, 730, 508, 13626, 503, 60, 1993, 1347, 63, 466, 508, 6438, 358, 267, 15686, 63, 1431, 275, 334, 10512, 508, 1347, 63, 10512, 503, 60, 586, 15686, 508, 13626, 503, 60, 586, 1347, 63, 10512, 508, 6438, 358, 267, 340, 730, 63, 1431, 436, 15686, 63, 1431, 26, 288, 1215, 63, 6742, 275, 7114, 8, 2734, 671, 12, 612, 26, 671, 435, 612, 12, 359, 17, 367, 334, 498, 12, 574, 9, 315, 971, 490, 1347, 63, 1162, 14, 4611, 342, 340, 790, 1137, 283, 81, 7, 436, 971, 490, 1862, 14, 1989, 63, 498, 8, 498, 9, 436, 574, 508, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Stavitsky/nova
nova/objects/tag.py
11
2321
# 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 nova import db from nova import objects from nova.objects import base from nova.objects import fields @base.NovaObjectRegistry.register class Tag(base.NovaObject): # Version 1.0: Initial version VERSION = '1.0' fields = { 'resource_id': fields.StringField(), 'tag': fields.StringField(), } @staticmethod def _from_db_object(context, tag, db_tag): for key in tag.fields: setattr(tag, key, db_tag[key]) tag.obj_reset_changes() tag._context = context return tag @base.remotable def create(self): db_tag = db.instance_tag_add(self._context, self.resource_id, self.tag) self._from_db_object(self._context, self, db_tag) @base.remotable_classmethod def destroy(cls, context, resource_id, name): db.instance_tag_delete(context, resource_id, name) @base.NovaObjectRegistry.register class TagList(base.ObjectListBase, base.NovaObject): # Version 1.0: Initial version VERSION = '1.0' fields = { 'objects': fields.ListOfObjectsField('Tag'), } child_versions = { '1.0': '1.0', } @base.remotable_classmethod def get_by_resource_id(cls, context, resource_id): db_tags = db.instance_tag_get_by_instance_uuid(context, resource_id) return base.obj_make_list(context, cls(), objects.Tag, db_tags) @base.remotable_classmethod def create(cls, context, resource_id, tags): db_tags = db.instance_tag_set(context, resource_id, tags) return base.obj_make_list(context, cls(), objects.Tag, db_tags) @base.remotable_classmethod def destroy(cls, context, resource_id): db.instance_tag_delete_all(context, resource_id)
apache-2.0
[ 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 5913, 492, 1592, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 1462, 492, 1300, 199, 504, 5913, 14, 1462, 492, 1504, 421, 199, 32, 1095, 14, 19884, 1692, 10899, 14, 2683, 199, 533, 8053, 8, 1095, 14, 19884, 1692, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 1504, 275, 469, 267, 283, 1927, 63, 344, 356, 1504, 14, 14912, 1062, 267, 283, 1450, 356, 1504, 14, 14912, 1062, 267, 789, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 8, 1100, 12, 1947, 12, 1592, 63, 1450, 304, 267, 367, 790, 315, 1947, 14, 955, 26, 288, 5371, 8, 1450, 12, 790, 12, 1592, 63, 1450, 59, 498, 566, 267, 1947, 14, 1113, 63, 3958, 63, 6627, 342, 267, 1947, 423, 1100, 275, 1067, 267, 372, 1947, 339, 768, 1095, 14, 13179, 357, 461, 272, 347, 1218, 8, 277, 304, 267, 1592, 63, 1450, 275, 1592, 14, 842, 63, 1450, 63, 525, 8, 277, 423, 1100, 12, 291, 14, 1927, 63, 344, 12, 291, 14, 1450, 9, 267, 291, 423, 504, 63, 697, 63, 785, 8, 277, 423, 1100, 12, 291, 12, 1592, 63, 1450, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 11972, 8, 1886, 12, 1067, 12, 2073, 63, 344, 12, 536, 304, 267, 1592, 14, 842, 63, 1450, 63, 1807, 8, 1100, 12, 2073, 63, 344, 12, 536, 9, 421, 199, 32, 1095, 14, 19884, 1692, 10899, 14, 2683, 199, 533, 8053, 1296, 8, 1095, 14, 1692, 1296, 1563, 12, 1300, 14, 19884, 1692, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 1504, 275, 469, 267, 283, 1462, 356, 1504, 14, 30210, 11188, 792, 360, 1931, 659, 267, 789, 272, 1982, 63, 6234, 275, 469, 267, 283, 17, 14, 16, 356, 283, 17, 14, 16, 297, 267, 789, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 1927, 63, 344, 8, 1886, 12, 1067, 12, 2073, 63, 344, 304, 267, 1592, 63, 2969, 275, 1592, 14, 842, 63, 1450, 63, 362, 63, 991, 63, 842, 63, 2580, 8, 1100, 12, 2073, 63, 344, 9, 267, 372, 1300, 14, 1113, 63, 1875, 63, 513, 8, 1100, 12, 843, 1062, 2251, 14, 1931, 12, 1592, 63, 2969, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 1218, 8, 1886, 12, 1067, 12, 2073, 63, 344, 12, 3762, 304, 267, 1592, 63, 2969, 275, 1592, 14, 842, 63, 1450, 63, 409, 8, 1100, 12, 2073, 63, 344, 12, 3762, 9, 267, 372, 1300, 14, 1113, 63, 1875, 63, 513, 8, 1100, 12, 843, 1062, 2251, 14, 1931, 12, 1592, 63, 2969, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 11972, 8, 1886, 12, 1067, 12, 2073, 63, 344, 304, 267, 1592, 14, 842, 63, 1450, 63, 1807, 63, 452, 8, 1100, 12, 2073, 63, 344, 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 ]
[ 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, 5913, 492, 1592, 199, 504, 5913, 492, 2251, 199, 504, 5913, 14, 1462, 492, 1300, 199, 504, 5913, 14, 1462, 492, 1504, 421, 199, 32, 1095, 14, 19884, 1692, 10899, 14, 2683, 199, 533, 8053, 8, 1095, 14, 19884, 1692, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 1504, 275, 469, 267, 283, 1927, 63, 344, 356, 1504, 14, 14912, 1062, 267, 283, 1450, 356, 1504, 14, 14912, 1062, 267, 789, 339, 768, 4639, 272, 347, 485, 504, 63, 697, 63, 785, 8, 1100, 12, 1947, 12, 1592, 63, 1450, 304, 267, 367, 790, 315, 1947, 14, 955, 26, 288, 5371, 8, 1450, 12, 790, 12, 1592, 63, 1450, 59, 498, 566, 267, 1947, 14, 1113, 63, 3958, 63, 6627, 342, 267, 1947, 423, 1100, 275, 1067, 267, 372, 1947, 339, 768, 1095, 14, 13179, 357, 461, 272, 347, 1218, 8, 277, 304, 267, 1592, 63, 1450, 275, 1592, 14, 842, 63, 1450, 63, 525, 8, 277, 423, 1100, 12, 291, 14, 1927, 63, 344, 12, 291, 14, 1450, 9, 267, 291, 423, 504, 63, 697, 63, 785, 8, 277, 423, 1100, 12, 291, 12, 1592, 63, 1450, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 11972, 8, 1886, 12, 1067, 12, 2073, 63, 344, 12, 536, 304, 267, 1592, 14, 842, 63, 1450, 63, 1807, 8, 1100, 12, 2073, 63, 344, 12, 536, 9, 421, 199, 32, 1095, 14, 19884, 1692, 10899, 14, 2683, 199, 533, 8053, 1296, 8, 1095, 14, 1692, 1296, 1563, 12, 1300, 14, 19884, 1692, 304, 272, 327, 3394, 413, 14, 16, 26, 6026, 1015, 272, 15945, 275, 283, 17, 14, 16, 7, 339, 1504, 275, 469, 267, 283, 1462, 356, 1504, 14, 30210, 11188, 792, 360, 1931, 659, 267, 789, 272, 1982, 63, 6234, 275, 469, 267, 283, 17, 14, 16, 356, 283, 17, 14, 16, 297, 267, 789, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 664, 63, 991, 63, 1927, 63, 344, 8, 1886, 12, 1067, 12, 2073, 63, 344, 304, 267, 1592, 63, 2969, 275, 1592, 14, 842, 63, 1450, 63, 362, 63, 991, 63, 842, 63, 2580, 8, 1100, 12, 2073, 63, 344, 9, 267, 372, 1300, 14, 1113, 63, 1875, 63, 513, 8, 1100, 12, 843, 1062, 2251, 14, 1931, 12, 1592, 63, 2969, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 1218, 8, 1886, 12, 1067, 12, 2073, 63, 344, 12, 3762, 304, 267, 1592, 63, 2969, 275, 1592, 14, 842, 63, 1450, 63, 409, 8, 1100, 12, 2073, 63, 344, 12, 3762, 9, 267, 372, 1300, 14, 1113, 63, 1875, 63, 513, 8, 1100, 12, 843, 1062, 2251, 14, 1931, 12, 1592, 63, 2969, 9, 339, 768, 1095, 14, 13179, 357, 461, 63, 3744, 272, 347, 11972, 8, 1886, 12, 1067, 12, 2073, 63, 344, 304, 267, 1592, 14, 842, 63, 1450, 63, 1807, 63, 452, 8, 1100, 12, 2073, 63, 344, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
jhuapl-boss/intern
examples/dvid/general_test.py
1
3757
import intern from intern.remote.dvid import DVIDRemote from intern.resource.dvid.resource import DataInstanceResource from intern.resource.dvid.resource import RepositoryResource import numpy as np from PIL import Image import matplotlib.pyplot as plt ########### NOTE ########### # This test requires an accessible DVID instance # DVID Data fetch: dvid = DVIDRemote({"protocol": "http", "host": "localhost:8001",}) DATA_INSTANCE = "ex_EM" ALIAS = "Test_alias" ########### Test Project API ########### ## Create DataInstanceResource and force the creation of a RepositoryResource instance_setup_em = DataInstanceResource( DATA_INSTANCE, None, "uint8blk", ALIAS, "Example channel.", datatype="uint8" ) # Get the channel and create a project instance_actual_repo = dvid.create_project(instance_setup_em) print("Repo UUID:" + instance_actual_repo) # Create an instance within given repo(UUID) instance_setup_anno = DataInstanceResource( DATA_INSTANCE + "_the_second", instance_actual_repo, "uint8blk", ALIAS, "Example channel.", datatype="uint8", ) instance_actual_anno_uuid = dvid.create_project(instance_setup_anno) print("Data Instance UUID: {}".format(instance_actual_anno_uuid)) # Create a dummy repo with the Repository Resource for deletion instance_setup_em_delete = RepositoryResource(None, "Test_for_deletion") instance_actual_em_delete_uuid = dvid.create_project(instance_setup_em_delete) instance_actual_em_delete = dvid.delete_project(instance_setup_em_delete) print("Successfully deleted Repo project: {}".format(instance_actual_em_delete_uuid)) # Delete the data instance of a repo instance_setup_em_delete = DataInstanceResource( DATA_INSTANCE, None, "uint8blk", ALIAS, "Example channel.", datatype="uint8" ) instance_actual_em_delete_uuid = dvid.create_project(instance_setup_em_delete) dvid.delete_project(dvid.get_instance(instance_actual_em_delete_uuid, DATA_INSTANCE)) print( "Successfully deleted data instance project: {}".format( instance_actual_em_delete_uuid ) ) ########### Test Versioning API ########### # Set up a new project with a channel instance_setup_merge = DataInstanceResource( DATA_INSTANCE + "_the_second", None, "uint8blk", "Mege_repo", "Example channel.", datatype="uint8", ) chan_actual_parent1 = dvid.create_project(instance_setup_merge) print("\nParent1 UUID: " + chan_actual_parent1) commit_1 = dvid.commit(chan_actual_parent1, note="Test the commit") branch_1 = dvid.branch(chan_actual_parent1, note="Test the versioning system once") branch_2 = dvid.branch(chan_actual_parent1, note="Test the versioning system twice") print("Created branches {} and {} from Parent1".format(branch_1, branch_2)) ########### Test Metadat API ########### # Set up a new project with a channel print(dvid.get_info(instance_setup_merge)) print(dvid.get_server_info()) print(dvid.get_server_compiled_types()) dvid.server_reload_metadata() ########### Test Voluming API ########### # # Prepare the data img = Image.open("<somedir>/*.png") data_tile = np.asarray(img) print(data_tile.shape) data_tile = np.expand_dims(data_tile, axis=0) data_tile = data_tile.copy(order="C") # Create the project instance_setup_up = DataInstanceResource( DATA_INSTANCE + "_the_second", None, "imagetile", "Upload Test", "Example channel.", datatype="uint8", ) chan_actual_up = dvid.create_project(instance_setup_up) # Create the cutout dvid.create_cutout(instance_setup_up, 0, [0, 454], [0, 480], [0, 1], data_tile) print("Create cutout successful") # Get the cutout got_cutout = dvid.get_cutout(instance_setup_up, 0, [0, 454], [0, 480], [0, 1]) # Check for equality if (got_cutout == data_tile).all(): print("Both tiles equate")
apache-2.0
[ 646, 10757, 199, 504, 10757, 14, 3846, 14, 68, 5017, 492, 577, 5437, 6713, 199, 504, 10757, 14, 1927, 14, 68, 5017, 14, 1927, 492, 3918, 3244, 4031, 199, 504, 10757, 14, 1927, 14, 68, 5017, 14, 1927, 492, 24426, 4031, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 516, 5680, 6944, 21937, 5680, 199, 3, 961, 511, 5074, 376, 17909, 577, 5437, 1256, 199, 199, 3, 577, 5437, 3918, 5267, 26, 199, 68, 5017, 275, 577, 5437, 6713, 6333, 3922, 582, 298, 1014, 401, 298, 1102, 582, 298, 5967, 26, 24, 4587, 401, 1552, 199, 199, 3998, 63, 18235, 275, 298, 476, 63, 2769, 2, 199, 12644, 275, 298, 774, 63, 3620, 2, 199, 199, 516, 5680, 1379, 7290, 3261, 21937, 5680, 199, 309, 2790, 3918, 3244, 4031, 436, 3542, 314, 7143, 402, 282, 24426, 4031, 199, 842, 63, 2758, 63, 5633, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 12, 488, 12, 298, 1635, 24, 14023, 401, 437, 2673, 1179, 12, 298, 9846, 3623, 4765, 16048, 628, 1635, 24, 2, 199, 9, 199, 199, 3, 2372, 314, 3623, 436, 1218, 282, 2199, 199, 842, 63, 6514, 63, 3417, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 9, 199, 1361, 480, 11334, 11134, 5424, 435, 1256, 63, 6514, 63, 3417, 9, 199, 199, 3, 2790, 376, 1256, 4453, 1627, 3831, 8, 8757, 9, 199, 842, 63, 2758, 63, 25264, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 1256, 63, 6514, 63, 3417, 12, 272, 298, 1635, 24, 14023, 401, 272, 437, 2673, 1179, 12, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 199, 842, 63, 6514, 63, 25264, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 25264, 9, 199, 1361, 480, 1451, 10066, 11134, 26, 8352, 908, 8, 842, 63, 6514, 63, 25264, 63, 2580, 430, 199, 199, 3, 2790, 282, 7283, 3831, 543, 314, 24426, 7337, 367, 14068, 199, 842, 63, 2758, 63, 5633, 63, 1807, 275, 24426, 4031, 8, 403, 12, 298, 774, 63, 509, 63, 14281, 531, 199, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 842, 63, 6514, 63, 5633, 63, 1807, 275, 366, 5017, 14, 1807, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 1361, 480, 25001, 5463, 20069, 2199, 26, 8352, 908, 8, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 430, 199, 199, 3, 8496, 314, 666, 1256, 402, 282, 3831, 199, 842, 63, 2758, 63, 5633, 63, 1807, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 12, 488, 12, 298, 1635, 24, 14023, 401, 437, 2673, 1179, 12, 298, 9846, 3623, 4765, 16048, 628, 1635, 24, 2, 199, 9, 199, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 68, 5017, 14, 1807, 63, 1715, 8, 68, 5017, 14, 362, 63, 842, 8, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 12, 7126, 63, 18235, 430, 199, 1361, 8, 272, 298, 25001, 5463, 666, 1256, 2199, 26, 8352, 908, 8, 267, 1256, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 272, 776, 199, 9, 199, 199, 516, 5680, 1379, 3394, 316, 3261, 21937, 5680, 199, 3, 2494, 1536, 282, 892, 2199, 543, 282, 3623, 199, 199, 842, 63, 2758, 63, 5628, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 488, 12, 272, 298, 1635, 24, 14023, 401, 272, 298, 1352, 303, 63, 3417, 401, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 199, 11984, 63, 6514, 63, 1708, 17, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5628, 9, 199, 1361, 4582, 78, 6652, 17, 11134, 26, 298, 435, 15985, 63, 6514, 63, 1708, 17, 9, 199, 3543, 63, 17, 275, 366, 5017, 14, 3543, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 5532, 531, 199, 4694, 63, 17, 275, 366, 5017, 14, 4694, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 1015, 316, 2656, 5403, 531, 199, 199, 4694, 63, 18, 275, 366, 5017, 14, 4694, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 1015, 316, 2656, 13373, 531, 199, 199, 1361, 480, 10502, 17347, 1052, 436, 1052, 687, 16396, 17, 1674, 908, 8, 4694, 63, 17, 12, 5246, 63, 18, 430, 199, 199, 516, 5680, 1379, 10072, 350, 292, 3261, 21937, 5680, 199, 3, 2494, 1536, 282, 892, 2199, 543, 282, 3623, 199, 1361, 8, 68, 5017, 14, 362, 63, 815, 8, 842, 63, 2758, 63, 5628, 430, 199, 1361, 8, 68, 5017, 14, 362, 63, 1000, 63, 815, 1012, 199, 1361, 8, 68, 5017, 14, 362, 63, 1000, 63, 8427, 63, 1313, 1012, 199, 68, 5017, 14, 1000, 63, 9233, 63, 2343, 342, 199, 199, 516, 5680, 1379, 16171, 12848, 3261, 21937, 5680, 199, 3, 199, 199, 3, 17008, 314, 666, 199, 4060, 275, 6047, 14, 1490, 6757, 3972, 694, 12202, 4856, 4524, 531, 199, 576, 63, 7172, 275, 980, 14, 8748, 8, 4060, 9, 199, 1361, 8, 576, 63, 7172, 14, 1392, 9, 199, 576, 63, 7172, 275, 980, 14, 4441, 63, 5380, 8, 576, 63, 7172, 12, 3114, 29, 16, 9, 199, 576, 63, 7172, 275, 666, 63, 7172, 14, 1574, 8, 1648, 628, 35, 531, 199, 199, 3, 2790, 314, 2199, 199, 842, 63, 2758, 63, 384, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 488, 12, 272, 298, 1569, 7172, 401, 272, 298, 10301, 1379, 401, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 11984, 63, 6514, 63, 384, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 384, 9, 199, 199, 3, 2790, 314, 10415, 548, 199, 68, 5017, 14, 981 ]
[ 10757, 199, 504, 10757, 14, 3846, 14, 68, 5017, 492, 577, 5437, 6713, 199, 504, 10757, 14, 1927, 14, 68, 5017, 14, 1927, 492, 3918, 3244, 4031, 199, 504, 10757, 14, 1927, 14, 68, 5017, 14, 1927, 492, 24426, 4031, 199, 646, 2680, 465, 980, 199, 504, 14937, 492, 6047, 199, 646, 8027, 14, 13563, 465, 4488, 199, 199, 516, 5680, 6944, 21937, 5680, 199, 3, 961, 511, 5074, 376, 17909, 577, 5437, 1256, 199, 199, 3, 577, 5437, 3918, 5267, 26, 199, 68, 5017, 275, 577, 5437, 6713, 6333, 3922, 582, 298, 1014, 401, 298, 1102, 582, 298, 5967, 26, 24, 4587, 401, 1552, 199, 199, 3998, 63, 18235, 275, 298, 476, 63, 2769, 2, 199, 12644, 275, 298, 774, 63, 3620, 2, 199, 199, 516, 5680, 1379, 7290, 3261, 21937, 5680, 199, 309, 2790, 3918, 3244, 4031, 436, 3542, 314, 7143, 402, 282, 24426, 4031, 199, 842, 63, 2758, 63, 5633, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 12, 488, 12, 298, 1635, 24, 14023, 401, 437, 2673, 1179, 12, 298, 9846, 3623, 4765, 16048, 628, 1635, 24, 2, 199, 9, 199, 199, 3, 2372, 314, 3623, 436, 1218, 282, 2199, 199, 842, 63, 6514, 63, 3417, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 9, 199, 1361, 480, 11334, 11134, 5424, 435, 1256, 63, 6514, 63, 3417, 9, 199, 199, 3, 2790, 376, 1256, 4453, 1627, 3831, 8, 8757, 9, 199, 842, 63, 2758, 63, 25264, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 1256, 63, 6514, 63, 3417, 12, 272, 298, 1635, 24, 14023, 401, 272, 437, 2673, 1179, 12, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 199, 842, 63, 6514, 63, 25264, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 25264, 9, 199, 1361, 480, 1451, 10066, 11134, 26, 8352, 908, 8, 842, 63, 6514, 63, 25264, 63, 2580, 430, 199, 199, 3, 2790, 282, 7283, 3831, 543, 314, 24426, 7337, 367, 14068, 199, 842, 63, 2758, 63, 5633, 63, 1807, 275, 24426, 4031, 8, 403, 12, 298, 774, 63, 509, 63, 14281, 531, 199, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 842, 63, 6514, 63, 5633, 63, 1807, 275, 366, 5017, 14, 1807, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 1361, 480, 25001, 5463, 20069, 2199, 26, 8352, 908, 8, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 430, 199, 199, 3, 8496, 314, 666, 1256, 402, 282, 3831, 199, 842, 63, 2758, 63, 5633, 63, 1807, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 12, 488, 12, 298, 1635, 24, 14023, 401, 437, 2673, 1179, 12, 298, 9846, 3623, 4765, 16048, 628, 1635, 24, 2, 199, 9, 199, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5633, 63, 1807, 9, 199, 68, 5017, 14, 1807, 63, 1715, 8, 68, 5017, 14, 362, 63, 842, 8, 842, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 12, 7126, 63, 18235, 430, 199, 1361, 8, 272, 298, 25001, 5463, 666, 1256, 2199, 26, 8352, 908, 8, 267, 1256, 63, 6514, 63, 5633, 63, 1807, 63, 2580, 272, 776, 199, 9, 199, 199, 516, 5680, 1379, 3394, 316, 3261, 21937, 5680, 199, 3, 2494, 1536, 282, 892, 2199, 543, 282, 3623, 199, 199, 842, 63, 2758, 63, 5628, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 488, 12, 272, 298, 1635, 24, 14023, 401, 272, 298, 1352, 303, 63, 3417, 401, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 199, 11984, 63, 6514, 63, 1708, 17, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 5628, 9, 199, 1361, 4582, 78, 6652, 17, 11134, 26, 298, 435, 15985, 63, 6514, 63, 1708, 17, 9, 199, 3543, 63, 17, 275, 366, 5017, 14, 3543, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 5532, 531, 199, 4694, 63, 17, 275, 366, 5017, 14, 4694, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 1015, 316, 2656, 5403, 531, 199, 199, 4694, 63, 18, 275, 366, 5017, 14, 4694, 8, 11984, 63, 6514, 63, 1708, 17, 12, 5317, 628, 774, 314, 1015, 316, 2656, 13373, 531, 199, 199, 1361, 480, 10502, 17347, 1052, 436, 1052, 687, 16396, 17, 1674, 908, 8, 4694, 63, 17, 12, 5246, 63, 18, 430, 199, 199, 516, 5680, 1379, 10072, 350, 292, 3261, 21937, 5680, 199, 3, 2494, 1536, 282, 892, 2199, 543, 282, 3623, 199, 1361, 8, 68, 5017, 14, 362, 63, 815, 8, 842, 63, 2758, 63, 5628, 430, 199, 1361, 8, 68, 5017, 14, 362, 63, 1000, 63, 815, 1012, 199, 1361, 8, 68, 5017, 14, 362, 63, 1000, 63, 8427, 63, 1313, 1012, 199, 68, 5017, 14, 1000, 63, 9233, 63, 2343, 342, 199, 199, 516, 5680, 1379, 16171, 12848, 3261, 21937, 5680, 199, 3, 199, 199, 3, 17008, 314, 666, 199, 4060, 275, 6047, 14, 1490, 6757, 3972, 694, 12202, 4856, 4524, 531, 199, 576, 63, 7172, 275, 980, 14, 8748, 8, 4060, 9, 199, 1361, 8, 576, 63, 7172, 14, 1392, 9, 199, 576, 63, 7172, 275, 980, 14, 4441, 63, 5380, 8, 576, 63, 7172, 12, 3114, 29, 16, 9, 199, 576, 63, 7172, 275, 666, 63, 7172, 14, 1574, 8, 1648, 628, 35, 531, 199, 199, 3, 2790, 314, 2199, 199, 842, 63, 2758, 63, 384, 275, 3918, 3244, 4031, 8, 272, 7126, 63, 18235, 435, 2668, 1589, 63, 4375, 401, 272, 488, 12, 272, 298, 1569, 7172, 401, 272, 298, 10301, 1379, 401, 272, 298, 9846, 3623, 4765, 272, 16048, 628, 1635, 24, 401, 199, 9, 199, 11984, 63, 6514, 63, 384, 275, 366, 5017, 14, 981, 63, 1715, 8, 842, 63, 2758, 63, 384, 9, 199, 199, 3, 2790, 314, 10415, 548, 199, 68, 5017, 14, 981, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
Zarokka/exaile
plugins/grouptagger/gt_prefs.py
4
1526
# 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 1, 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. from xlgui.preferences import widgets from xl import xdg from xl.nls import gettext as _ import os from gi.repository import Gtk name = _('GroupTagger') basedir = os.path.dirname(os.path.realpath(__file__)) ui = os.path.join(basedir, 'gt_prefs.ui') def _get_system_default_font(): return Gtk.Widget.get_default_style().font_desc.to_string() class GTPanelFontPreference(widgets.FontButtonPreference): default = _get_system_default_font() name = 'plugin/grouptagger/panel_font' class GTPanelFontResetButtonPreference(widgets.FontResetButtonPreference): default = _get_system_default_font() name = 'plugin/grouptagger/reset_button' condition_preference_name = 'plugin/grouptagger/panel_font' class GTGroupingTagName(widgets.ComboPreference): default = 'grouping' name = 'plugin/grouptagger/tagname'
gpl-2.0
[ 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, 413, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 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, 12, 8217, 14, 199, 199, 504, 25077, 5885, 14, 18063, 492, 11114, 199, 504, 25077, 492, 671, 13279, 199, 504, 25077, 14, 78, 478, 492, 9796, 465, 485, 199, 646, 747, 199, 504, 18895, 14, 8421, 492, 11424, 199, 199, 354, 275, 4018, 2448, 1931, 836, 358, 199, 12484, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 1907, 275, 747, 14, 515, 14, 904, 8, 12484, 12, 283, 3308, 63, 17253, 14, 1907, 358, 199, 199, 318, 485, 362, 63, 2253, 63, 885, 63, 4246, 837, 272, 372, 11424, 14, 3339, 14, 362, 63, 885, 63, 2487, 1252, 4246, 63, 3257, 14, 475, 63, 875, 342, 199, 199, 533, 598, 6495, 4822, 6986, 25258, 8, 8583, 14, 6986, 4259, 25258, 304, 272, 849, 275, 485, 362, 63, 2253, 63, 885, 63, 4246, 342, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 7885, 63, 4246, 7, 199, 199, 533, 598, 6495, 4822, 6986, 9637, 4259, 25258, 8, 8583, 14, 6986, 9637, 4259, 25258, 304, 272, 849, 275, 485, 362, 63, 2253, 63, 885, 63, 4246, 342, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 3958, 63, 3887, 7, 272, 5558, 63, 14994, 63, 354, 275, 283, 2718, 15, 923, 1450, 836, 15, 7885, 63, 4246, 7, 421, 199, 533, 598, 52, 2448, 316, 12902, 8, 8583, 14, 12413, 25258, 304, 272, 849, 275, 283, 22390, 7, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 24173, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 961, 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, 413, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 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, 12, 8217, 14, 199, 199, 504, 25077, 5885, 14, 18063, 492, 11114, 199, 504, 25077, 492, 671, 13279, 199, 504, 25077, 14, 78, 478, 492, 9796, 465, 485, 199, 646, 747, 199, 504, 18895, 14, 8421, 492, 11424, 199, 199, 354, 275, 4018, 2448, 1931, 836, 358, 199, 12484, 275, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 199, 1907, 275, 747, 14, 515, 14, 904, 8, 12484, 12, 283, 3308, 63, 17253, 14, 1907, 358, 199, 199, 318, 485, 362, 63, 2253, 63, 885, 63, 4246, 837, 272, 372, 11424, 14, 3339, 14, 362, 63, 885, 63, 2487, 1252, 4246, 63, 3257, 14, 475, 63, 875, 342, 199, 199, 533, 598, 6495, 4822, 6986, 25258, 8, 8583, 14, 6986, 4259, 25258, 304, 272, 849, 275, 485, 362, 63, 2253, 63, 885, 63, 4246, 342, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 7885, 63, 4246, 7, 199, 199, 533, 598, 6495, 4822, 6986, 9637, 4259, 25258, 8, 8583, 14, 6986, 9637, 4259, 25258, 304, 272, 849, 275, 485, 362, 63, 2253, 63, 885, 63, 4246, 342, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 3958, 63, 3887, 7, 272, 5558, 63, 14994, 63, 354, 275, 283, 2718, 15, 923, 1450, 836, 15, 7885, 63, 4246, 7, 421, 199, 533, 598, 52, 2448, 316, 12902, 8, 8583, 14, 12413, 25258, 304, 272, 849, 275, 283, 22390, 7, 272, 536, 275, 283, 2718, 15, 923, 1450, 836, 15, 24173, 7, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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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 ]
DarioI/DroidSec
androguard/gui/helpers.py
14
2956
class Signature(object): def __init__(self, cls, method=None, descriptor=None): self.cls = cls self.class_components = self.cls.name.strip('L').strip(';').split('/') self.class_path = self.class_components[:-1] self.class_name = self.class_components[-1] self.full_class_name = self.cls.name self.method = method self.descriptor = descriptor def class2func(path): ''' Convert a path such as 'Landroid/support/v4/app/ActivityCompat;' into a method string 'CLASS_Landroid_support_v4_app_ActivityCompat' so we can call d.CLASS_Landroid_support_v4_app_ActivityCompat.get_source() ''' func = "CLASS_" + path.replace("/", "_").replace("$", "_").replace(";", "") return func def method2func(method): return "METHOD_" + method.replace("/", "_").replace("[", "").replace( "(", "").replace(")", "").replace(";", "") def classmethod2func(class_, method_): '''Convert two strings such as "Lcom/mwr/example/sieve/AddEntryActivity;" and "onCreate" into a string "CLASS_Lcom_example_sieve_AddEntryActivity.METHOD_onCreate" so we can access d.CLASS_Lcom_example_sieve_AddEntryActivity.METHOD_onCreate.XREFfrom ''' return "%s.%s" % (class2func(class_), method2func(method_)) def classmethod2display(class_, method_, descriptor_): '''Convert two strings such as "Lcom/mwr/example/sieve/AddEntryActivity;" and "onCreate" into a beautiful :) string to display Xrefs: "Lcom/mwr/example/sieve/AddEntryActivity; -> onCreate" ''' return "%s -> %s ( %s )" % (class_, method_, descriptor_) def display2classmethod(display): '''Opposite of classmethod2display. ''' L = display.split(" -> ") return (L[0], L[1]) def classdot2func(path): ''' Convert a path such as 'android.support.v4.app.ActivityCompat' into a method string 'CLASS_Landroid_support_v4_app_ActivityCompat' so we can call d.CLASS_Landroid_support_v4_app_ActivityCompat.get_source() ''' func = "CLASS_L" + path.replace(".", "_").replace("$", "_") return func def classdot2class(path): ''' Convert a path such as 'android.support.v4.app.ActivityCompat' into a string 'Landroid/support/v4/app/ActivityCompat' so we can change name of a class by d.CLASS_Landroid_support_v4_app_ActivityCompat.set_name(new_name) ''' if path[0] == 'L' and path[-1] == ';': print "WARNING: %s already a Lclass; name" % path return path new_name = 'L' + path.replace('.', '/') + ';' return new_name def proto2methodprotofunc(proto): '''Convert a prototype such as 'Ljava/lang/String;' into a string 'Ljava_lang_String" so we can append that to the 'METHOD_myMethod' if its export python name contains the prototype ''' return proto.replace(' ', '').replace('(', '').replace('[', '').replace( ')', '').replace('/', '_').replace(';', '')
apache-2.0
[ 533, 18603, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 843, 12, 1083, 29, 403, 12, 5872, 29, 403, 304, 267, 291, 14, 1886, 275, 843, 267, 291, 14, 533, 63, 4608, 275, 291, 14, 1886, 14, 354, 14, 1913, 360, 44, 1959, 1913, 25282, 1959, 1294, 7825, 267, 291, 14, 533, 63, 515, 275, 291, 14, 533, 63, 4608, 4439, 17, 61, 267, 291, 14, 533, 63, 354, 275, 291, 14, 533, 63, 4608, 1988, 17, 61, 267, 291, 14, 2861, 63, 533, 63, 354, 275, 291, 14, 1886, 14, 354, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 4120, 275, 5872, 421, 199, 318, 1021, 18, 1532, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 14752, 15, 4058, 15, 86, 20, 15, 571, 15, 14350, 2404, 292, 8942, 267, 1901, 282, 1083, 1059, 283, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 7, 267, 880, 781, 883, 1240, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 362, 63, 1365, 342, 272, 1449, 339, 2562, 275, 298, 6885, 12172, 435, 931, 14, 1814, 27374, 2668, 3471, 1814, 480, 11918, 2668, 3471, 1814, 480, 17259, 6899, 272, 372, 2562, 421, 199, 318, 1083, 18, 1532, 8, 765, 304, 272, 372, 298, 9977, 12172, 435, 1083, 14, 1814, 27374, 2668, 3471, 1814, 10994, 401, 25354, 1814, 8, 267, 7340, 401, 25354, 1814, 480, 4186, 25354, 1814, 480, 17259, 6899, 421, 199, 318, 18990, 18, 1532, 8, 533, 3131, 1083, 7822, 272, 1449, 7306, 2877, 3326, 4066, 465, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 9426, 436, 298, 265, 2499, 2, 2126, 1901, 282, 1059, 298, 6885, 63, 44, 957, 63, 2694, 63, 338, 4754, 63, 1123, 3900, 14350, 14, 9977, 63, 265, 2499, 2, 2126, 880, 781, 883, 2879, 366, 14, 6885, 63, 44, 957, 63, 2694, 63, 338, 4754, 63, 1123, 3900, 14350, 14, 9977, 63, 265, 2499, 14, 56, 8279, 504, 272, 1449, 339, 372, 2071, 83, 4111, 83, 2, 450, 334, 533, 18, 1532, 8, 533, 29425, 1083, 18, 1532, 8, 765, 13309, 421, 199, 318, 18990, 18, 2918, 8, 533, 3131, 1083, 3131, 5872, 7822, 272, 1449, 7306, 2877, 3326, 4066, 465, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 9426, 436, 298, 265, 2499, 2, 272, 1901, 282, 506, 25146, 32428, 1059, 370, 2929, 1323, 7655, 26, 272, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 27, 1035, 641, 2499, 2, 272, 1449, 339, 372, 2071, 83, 1035, 450, 83, 334, 450, 83, 776, 2, 450, 334, 533, 3131, 1083, 3131, 5872, 4602, 421, 199, 318, 2929, 18, 3744, 8, 2918, 304, 272, 1449, 4619, 23898, 402, 18990, 18, 2918, 14, 272, 1449, 339, 491, 275, 2929, 14, 1294, 480, 1035, 6099, 272, 372, 334, 44, 59, 16, 467, 491, 59, 17, 566, 421, 199, 318, 1021, 3287, 18, 1532, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 6238, 14, 4058, 14, 86, 20, 14, 571, 14, 14350, 2404, 292, 7, 267, 1901, 282, 1083, 1059, 283, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 7, 267, 880, 781, 883, 1240, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 362, 63, 1365, 342, 272, 1449, 339, 2562, 275, 298, 6885, 63, 44, 2, 435, 931, 14, 1814, 30381, 2668, 3471, 1814, 480, 11918, 2668, 531, 272, 372, 2562, 421, 199, 318, 1021, 3287, 18, 533, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 6238, 14, 4058, 14, 86, 20, 14, 571, 14, 14350, 2404, 292, 7, 267, 1901, 282, 1059, 283, 14752, 15, 4058, 15, 86, 20, 15, 571, 15, 14350, 2404, 292, 7, 267, 880, 781, 883, 1570, 536, 402, 282, 1021, 701, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 409, 63, 354, 8, 1222, 63, 354, 9, 272, 1449, 272, 340, 931, 59, 16, 61, 508, 283, 44, 7, 436, 931, 1988, 17, 61, 508, 283, 6015, 267, 870, 298, 9171, 26, 450, 83, 2575, 282, 491, 533, 27, 536, 2, 450, 931, 267, 372, 931, 339, 892, 63, 354, 275, 283, 44, 7, 435, 931, 14, 1814, 14078, 15107, 435, 20054, 272, 372, 892, 63, 354, 421, 199, 318, 4104, 18, 765, 2625, 1532, 8, 2625, 304, 272, 1449, 7306, 282, 19393, 4066, 465, 283, 24457, 15, 4159, 15, 1558, 8942, 2126, 1901, 282, 1059, 283, 24457, 63, 4159, 63, 1558, 2, 880, 781, 883, 5666, 626, 370, 314, 2126, 283, 9977, 63, 1662, 3767, 7, 340, 2399, 4843, 2366, 536, 3509, 314, 19393, 272, 1449, 272, 372, 4104, 14, 1814, 360, 1656, 12548, 1814, 360, 5102, 12548, 1814, 11894, 297, 12548, 1814, 8, 267, 283, 3196, 12548, 1814, 10998, 2513, 1959, 1814, 360, 10805, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 18603, 8, 785, 304, 339, 347, 636, 826, 721, 277, 12, 843, 12, 1083, 29, 403, 12, 5872, 29, 403, 304, 267, 291, 14, 1886, 275, 843, 267, 291, 14, 533, 63, 4608, 275, 291, 14, 1886, 14, 354, 14, 1913, 360, 44, 1959, 1913, 25282, 1959, 1294, 7825, 267, 291, 14, 533, 63, 515, 275, 291, 14, 533, 63, 4608, 4439, 17, 61, 267, 291, 14, 533, 63, 354, 275, 291, 14, 533, 63, 4608, 1988, 17, 61, 267, 291, 14, 2861, 63, 533, 63, 354, 275, 291, 14, 1886, 14, 354, 267, 291, 14, 765, 275, 1083, 267, 291, 14, 4120, 275, 5872, 421, 199, 318, 1021, 18, 1532, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 14752, 15, 4058, 15, 86, 20, 15, 571, 15, 14350, 2404, 292, 8942, 267, 1901, 282, 1083, 1059, 283, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 7, 267, 880, 781, 883, 1240, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 362, 63, 1365, 342, 272, 1449, 339, 2562, 275, 298, 6885, 12172, 435, 931, 14, 1814, 27374, 2668, 3471, 1814, 480, 11918, 2668, 3471, 1814, 480, 17259, 6899, 272, 372, 2562, 421, 199, 318, 1083, 18, 1532, 8, 765, 304, 272, 372, 298, 9977, 12172, 435, 1083, 14, 1814, 27374, 2668, 3471, 1814, 10994, 401, 25354, 1814, 8, 267, 7340, 401, 25354, 1814, 480, 4186, 25354, 1814, 480, 17259, 6899, 421, 199, 318, 18990, 18, 1532, 8, 533, 3131, 1083, 7822, 272, 1449, 7306, 2877, 3326, 4066, 465, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 9426, 436, 298, 265, 2499, 2, 2126, 1901, 282, 1059, 298, 6885, 63, 44, 957, 63, 2694, 63, 338, 4754, 63, 1123, 3900, 14350, 14, 9977, 63, 265, 2499, 2, 2126, 880, 781, 883, 2879, 366, 14, 6885, 63, 44, 957, 63, 2694, 63, 338, 4754, 63, 1123, 3900, 14350, 14, 9977, 63, 265, 2499, 14, 56, 8279, 504, 272, 1449, 339, 372, 2071, 83, 4111, 83, 2, 450, 334, 533, 18, 1532, 8, 533, 29425, 1083, 18, 1532, 8, 765, 13309, 421, 199, 318, 18990, 18, 2918, 8, 533, 3131, 1083, 3131, 5872, 7822, 272, 1449, 7306, 2877, 3326, 4066, 465, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 9426, 436, 298, 265, 2499, 2, 272, 1901, 282, 506, 25146, 32428, 1059, 370, 2929, 1323, 7655, 26, 272, 298, 44, 957, 15, 14716, 82, 15, 2694, 15, 338, 4754, 15, 1123, 3900, 14350, 27, 1035, 641, 2499, 2, 272, 1449, 339, 372, 2071, 83, 1035, 450, 83, 334, 450, 83, 776, 2, 450, 334, 533, 3131, 1083, 3131, 5872, 4602, 421, 199, 318, 2929, 18, 3744, 8, 2918, 304, 272, 1449, 4619, 23898, 402, 18990, 18, 2918, 14, 272, 1449, 339, 491, 275, 2929, 14, 1294, 480, 1035, 6099, 272, 372, 334, 44, 59, 16, 467, 491, 59, 17, 566, 421, 199, 318, 1021, 3287, 18, 1532, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 6238, 14, 4058, 14, 86, 20, 14, 571, 14, 14350, 2404, 292, 7, 267, 1901, 282, 1083, 1059, 283, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 7, 267, 880, 781, 883, 1240, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 362, 63, 1365, 342, 272, 1449, 339, 2562, 275, 298, 6885, 63, 44, 2, 435, 931, 14, 1814, 30381, 2668, 3471, 1814, 480, 11918, 2668, 531, 272, 372, 2562, 421, 199, 318, 1021, 3287, 18, 533, 8, 515, 304, 272, 1449, 7905, 282, 931, 4066, 465, 283, 6238, 14, 4058, 14, 86, 20, 14, 571, 14, 14350, 2404, 292, 7, 267, 1901, 282, 1059, 283, 14752, 15, 4058, 15, 86, 20, 15, 571, 15, 14350, 2404, 292, 7, 267, 880, 781, 883, 1570, 536, 402, 282, 1021, 701, 366, 14, 6885, 63, 14752, 63, 4058, 63, 86, 20, 63, 571, 63, 14350, 2404, 292, 14, 409, 63, 354, 8, 1222, 63, 354, 9, 272, 1449, 272, 340, 931, 59, 16, 61, 508, 283, 44, 7, 436, 931, 1988, 17, 61, 508, 283, 6015, 267, 870, 298, 9171, 26, 450, 83, 2575, 282, 491, 533, 27, 536, 2, 450, 931, 267, 372, 931, 339, 892, 63, 354, 275, 283, 44, 7, 435, 931, 14, 1814, 14078, 15107, 435, 20054, 272, 372, 892, 63, 354, 421, 199, 318, 4104, 18, 765, 2625, 1532, 8, 2625, 304, 272, 1449, 7306, 282, 19393, 4066, 465, 283, 24457, 15, 4159, 15, 1558, 8942, 2126, 1901, 282, 1059, 283, 24457, 63, 4159, 63, 1558, 2, 880, 781, 883, 5666, 626, 370, 314, 2126, 283, 9977, 63, 1662, 3767, 7, 340, 2399, 4843, 2366, 536, 3509, 314, 19393, 272, 1449, 272, 372, 4104, 14, 1814, 360, 1656, 12548, 1814, 360, 5102, 12548, 1814, 11894, 297, 12548, 1814, 8, 267, 283, 3196, 12548, 1814, 10998, 2513, 1959, 1814, 360, 10805, 4074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sauloal/linuxscripts
apache/var/www/html/saulo/torrent/html/bin/clients/mainline/BitTorrent/GetTorrent.py
6
5371
# The contents of this file are subject to the BitTorrent Open Source License # Version 1.1 (the License). You may not copy or use this file, in either # source code or executable form, except in compliance with the License. You # may obtain a copy of the License at http://www.bittorrent.com/license/. # # Software distributed under the License is distributed on an AS IS basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # GetTorrent -- abstraction which can get a .torrent file from multiple # sources: local file, url, etc. # written by Matt Chisholm and David Harrison import os import re from BitTorrent import zurllib from BTL.translation import _ from BTL.bencode import bdecode, bencode from BTL.ConvertedMetainfo import ConvertedMetainfo from BTL.platform import get_cache_dir urlpat = re.compile('^\w+://') urlpat_torrent = re.compile('^torrent://') urlpat_bittorrent = re.compile('^bittorrent://') class GetTorrentException(Exception): pass class UnknownArgument(GetTorrentException): pass class URLException(GetTorrentException): pass class FileException(GetTorrentException): pass class MetainfoException(GetTorrentException): pass def get_quietly(arg): """Wrapper for GetTorrent.get() which works around an IE bug. If there's an error opening a file from the IE cache, act like we simply didn't get a file (because we didn't). This happens when IE passes us a path to a file in its cache that has already been deleted because it came from a website which set Pragma:No-Cache on it. """ try: data = get(arg) except FileException, e: cache = get_cache_dir() if (cache is not None) and (cache in unicode(e.args[0])): data = None else: raise return data def _get(arg): """Obtains the contents of the .torrent metainfo file either from the local filesystem or from a remote server. 'arg' is either a filename or an URL. Returns data, the raw contents of the .torrent file. Any exception raised while obtaining the .torrent file or parsing its contents is caught and wrapped in one of the following errors: GetTorrent.URLException, GetTorrent.FileException, GetTorrent.MetainfoException, or GetTorrent.UnknownArgument. (All have the base class GetTorrent.GetTorrentException) """ data = None arg_stripped = arg.strip() if os.access(arg, os.F_OK): data = get_file(arg) elif urlpat.match(arg_stripped): data = get_url(arg_stripped) else: raise UnknownArgument(_('Could not read "%s", it is neither a file nor a URL.') % arg) return data def get(arg): """Obtains the contents of the .torrent metainfo file either from the local filesystem or from a remote server. 'arg' is either a filename or an URL. Returns a ConvertedMetainfo object which is the parsed metainfo from the contents of the .torrent file. Any exception raised while obtaining the .torrent file or parsing its contents is caught and wrapped in one of the following errors: GetTorrent.URLException, GetTorrent.FileException, GetTorrent.MetainfoException, or GetTorrent.UnknownArgument. (All have the base class GetTorrent.GetTorrentException) """ data = _get(arg) metainfo = None try: b = bdecode(data) metainfo = ConvertedMetainfo(b) except Exception, e: raise MetainfoException( (_('"%s" is not a valid torrent file (%s).') % (arg, unicode(e))) ) return metainfo def get_url(url): """Downloads the .torrent metainfo file specified by the passed URL and returns data, the raw contents of the metainfo file. Any exception raised while trying to obtain the metainfo file is caught and GetTorrent.URLException is raised instead. """ data = None err_str = ((_('Could not download or open "%s"')% url) + '\n' + _("Try using a web browser to download the torrent file.")) u = None # pending protocol changes, convert: # torrent://http://path.to/file # and: # bittorrent://http://path.to/file # to: # http://path.to/file url = urlpat_torrent.sub('', url) url = urlpat_bittorrent.sub('', url) try: u = zurllib.urlopen(url) data = u.read() u.close() except Exception, e: if u is not None: u.close() raise URLException(err_str + "\n(%s)" % e) else: if u is not None: u.close() return data def get_file(filename): """Reads the .torrent metainfo file specified by the passed filename and returns data, the raw contents of the metainfo file. Any exception raised while trying to obtain the metainfo file is caught and GetTorrent.FileException is raised instead. """ data = None f = None try: f = file(filename, 'rb') data = f.read() f.close() except Exception, e: if f is not None: f.close() raise FileException((_("Could not read %s") % filename) + (': %s' % unicode(e.args[0]))) return data
mit
[ 3, 710, 4072, 402, 642, 570, 787, 5420, 370, 314, 10199, 32004, 3232, 5800, 844, 199, 3, 3394, 413, 14, 17, 334, 1589, 844, 680, 221, 2047, 1443, 440, 1331, 503, 675, 642, 570, 12, 315, 1902, 199, 3, 1350, 1233, 503, 7286, 1824, 12, 871, 315, 4151, 543, 314, 844, 14, 221, 2047, 199, 3, 1443, 3332, 282, 1331, 402, 314, 844, 737, 1455, 921, 1544, 14, 2075, 14101, 14, 957, 15, 1682, 8083, 199, 3, 199, 3, 2290, 1854, 1334, 314, 844, 365, 1854, 641, 376, 4319, 2281, 5597, 12, 199, 3, 2428, 3408, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 199, 3, 367, 314, 2488, 2637, 4210, 4481, 436, 4204, 1334, 314, 199, 3, 844, 14, 199, 199, 3, 2372, 32004, 1553, 2236, 29639, 1314, 883, 664, 282, 1275, 14101, 570, 687, 3663, 199, 3, 5274, 26, 2257, 570, 12, 1166, 12, 5423, 14, 199, 199, 3, 5313, 701, 31653, 445, 866, 24588, 77, 436, 20232, 25378, 322, 834, 199, 199, 646, 747, 199, 646, 295, 199, 504, 10199, 32004, 492, 1315, 4078, 199, 504, 699, 7308, 14, 6893, 492, 485, 199, 199, 504, 699, 7308, 14, 66, 2143, 492, 330, 2708, 12, 330, 2143, 199, 504, 699, 7308, 14, 7619, 471, 3396, 815, 492, 11801, 471, 3396, 815, 199, 504, 699, 7308, 14, 3246, 492, 664, 63, 1637, 63, 694, 199, 199, 633, 10853, 275, 295, 14, 2014, 9097, 60, 87, 11, 921, 358, 199, 633, 10853, 63, 14101, 275, 295, 14, 2014, 9097, 14101, 921, 358, 199, 633, 10853, 63, 2075, 14101, 275, 295, 14, 2014, 9097, 2075, 14101, 921, 358, 199, 199, 533, 2372, 32004, 1726, 8, 1726, 304, 272, 986, 199, 199, 533, 14831, 5201, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 25628, 906, 16010, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 3814, 1726, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 6288, 815, 1726, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 318, 664, 63, 10243, 590, 8, 1273, 304, 272, 408, 4590, 367, 2372, 32004, 14, 362, 342, 1314, 5419, 6818, 376, 15292, 6519, 14, 221, 982, 272, 2337, 1159, 376, 1125, 13618, 282, 570, 687, 314, 15292, 2581, 12, 2454, 2839, 781, 272, 9329, 9980, 1133, 664, 282, 570, 334, 20684, 781, 9980, 1133, 680, 221, 961, 10986, 1380, 272, 15292, 14933, 2739, 282, 931, 370, 282, 570, 315, 2399, 2581, 626, 965, 2575, 2757, 272, 5463, 2952, 652, 20382, 687, 282, 10691, 1314, 663, 510, 9717, 26, 1944, 13, 4437, 272, 641, 652, 14, 272, 408, 272, 862, 26, 267, 666, 275, 664, 8, 1273, 9, 272, 871, 3814, 1726, 12, 325, 26, 267, 2581, 275, 664, 63, 1637, 63, 694, 342, 267, 340, 334, 1637, 365, 440, 488, 9, 436, 334, 1637, 315, 2649, 8, 69, 14, 589, 59, 16, 18710, 288, 666, 275, 488, 267, 587, 26, 288, 746, 339, 372, 666, 199, 199, 318, 485, 362, 8, 1273, 304, 272, 408, 11394, 3953, 314, 4072, 402, 314, 1275, 14101, 3404, 815, 570, 1902, 687, 2126, 314, 2257, 10036, 503, 687, 282, 3982, 1654, 14, 283, 1273, 7, 365, 1902, 2126, 282, 1788, 503, 376, 2851, 14, 10817, 1803, 666, 12, 314, 3066, 4072, 402, 314, 1275, 14101, 570, 14, 6184, 2126, 1919, 4915, 1830, 12408, 314, 1275, 14101, 570, 503, 6057, 2126, 2399, 4072, 365, 15604, 436, 8072, 315, 1373, 402, 314, 2569, 2126, 2552, 26, 2372, 32004, 14, 1230, 906, 16010, 12, 2372, 32004, 14, 1173, 1726, 12, 2126, 2372, 32004, 14, 3396, 815, 1726, 12, 503, 2372, 32004, 14, 5912, 5201, 14, 2126, 334, 2422, 1172, 314, 1300, 1021, 2372, 32004, 14, 1002, 32004, 1726, 9, 2126, 408, 272, 666, 275, 488, 272, 1680, 63, 25382, 275, 1680, 14, 1913, 342, 272, 340, 747, 14, 2732, 8, 1273, 12, 747, 14, 38, 63, 3593, 304, 267, 666, 275, 664, 63, 493, 8, 1273, 9, 272, 916, 1166, 10853, 14, 1431, 8, 1273, 63, 25382, 304, 267, 666, 275, 664, 63, 633, 8, 1273, 63, 25382, 9, 272, 587, 26, 267, 746, 14831, 5201, 6723, 6531, 440, 1586, 2071, 83, 401, 652, 365, 15564, 282, 570, 6590, 282, 2851, 2659, 450, 1680, 9, 339, 372, 666, 421, 199, 318, 664, 8, 1273, 304, 272, 408, 11394, 3953, 314, 4072, 402, 314, 1275, 14101, 3404, 815, 570, 1902, 687, 2126, 314, 2257, 10036, 503, 687, 282, 3982, 1654, 14, 283, 1273, 7, 365, 1902, 2126, 282, 1788, 503, 376, 2851, 14, 10817, 1803, 282, 11801, 471, 3396, 815, 909, 1314, 365, 314, 4565, 3404, 815, 2126, 687, 314, 4072, 402, 314, 1275, 14101, 570, 14, 221, 6184, 1919, 4915, 2126, 1830, 12408, 314, 1275, 14101, 570, 503, 6057, 2399, 4072, 365, 2126, 15604, 436, 8072, 315, 1373, 402, 314, 2569, 2552, 26, 2126, 2372, 32004, 14, 1230, 906, 16010, 12, 2372, 32004, 14, 1173, 1726, 12, 28872, 2372, 32004, 14, 3396, 815, 1726, 12, 503, 2372, 32004, 14, 5912, 5201, 14, 2126, 334, 2422, 1172, 314, 1300, 1021, 2372, 32004, 14, 1002, 32004, 1726, 9, 2126, 408, 272, 666, 275, 485, 362, 8, 1273, 9, 272, 3404, 815, 275, 488, 272, 862, 26, 267, 330, 275, 330, 2708, 8, 576, 9, 267, 3404, 815, 275, 11801, 471, 3396, 815, 8, 66, 9, 272, 871, 2186, 12, 325, 26, 267, 746, 6288, 815, 1726, 8, 288, 21790, 6808, 83, 2, 365, 440, 282, 1686, 17671, 570, 4366, 83, 28583, 450, 334, 1273, 12, 2649, 8, 69, 1724, 288, 776, 339, 372, 3404, 815, 421, 199, 318, 664, 63, 633, 8, 633, 304, 272, 408, 3514, 3640, 314, 1275, 14101, 3404, 815, 570, 2013, 701, 314, 3032, 2126, 2851, 436, 2529, 666, 12, 314, 3066, 4072, 402, 314, 3404, 815, 570, 14, 2126, 6184, 1919, 4915, 1830, 9936, 370, 3332, 314, 3404, 815, 570, 2126, 365, 15604, 436, 2372, 32004, 14, 1230, 906, 16010, 365, 4915, 3140, 14, 2126, 408, 339, 666, 275, 488, 272, 2329, 63, 495, 275, 334, 6723, 6531, 440, 5235, 503, 1551, 2071, 83, 9008, 5, 1166, 9, 435, 1557, 78, 7, 435, 2049, 3824, 12357, 1808, 282, 3330, 7042, 370, 5235, 314 ]
[ 710, 4072, 402, 642, 570, 787, 5420, 370, 314, 10199, 32004, 3232, 5800, 844, 199, 3, 3394, 413, 14, 17, 334, 1589, 844, 680, 221, 2047, 1443, 440, 1331, 503, 675, 642, 570, 12, 315, 1902, 199, 3, 1350, 1233, 503, 7286, 1824, 12, 871, 315, 4151, 543, 314, 844, 14, 221, 2047, 199, 3, 1443, 3332, 282, 1331, 402, 314, 844, 737, 1455, 921, 1544, 14, 2075, 14101, 14, 957, 15, 1682, 8083, 199, 3, 199, 3, 2290, 1854, 1334, 314, 844, 365, 1854, 641, 376, 4319, 2281, 5597, 12, 199, 3, 2428, 3408, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 199, 3, 367, 314, 2488, 2637, 4210, 4481, 436, 4204, 1334, 314, 199, 3, 844, 14, 199, 199, 3, 2372, 32004, 1553, 2236, 29639, 1314, 883, 664, 282, 1275, 14101, 570, 687, 3663, 199, 3, 5274, 26, 2257, 570, 12, 1166, 12, 5423, 14, 199, 199, 3, 5313, 701, 31653, 445, 866, 24588, 77, 436, 20232, 25378, 322, 834, 199, 199, 646, 747, 199, 646, 295, 199, 504, 10199, 32004, 492, 1315, 4078, 199, 504, 699, 7308, 14, 6893, 492, 485, 199, 199, 504, 699, 7308, 14, 66, 2143, 492, 330, 2708, 12, 330, 2143, 199, 504, 699, 7308, 14, 7619, 471, 3396, 815, 492, 11801, 471, 3396, 815, 199, 504, 699, 7308, 14, 3246, 492, 664, 63, 1637, 63, 694, 199, 199, 633, 10853, 275, 295, 14, 2014, 9097, 60, 87, 11, 921, 358, 199, 633, 10853, 63, 14101, 275, 295, 14, 2014, 9097, 14101, 921, 358, 199, 633, 10853, 63, 2075, 14101, 275, 295, 14, 2014, 9097, 2075, 14101, 921, 358, 199, 199, 533, 2372, 32004, 1726, 8, 1726, 304, 272, 986, 199, 199, 533, 14831, 5201, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 25628, 906, 16010, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 3814, 1726, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 533, 6288, 815, 1726, 8, 1002, 32004, 1726, 304, 272, 986, 199, 199, 318, 664, 63, 10243, 590, 8, 1273, 304, 272, 408, 4590, 367, 2372, 32004, 14, 362, 342, 1314, 5419, 6818, 376, 15292, 6519, 14, 221, 982, 272, 2337, 1159, 376, 1125, 13618, 282, 570, 687, 314, 15292, 2581, 12, 2454, 2839, 781, 272, 9329, 9980, 1133, 664, 282, 570, 334, 20684, 781, 9980, 1133, 680, 221, 961, 10986, 1380, 272, 15292, 14933, 2739, 282, 931, 370, 282, 570, 315, 2399, 2581, 626, 965, 2575, 2757, 272, 5463, 2952, 652, 20382, 687, 282, 10691, 1314, 663, 510, 9717, 26, 1944, 13, 4437, 272, 641, 652, 14, 272, 408, 272, 862, 26, 267, 666, 275, 664, 8, 1273, 9, 272, 871, 3814, 1726, 12, 325, 26, 267, 2581, 275, 664, 63, 1637, 63, 694, 342, 267, 340, 334, 1637, 365, 440, 488, 9, 436, 334, 1637, 315, 2649, 8, 69, 14, 589, 59, 16, 18710, 288, 666, 275, 488, 267, 587, 26, 288, 746, 339, 372, 666, 199, 199, 318, 485, 362, 8, 1273, 304, 272, 408, 11394, 3953, 314, 4072, 402, 314, 1275, 14101, 3404, 815, 570, 1902, 687, 2126, 314, 2257, 10036, 503, 687, 282, 3982, 1654, 14, 283, 1273, 7, 365, 1902, 2126, 282, 1788, 503, 376, 2851, 14, 10817, 1803, 666, 12, 314, 3066, 4072, 402, 314, 1275, 14101, 570, 14, 6184, 2126, 1919, 4915, 1830, 12408, 314, 1275, 14101, 570, 503, 6057, 2126, 2399, 4072, 365, 15604, 436, 8072, 315, 1373, 402, 314, 2569, 2126, 2552, 26, 2372, 32004, 14, 1230, 906, 16010, 12, 2372, 32004, 14, 1173, 1726, 12, 2126, 2372, 32004, 14, 3396, 815, 1726, 12, 503, 2372, 32004, 14, 5912, 5201, 14, 2126, 334, 2422, 1172, 314, 1300, 1021, 2372, 32004, 14, 1002, 32004, 1726, 9, 2126, 408, 272, 666, 275, 488, 272, 1680, 63, 25382, 275, 1680, 14, 1913, 342, 272, 340, 747, 14, 2732, 8, 1273, 12, 747, 14, 38, 63, 3593, 304, 267, 666, 275, 664, 63, 493, 8, 1273, 9, 272, 916, 1166, 10853, 14, 1431, 8, 1273, 63, 25382, 304, 267, 666, 275, 664, 63, 633, 8, 1273, 63, 25382, 9, 272, 587, 26, 267, 746, 14831, 5201, 6723, 6531, 440, 1586, 2071, 83, 401, 652, 365, 15564, 282, 570, 6590, 282, 2851, 2659, 450, 1680, 9, 339, 372, 666, 421, 199, 318, 664, 8, 1273, 304, 272, 408, 11394, 3953, 314, 4072, 402, 314, 1275, 14101, 3404, 815, 570, 1902, 687, 2126, 314, 2257, 10036, 503, 687, 282, 3982, 1654, 14, 283, 1273, 7, 365, 1902, 2126, 282, 1788, 503, 376, 2851, 14, 10817, 1803, 282, 11801, 471, 3396, 815, 909, 1314, 365, 314, 4565, 3404, 815, 2126, 687, 314, 4072, 402, 314, 1275, 14101, 570, 14, 221, 6184, 1919, 4915, 2126, 1830, 12408, 314, 1275, 14101, 570, 503, 6057, 2399, 4072, 365, 2126, 15604, 436, 8072, 315, 1373, 402, 314, 2569, 2552, 26, 2126, 2372, 32004, 14, 1230, 906, 16010, 12, 2372, 32004, 14, 1173, 1726, 12, 28872, 2372, 32004, 14, 3396, 815, 1726, 12, 503, 2372, 32004, 14, 5912, 5201, 14, 2126, 334, 2422, 1172, 314, 1300, 1021, 2372, 32004, 14, 1002, 32004, 1726, 9, 2126, 408, 272, 666, 275, 485, 362, 8, 1273, 9, 272, 3404, 815, 275, 488, 272, 862, 26, 267, 330, 275, 330, 2708, 8, 576, 9, 267, 3404, 815, 275, 11801, 471, 3396, 815, 8, 66, 9, 272, 871, 2186, 12, 325, 26, 267, 746, 6288, 815, 1726, 8, 288, 21790, 6808, 83, 2, 365, 440, 282, 1686, 17671, 570, 4366, 83, 28583, 450, 334, 1273, 12, 2649, 8, 69, 1724, 288, 776, 339, 372, 3404, 815, 421, 199, 318, 664, 63, 633, 8, 633, 304, 272, 408, 3514, 3640, 314, 1275, 14101, 3404, 815, 570, 2013, 701, 314, 3032, 2126, 2851, 436, 2529, 666, 12, 314, 3066, 4072, 402, 314, 3404, 815, 570, 14, 2126, 6184, 1919, 4915, 1830, 9936, 370, 3332, 314, 3404, 815, 570, 2126, 365, 15604, 436, 2372, 32004, 14, 1230, 906, 16010, 365, 4915, 3140, 14, 2126, 408, 339, 666, 275, 488, 272, 2329, 63, 495, 275, 334, 6723, 6531, 440, 5235, 503, 1551, 2071, 83, 9008, 5, 1166, 9, 435, 1557, 78, 7, 435, 2049, 3824, 12357, 1808, 282, 3330, 7042, 370, 5235, 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,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
xiaohutushen30/seentao-xblock-sdk
sample_xblocks/basic/problem.py
11
20841
"""Problem XBlock, and friends. These implement a general mechanism for problems containing input fields and checkers, wired together in interesting ways. This code is in the XBlock layer. A rough sequence diagram:: BROWSER (Javascript) SERVER (Python) Problem Input Checker Problem Input Checker | | | | | | | submit()| | | | | +-------->| | | | | |<--------+ submit()| | | | +------------------->| | | | |<-------------------+ | | | | | | "check" | | | +------------------------------------>| submit()| | | | | +-------->| | | | | |<--------+ check()| | | | +------------------>| | | | |<------------------| |<------------------------------------+ | | | handleSubmit() | | | | +-------->| handleCheck() | | | +------------------->| | | | | | | | | | """ import inspect import random import string # pylint: disable=W0402 import time from xblock.core import XBlock from xblock.fields import Integer, Scope, String, Any, Boolean, Dict from xblock.run_script import run_script from xblock.fragment import Fragment class ProblemBlock(XBlock): """A generalized container of InputBlocks and Checkers. """ script = String(help="Python code to compute values", scope=Scope.content, default="") seed = Integer(help="Random seed for this student", scope=Scope.user_state, default=0) problem_attempted = Boolean(help="Has the student attempted this problem?", scope=Scope.user_state, default=False) has_children = True @classmethod def parse_xml(cls, node, runtime, keys, id_generator): block = runtime.construct_xblock_from_class(cls, keys) # Find <script> children, turn them into script content. for child in node: if child.tag == "script": block.script += child.text else: block.runtime.add_node_as_child(block, child, id_generator) return block def set_student_seed(self): """Set a random seed for the student so they each have different but repeatable data.""" # Don't return zero, that's the default, and the sign that we should make a new seed. self.seed = int(time.time() * 1000) % 100 + 1 def calc_context(self, context): """If we have a script, run it, and return the resulting context.""" if self.script: # Seed the random number for the student if not self.seed: self.set_student_seed() random.seed(self.seed) script_vals = run_script(self.script) context = dict(context) context.update(script_vals) return context # The content controls how the Inputs attach to Graders def student_view(self, context=None): """Provide the default student view.""" if context is None: context = {} context = self.calc_context(context) result = Fragment() named_child_frags = [] # self.children is an attribute obtained from ChildrenModelMetaclass, so disable the # static pylint checking warning about this. for child_id in self.children: # pylint: disable=E1101 child = self.runtime.get_block(child_id) frag = self.runtime.render_child(child, "problem_view", context) result.add_frag_resources(frag) named_child_frags.append((child.name, frag)) result.add_css(""" .problem { border: solid 1px #888; padding: 3px; } """) result.add_content(self.runtime.render_template( "problem.html", named_children=named_child_frags )) result.add_javascript(""" function ProblemBlock(runtime, element) { function callIfExists(obj, fn) { if (typeof obj[fn] == 'function') { return obj[fn].apply(obj, Array.prototype.slice.call(arguments, 2)); } else { return undefined; } } function handleCheckResults(results) { $.each(results.submitResults || {}, function(input, result) { callIfExists(runtime.childMap(element, input), 'handleSubmit', result); }); $.each(results.checkResults || {}, function(checker, result) { callIfExists(runtime.childMap(element, checker), 'handleCheck', result); }); } // To submit a problem, call all the named children's submit() // function, collect their return values, and post that object // to the check handler. $(element).find('.check').bind('click', function() { var data = {}; var children = runtime.children(element); for (var i = 0; i < children.length; i++) { var child = children[i]; if (child.name !== undefined) { data[child.name] = callIfExists(child, 'submit'); } } var handlerUrl = runtime.handlerUrl(element, 'check') $.post(handlerUrl, JSON.stringify(data)).success(handleCheckResults); }); $(element).find('.rerandomize').bind('click', function() { var handlerUrl = runtime.handlerUrl(element, 'rerandomize'); $.post(handlerUrl, JSON.stringify({})); }); } """) result.initialize_js('ProblemBlock') return result @XBlock.json_handler def check(self, submissions, suffix=''): # pylint: disable=unused-argument """ Processess the `submissions` with each provided Checker. First calls the submit() method on each InputBlock. Then, for each Checker, finds the values it needs and passes them to the appropriate `check()` method. Returns a dictionary of 'submitResults': {input_name: user_submitted_results}, 'checkResults': {checker_name: results_passed_through_checker} """ self.problem_attempted = True context = self.calc_context({}) child_map = {} # self.children is an attribute obtained from ChildrenModelMetaclass, so disable the # static pylint checking warning about this. for child_id in self.children: # pylint: disable=E1101 child = self.runtime.get_block(child_id) if child.name: child_map[child.name] = child # For each InputBlock, call the submit() method with the browser-sent # input data. submit_results = {} for input_name, submission in submissions.items(): child = child_map[input_name] submit_results[input_name] = child.submit(submission) child.save() # For each Checker, find the values it wants, and pass them to its # check() method. checkers = list(self.runtime.querypath(self, "./checker")) check_results = {} for checker in checkers: arguments = checker.arguments kwargs = {} kwargs.update(arguments) for arg_name, arg_value in arguments.items(): if arg_value.startswith("."): values = list(self.runtime.querypath(self, arg_value)) # TODO: What is the specific promised semantic of the iterability # of the value returned by querypath? kwargs[arg_name] = values[0] elif arg_value.startswith("$"): kwargs[arg_name] = context.get(arg_value[1:]) elif arg_value.startswith("="): kwargs[arg_name] = int(arg_value[1:]) else: raise ValueError("Couldn't interpret checker argument: %r" % arg_value) result = checker.check(**kwargs) if checker.name: check_results[checker.name] = result return { 'submitResults': submit_results, 'checkResults': check_results, } @XBlock.json_handler def rerandomize(self, unused, suffix=''): # pylint: disable=unused-argument """Set a new random seed for the student.""" self.set_student_seed() return {'status': 'ok'} @staticmethod def workbench_scenarios(): """A few canned scenarios for display in the workbench.""" return [ ("problem with thumbs and textbox", """\ <problem_demo> <html_demo> <p>You have three constraints to satisfy:</p> <ol> <li>The upvotes and downvotes must be equal.</li> <li>You must enter the number of upvotes into the text field.</li> <li>The number of upvotes must be $numvotes.</li> </ol> </html_demo> <thumbs name='thumb'/> <textinput_demo name='vote_count' input_type='int'/> <script> # Compute the random answer. import random numvotes = random.randrange(2,5) </script> <equality_demo name='votes_equal' left='./thumb/@upvotes' right='./thumb/@downvotes'> Upvotes match downvotes </equality_demo> <equality_demo name='votes_named' left='./thumb/@upvotes' right='./vote_count/@student_input'> Number of upvotes matches entered string </equality_demo> <equality_demo name='votes_specified' left='./thumb/@upvotes' right='$numvotes'> Number of upvotes is $numvotes </equality_demo> </problem_demo> """), ("three problems 2", """ <vertical_demo> <attempts_scoreboard_demo/> <problem_demo> <html_demo><p>What is $a+$b?</p></html_demo> <textinput_demo name="sum_input" input_type="int" /> <equality_demo name="sum_checker" left="./sum_input/@student_input" right="$c" /> <script> import random a = random.randint(2, 5) b = random.randint(1, 4) c = a + b </script> </problem_demo> <sidebar_demo> <problem_demo> <html_demo><p>What is $a &#215; $b?</p></html_demo> <textinput_demo name="sum_input" input_type="int" /> <equality_demo name="sum_checker" left="./sum_input/@student_input" right="$c" /> <script> import random a = random.randint(2, 6) b = random.randint(3, 7) c = a * b </script> </problem_demo> </sidebar_demo> <problem_demo> <html_demo><p>What is $a+$b?</p></html_demo> <textinput_demo name="sum_input" input_type="int" /> <equality_demo name="sum_checker" left="./sum_input/@student_input" right="$c" /> <script> import random a = random.randint(3, 5) b = random.randint(2, 6) c = a + b </script> </problem_demo> </vertical_demo> """), ] class InputBlock(XBlock): """Base class for blocks that accept inputs. """ def submit(self, submission): """ Called with the result of the javascript Block's submit() function. Returns any data, which is passed to the Javascript handle_submit function. """ pass @XBlock.tag("checker") class CheckerBlock(XBlock): """Base class for blocks that check answers. """ arguments = Dict(help="The arguments expected by `check`") def set_arguments_from_xml(self, node): """ Set the `arguments` field from XML attributes based on `check` arguments. """ # Introspect the .check() method, and collect arguments it expects. argspec = inspect.getargspec(self.check) arguments = {} for arg in argspec.args[1:]: arguments[arg] = node.attrib.pop(arg) self.arguments = arguments @classmethod def parse_xml(cls, node, runtime, keys, id_generator): """ Parse the XML for a checker. A few arguments are handled specially, then the rest get the usual treatment. """ block = super(CheckerBlock, cls).parse_xml(node, runtime, keys, id_generator) block.set_arguments_from_xml(node) return block def check(self, **kwargs): """ Called with the data provided by the ProblemBlock. Returns any data, which will be passed to the Javascript handle_check function. """ raise NotImplementedError() class TextInputBlock(InputBlock): """An XBlock that accepts text input.""" input_type = String(help="Type of conversion to attempt on input string") student_input = Any(help="Last input submitted by the student", default="", scope=Scope.user_state) def student_view(self, context=None): # pylint: disable=W0613 """Returns default student view.""" return Fragment(u"<p>I can only appear inside problems.</p>") def problem_view(self, context=None): # pylint: disable=W0613 """Returns a view of the problem - a javascript text input field.""" html = u"<input type='text' name='input' value='{0}'><span class='message'></span>".format(self.student_input) result = Fragment(html) result.add_javascript(""" function TextInputBlock(runtime, element) { return { submit: function() { return $(element).find(':input').serializeArray(); }, handleSubmit: function(result) { $(element).find('.message').text((result || {}).error || ''); } } } """) result.initialize_js('TextInputBlock') return result def submit(self, submission): self.student_input = submission[0]['value'] if self.input_type == 'int': try: self.student_input = int(submission[0]['value']) except ValueError: return {'error': '"%s" is not an integer' % self.student_input} class EqualityCheckerBlock(CheckerBlock): """An XBlock that checks the equality of two student data fields.""" # Content: the problem will hook us up with our data. content = String(help="Message describing the equality test", scope=Scope.content, default="Equality test") # Student data left = Any(scope=Scope.user_state) right = Any(scope=Scope.user_state) attempted = Boolean(scope=Scope.user_state) def problem_view(self, context=None): """Renders the problem view. The view is specific to whether or not this problem was attempted, and, if so, if it was answered correctly. """ correct = self.left == self.right # TODO: I originally named this class="data", but that conflicted with # the CSS on the page! :( We might have to do something to namespace # things. # TODO: Should we have a way to spit out JSON islands full of data? # Note the horror of mixed Python-Javascript data below... content = string.Template(self.content).substitute(**context) result = Fragment(u""" <span class="mydata" data-attempted='{self.attempted}' data-correct='{correct}'> {content} <span class='indicator'></span> </span> """.format(self=self, content=content, correct=correct) ) # TODO: This is a runtime-specific URL. But if each XBlock ships their # own copy of underscore.js, we won't be able to uniquify them. # Perhaps runtimes can offer a palette of popular libraries so that # XBlocks can refer to them in XBlock-standard ways? result.add_javascript_url( self.runtime.resource_url("js/vendor/underscore-min.js")) # TODO: The image tag here needs a magic URL, not a hard-coded one. format_data = { 'correct': self.runtime.local_resource_url( self, 'public/images/correct-icon.png'), 'incorrect': self.runtime.local_resource_url( self, 'public/images/incorrect-icon.png'), } result.add_resource(u""" <script type="text/template" id="xblock-equality-template"> <% if (attempted !== "True") {{ %> (Not attempted) <% }} else if (correct === "True") {{ %> <img src="{correct}"> <% }} else {{ %> <img src="{incorrect}"> <% }} %> </script> """.format(**format_data), "text/html") result.add_javascript(""" function EqualityCheckerBlock(runtime, element) { var template = _.template($("#xblock-equality-template").html()); function render() { var data = $("span.mydata", element).data(); $("span.indicator", element).html(template(data)); } render(); return { handleCheck: function(result) { $("span.mydata", element) .data("correct", result ? "True" : "False") .data("attempted", "True"); render(); } } } """) result.initialize_js('EqualityCheckerBlock') return result def check(self, left, right): # pylint: disable=W0221 self.attempted = True self.left = left self.right = right event_data = {'value': 1 if left == right else 0, 'max_value': 1} self.runtime.publish(self, 'grade', event_data) return left == right class AttemptsScoreboardBlock(XBlock): """ Show attempts on problems in my nieces. """ def student_view(self, context=None): # pylint: disable=W0613 """Provide default student view.""" # Get the attempts for all problems in my parent. if self.parent: # these two lines are equivalent, and both work: attempts = list(self.runtime.query(self).parent().descendants().attr("problem_attempted")) attempts = list(self.runtime.querypath(self, "..//@problem_attempted")) num_problems = len(attempts) attempted = sum(attempts) if num_problems == 0: content = u"There are no problems here..." elif attempted == num_problems: content = u"Great! You attempted all %d problems!" % num_problems else: content = u"Hmm, you've only tried %d out of %d problems..." % (attempted, num_problems) else: content = u"I have nothing to live for! :(" return Fragment(content)
agpl-3.0
[ 624, 16467, 15398, 12, 436, 26157, 14, 199, 199, 20676, 5669, 282, 8605, 14729, 367, 8826, 3035, 1324, 1504, 199, 460, 1104, 1192, 12, 336, 16139, 10451, 315, 19604, 15217, 14, 199, 199, 2765, 1233, 365, 315, 314, 15398, 4045, 14, 199, 199, 33, 28568, 3414, 8348, 5975, 447, 2541, 699, 11415, 3279, 334, 31708, 9, 463, 23578, 334, 4718, 9, 339, 20980, 259, 6924, 258, 2670, 281, 3515, 20980, 259, 6924, 259, 2670, 281, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 11482, 342, 92, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 435, 518, 21521, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 28, 518, 11, 221, 11482, 342, 92, 4483, 1204, 260, 1204, 260, 1204, 2126, 24680, 2595, 21521, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 28, 777, 9018, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 258, 298, 1074, 2, 259, 1204, 260, 1204, 260, 1204, 2126, 435, 1444, 375, 21521, 11482, 342, 92, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 435, 518, 21521, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 28, 518, 11, 221, 1104, 342, 92, 2126, 1204, 260, 1204, 3515, 1204, 4483, 24680, 306, 21521, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 28, 777, 306, 92, 2126, 1204, 28, 1444, 32752, 260, 1204, 260, 1204, 2126, 1204, 2429, 17187, 342, 258, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 435, 518, 21521, 2429, 1799, 342, 3777, 1204, 260, 1204, 260, 1204, 2126, 24680, 2595, 21521, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 199, 199, 624, 199, 199, 646, 6485, 199, 646, 2196, 199, 646, 1059, 221, 327, 4287, 26, 3507, 29, 55, 966, 996, 199, 646, 900, 199, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 12971, 14, 955, 492, 7225, 12, 20488, 12, 2624, 12, 6184, 12, 9411, 12, 7448, 199, 504, 12971, 14, 1065, 63, 1579, 492, 1255, 63, 1579, 199, 504, 12971, 14, 7677, 492, 481, 4338, 421, 199, 533, 20980, 3142, 8, 24784, 304, 272, 408, 33, 8605, 1759, 3970, 402, 6924, 24996, 436, 2670, 1192, 14, 339, 408, 272, 2884, 275, 2624, 8, 3437, 628, 4718, 1233, 370, 4526, 1338, 401, 4194, 29, 7812, 14, 1317, 12, 849, 18413, 272, 6347, 275, 7225, 8, 3437, 628, 3883, 6347, 367, 642, 6474, 401, 4194, 29, 7812, 14, 751, 63, 929, 12, 849, 29, 16, 9, 272, 5160, 63, 30021, 275, 9411, 8, 3437, 628, 6362, 314, 6474, 22040, 642, 5160, 15583, 4194, 29, 7812, 14, 751, 63, 929, 12, 849, 29, 797, 9, 272, 965, 63, 3223, 275, 715, 339, 768, 3744, 272, 347, 2198, 63, 1652, 8, 1886, 12, 1031, 12, 8836, 12, 2883, 12, 1305, 63, 4679, 304, 267, 1853, 275, 8836, 14, 8514, 63, 11283, 63, 504, 63, 533, 8, 1886, 12, 2883, 9, 398, 327, 6668, 665, 1579, 30, 4978, 12, 7485, 3062, 1901, 2884, 1564, 14, 267, 367, 1982, 315, 1031, 26, 288, 340, 1982, 14, 1450, 508, 298, 1579, 582, 355, 1853, 14, 1579, 847, 1982, 14, 505, 288, 587, 26, 355, 1853, 14, 7726, 14, 525, 63, 932, 63, 305, 63, 1739, 8, 1457, 12, 1982, 12, 1305, 63, 4679, 9, 398, 372, 1853, 339, 347, 663, 63, 5500, 63, 5176, 8, 277, 304, 267, 408, 1084, 282, 2196, 6347, 367, 314, 6474, 880, 2985, 1924, 1172, 3365, 1325, 11982, 461, 666, 1041, 267, 327, 7529, 1133, 372, 4697, 12, 626, 1159, 314, 849, 12, 436, 314, 2070, 626, 781, 1077, 1852, 282, 892, 6347, 14, 267, 291, 14, 5176, 275, 1109, 8, 521, 14, 521, 342, 627, 5198, 9, 450, 2948, 435, 413, 339, 347, 12831, 63, 1100, 8, 277, 12, 1067, 304, 267, 408, 3917, 781, 1172, 282, 2884, 12, 1255, 652, 12, 436, 372, 314, 9183, 1067, 1041, 267, 340, 291, 14, 1579, 26, 288, 327, 3240, 379, 314, 2196, 1329, 367, 314, 6474, 288, 340, 440, 291, 14, 5176, 26, 355, 291, 14, 409, 63, 5500, 63, 5176, 342, 288, 2196, 14, 5176, 8, 277, 14, 5176, 9, 288, 2884, 63, 3643, 275, 1255, 63, 1579, 8, 277, 14, 1579, 9, 288, 1067, 275, 1211, 8, 1100, 9, 288, 1067, 14, 873, 8, 1579, 63, 3643, 9, 267, 372, 1067, 339, 327, 710, 1564, 13467, 4212, 314, 30520, 6554, 370, 10268, 7735, 272, 347, 6474, 63, 1345, 8, 277, 12, 1067, 29, 403, 304, 267, 408, 25107, 314, 849, 6474, 2455, 1041, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 1067, 275, 291, 14, 8104, 63, 1100, 8, 1100, 9, 398, 754, 275, 481, 4338, 342, 267, 4310, 63, 1739, 63, 21844, 458, 275, 942, 267, 327, 291, 14, 3223, 365, 376, 2225, 15884, 687, 12988, 828, 1685, 29387, 12, 880, 3507, 314, 267, 327, 2955, 4287, 7907, 5721, 3595, 642, 14, 267, 367, 1982, 63, 344, 315, 291, 14, 3223, 26, 221, 327, 4287, 26, 3507, 29, 37, 24827, 288, 1982, 275, 291, 14, 7726, 14, 362, 63, 1457, 8, 1739, 63, 344, 9, 288, 11101, 275, 291, 14, 7726, 14, 3352, 63, 1739, 8, 1739, 12, 298, 6462, 63, 1345, 401, 1067, 9, 288, 754, 14, 525, 63, 11255, 63, 4435, 8, 11255, 9, 288, 4310, 63, 1739, 63, 21844, 458, 14, 740, 1332, 1739, 14, 354, 12, 11101, 430, 267, 754, 14, 525, 63, 3919, 4852, 288, 1275, 6462, 469, 355, 9162, 26, 18609, 413, 5326, 327, 13997, 27, 6273, 26, 650, 5326, 27, 288, 789, 288, 7857, 267, 754, 14, 525, 63, 1317, 8, 277, 14, 7726, 14, 3352, 63, 1160, 8, 288, 298, 6462, 14, 1360, 401, 288, 4310, 63, 3223, 29, 4579, 63, 1739, 63, 21844, 458, 267, 5082, 267, 754, 14, 525, 63, 9554, 4852, 288, 805, 20980, 3142, 8, 7726, 12, 1819, 9, 469, 2234, 805, 1240, 3917, 7965, 8, 1113, 12, 4325, 9, 469, 490, 340, 334, 23426, 1559, 59, 2324, 61, 508, 283, 1593, 358, 469, 717, 372, 1559, 59, 2324, 1055, 4998, 8, 1113, 12, 8725, 14, 16141, 14, 5224, 14, 1250, 8, 4958, 12, 499 ]
[ 16467, 15398, 12, 436, 26157, 14, 199, 199, 20676, 5669, 282, 8605, 14729, 367, 8826, 3035, 1324, 1504, 199, 460, 1104, 1192, 12, 336, 16139, 10451, 315, 19604, 15217, 14, 199, 199, 2765, 1233, 365, 315, 314, 15398, 4045, 14, 199, 199, 33, 28568, 3414, 8348, 5975, 447, 2541, 699, 11415, 3279, 334, 31708, 9, 463, 23578, 334, 4718, 9, 339, 20980, 259, 6924, 258, 2670, 281, 3515, 20980, 259, 6924, 259, 2670, 281, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 11482, 342, 92, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 435, 518, 21521, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 28, 518, 11, 221, 11482, 342, 92, 4483, 1204, 260, 1204, 260, 1204, 2126, 24680, 2595, 21521, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 28, 777, 9018, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 258, 298, 1074, 2, 259, 1204, 260, 1204, 260, 1204, 2126, 435, 1444, 375, 21521, 11482, 342, 92, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 435, 518, 21521, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 28, 518, 11, 221, 1104, 342, 92, 2126, 1204, 260, 1204, 3515, 1204, 4483, 24680, 306, 21521, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 28, 777, 306, 92, 2126, 1204, 28, 1444, 32752, 260, 1204, 260, 1204, 2126, 1204, 2429, 17187, 342, 258, 1204, 4483, 1204, 260, 1204, 260, 1204, 2126, 435, 518, 21521, 2429, 1799, 342, 3777, 1204, 260, 1204, 260, 1204, 2126, 24680, 2595, 21521, 4483, 1204, 260, 1204, 260, 1204, 2126, 1204, 260, 1204, 3515, 1204, 4483, 1204, 260, 1204, 260, 1204, 199, 199, 624, 199, 199, 646, 6485, 199, 646, 2196, 199, 646, 1059, 221, 327, 4287, 26, 3507, 29, 55, 966, 996, 199, 646, 900, 199, 199, 504, 12971, 14, 1018, 492, 15398, 199, 504, 12971, 14, 955, 492, 7225, 12, 20488, 12, 2624, 12, 6184, 12, 9411, 12, 7448, 199, 504, 12971, 14, 1065, 63, 1579, 492, 1255, 63, 1579, 199, 504, 12971, 14, 7677, 492, 481, 4338, 421, 199, 533, 20980, 3142, 8, 24784, 304, 272, 408, 33, 8605, 1759, 3970, 402, 6924, 24996, 436, 2670, 1192, 14, 339, 408, 272, 2884, 275, 2624, 8, 3437, 628, 4718, 1233, 370, 4526, 1338, 401, 4194, 29, 7812, 14, 1317, 12, 849, 18413, 272, 6347, 275, 7225, 8, 3437, 628, 3883, 6347, 367, 642, 6474, 401, 4194, 29, 7812, 14, 751, 63, 929, 12, 849, 29, 16, 9, 272, 5160, 63, 30021, 275, 9411, 8, 3437, 628, 6362, 314, 6474, 22040, 642, 5160, 15583, 4194, 29, 7812, 14, 751, 63, 929, 12, 849, 29, 797, 9, 272, 965, 63, 3223, 275, 715, 339, 768, 3744, 272, 347, 2198, 63, 1652, 8, 1886, 12, 1031, 12, 8836, 12, 2883, 12, 1305, 63, 4679, 304, 267, 1853, 275, 8836, 14, 8514, 63, 11283, 63, 504, 63, 533, 8, 1886, 12, 2883, 9, 398, 327, 6668, 665, 1579, 30, 4978, 12, 7485, 3062, 1901, 2884, 1564, 14, 267, 367, 1982, 315, 1031, 26, 288, 340, 1982, 14, 1450, 508, 298, 1579, 582, 355, 1853, 14, 1579, 847, 1982, 14, 505, 288, 587, 26, 355, 1853, 14, 7726, 14, 525, 63, 932, 63, 305, 63, 1739, 8, 1457, 12, 1982, 12, 1305, 63, 4679, 9, 398, 372, 1853, 339, 347, 663, 63, 5500, 63, 5176, 8, 277, 304, 267, 408, 1084, 282, 2196, 6347, 367, 314, 6474, 880, 2985, 1924, 1172, 3365, 1325, 11982, 461, 666, 1041, 267, 327, 7529, 1133, 372, 4697, 12, 626, 1159, 314, 849, 12, 436, 314, 2070, 626, 781, 1077, 1852, 282, 892, 6347, 14, 267, 291, 14, 5176, 275, 1109, 8, 521, 14, 521, 342, 627, 5198, 9, 450, 2948, 435, 413, 339, 347, 12831, 63, 1100, 8, 277, 12, 1067, 304, 267, 408, 3917, 781, 1172, 282, 2884, 12, 1255, 652, 12, 436, 372, 314, 9183, 1067, 1041, 267, 340, 291, 14, 1579, 26, 288, 327, 3240, 379, 314, 2196, 1329, 367, 314, 6474, 288, 340, 440, 291, 14, 5176, 26, 355, 291, 14, 409, 63, 5500, 63, 5176, 342, 288, 2196, 14, 5176, 8, 277, 14, 5176, 9, 288, 2884, 63, 3643, 275, 1255, 63, 1579, 8, 277, 14, 1579, 9, 288, 1067, 275, 1211, 8, 1100, 9, 288, 1067, 14, 873, 8, 1579, 63, 3643, 9, 267, 372, 1067, 339, 327, 710, 1564, 13467, 4212, 314, 30520, 6554, 370, 10268, 7735, 272, 347, 6474, 63, 1345, 8, 277, 12, 1067, 29, 403, 304, 267, 408, 25107, 314, 849, 6474, 2455, 1041, 267, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 1067, 275, 291, 14, 8104, 63, 1100, 8, 1100, 9, 398, 754, 275, 481, 4338, 342, 267, 4310, 63, 1739, 63, 21844, 458, 275, 942, 267, 327, 291, 14, 3223, 365, 376, 2225, 15884, 687, 12988, 828, 1685, 29387, 12, 880, 3507, 314, 267, 327, 2955, 4287, 7907, 5721, 3595, 642, 14, 267, 367, 1982, 63, 344, 315, 291, 14, 3223, 26, 221, 327, 4287, 26, 3507, 29, 37, 24827, 288, 1982, 275, 291, 14, 7726, 14, 362, 63, 1457, 8, 1739, 63, 344, 9, 288, 11101, 275, 291, 14, 7726, 14, 3352, 63, 1739, 8, 1739, 12, 298, 6462, 63, 1345, 401, 1067, 9, 288, 754, 14, 525, 63, 11255, 63, 4435, 8, 11255, 9, 288, 4310, 63, 1739, 63, 21844, 458, 14, 740, 1332, 1739, 14, 354, 12, 11101, 430, 267, 754, 14, 525, 63, 3919, 4852, 288, 1275, 6462, 469, 355, 9162, 26, 18609, 413, 5326, 327, 13997, 27, 6273, 26, 650, 5326, 27, 288, 789, 288, 7857, 267, 754, 14, 525, 63, 1317, 8, 277, 14, 7726, 14, 3352, 63, 1160, 8, 288, 298, 6462, 14, 1360, 401, 288, 4310, 63, 3223, 29, 4579, 63, 1739, 63, 21844, 458, 267, 5082, 267, 754, 14, 525, 63, 9554, 4852, 288, 805, 20980, 3142, 8, 7726, 12, 1819, 9, 469, 2234, 805, 1240, 3917, 7965, 8, 1113, 12, 4325, 9, 469, 490, 340, 334, 23426, 1559, 59, 2324, 61, 508, 283, 1593, 358, 469, 717, 372, 1559, 59, 2324, 1055, 4998, 8, 1113, 12, 8725, 14, 16141, 14, 5224, 14, 1250, 8, 4958, 12, 499, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
163gal/Time-Line
specs/Backend.py
2
2029
# Copyright (C) 2009, 2010, 2011 Rickard Lindberg, Roger Lindberg # # This file is part of Timeline. # # Timeline 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. # # Timeline 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 Timeline. If not, see <http://www.gnu.org/licenses/>. import unittest from specs.utils import TmpDirTestCase from timelinelib.db.backends.ics import IcsTimeline from timelinelib.db.backends.memory import MemoryDB class BackendTest(object): # These tests should work for any backend. They are tested with different # backends below. def test_get_all_events_returns_a_list(self): all_events = self.backend.get_all_events() self.assertTrue(isinstance(all_events, list)) def test_has_time_type_method(self): self.backend.get_time_type() class MemoryBackendTest(unittest.TestCase, BackendTest): def setUp(self): self.backend = MemoryDB() class IcsBackendTest(TmpDirTestCase, BackendTest): def setUp(self): TmpDirTestCase.setUp(self) self.backend = IcsTimeline(self.write_ics_content()) def write_ics_content(self): tmp_path = self.get_tmp_path("test.ics") f = open(tmp_path, "w") f.write(ICS_EXAMPLE) f.close() return tmp_path ICS_EXAMPLE = """ BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN BEGIN:VEVENT UID:uid1@example.com DTSTAMP:19970714T170000Z ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com DTSTART:19970714T170000Z DTEND:19970715T035959Z SUMMARY:Bastille Day Party END:VEVENT END:VCALENDAR """
gpl-3.0
[ 3, 1898, 334, 35, 9, 8937, 12, 7129, 12, 7760, 221, 820, 2000, 1005, 491, 688, 14630, 12, 6848, 836, 491, 688, 14630, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 4703, 604, 14, 199, 3, 199, 3, 4703, 604, 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, 4703, 604, 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, 4703, 604, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2882, 199, 199, 504, 15941, 14, 1208, 492, 377, 311, 3567, 1746, 199, 504, 20780, 773, 14, 697, 14, 7765, 14, 2932, 492, 473, 1259, 27097, 199, 504, 20780, 773, 14, 697, 14, 7765, 14, 4844, 492, 15825, 2846, 421, 199, 533, 25674, 774, 8, 785, 304, 339, 327, 5723, 2295, 1077, 1736, 367, 1263, 4865, 14, 9322, 787, 12470, 543, 3365, 272, 327, 14745, 5084, 14, 339, 347, 511, 63, 362, 63, 452, 63, 4368, 63, 5808, 63, 65, 63, 513, 8, 277, 304, 267, 1006, 63, 4368, 275, 291, 14, 4620, 14, 362, 63, 452, 63, 4368, 342, 267, 291, 14, 1815, 8, 6074, 8, 452, 63, 4368, 12, 769, 430, 339, 347, 511, 63, 1989, 63, 521, 63, 466, 63, 765, 8, 277, 304, 267, 291, 14, 4620, 14, 362, 63, 521, 63, 466, 342, 421, 199, 533, 15825, 8447, 774, 8, 2796, 14, 1746, 12, 25674, 774, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4620, 275, 15825, 2846, 342, 421, 199, 533, 473, 1259, 8447, 774, 8, 52, 311, 3567, 1746, 12, 25674, 774, 304, 339, 347, 3613, 8, 277, 304, 267, 377, 311, 3567, 1746, 14, 5996, 8, 277, 9, 267, 291, 14, 4620, 275, 473, 1259, 27097, 8, 277, 14, 952, 63, 2932, 63, 1317, 1012, 339, 347, 2218, 63, 2932, 63, 1317, 8, 277, 304, 267, 3529, 63, 515, 275, 291, 14, 362, 63, 2791, 63, 515, 480, 396, 14, 2932, 531, 267, 289, 275, 1551, 8, 2791, 63, 515, 12, 298, 87, 531, 267, 289, 14, 952, 8, 21174, 63, 26900, 9, 267, 289, 14, 1600, 342, 267, 372, 3529, 63, 515, 421, 199, 21174, 63, 26900, 275, 408, 199, 15947, 26, 9454, 748, 3902, 689, 199, 4612, 26, 18, 14, 16, 199, 2514, 36, 998, 6809, 501, 20875, 3519, 15, 6868, 915, 501, 13887, 4254, 1698, 373, 17, 14, 16, 501, 742, 199, 15947, 26, 2524, 4554, 199, 6685, 26, 1535, 17, 32, 2694, 14, 957, 199, 7438, 840, 7089, 26, 7155, 15378, 1079, 52, 1196, 993, 58, 199, 25797, 879, 5357, 540, 27, 12874, 29, 12923, 30795, 26, 8175, 2566, 26, 20216, 14, 1117, 69, 32, 2694, 14, 957, 199, 7438, 7363, 26, 7155, 15378, 1079, 52, 1196, 993, 58, 199, 7438, 3902, 26, 7155, 15378, 1046, 52, 16, 11444, 1427, 58, 199, 29508, 26, 34, 1810, 17142, 28358, 2235, 369, 199, 3902, 26, 2524, 4554, 199, 3902, 26, 9454, 748, 3902, 689, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 8937, 12, 7129, 12, 7760, 221, 820, 2000, 1005, 491, 688, 14630, 12, 6848, 836, 491, 688, 14630, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 4703, 604, 14, 199, 3, 199, 3, 4703, 604, 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, 4703, 604, 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, 4703, 604, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 421, 199, 646, 2882, 199, 199, 504, 15941, 14, 1208, 492, 377, 311, 3567, 1746, 199, 504, 20780, 773, 14, 697, 14, 7765, 14, 2932, 492, 473, 1259, 27097, 199, 504, 20780, 773, 14, 697, 14, 7765, 14, 4844, 492, 15825, 2846, 421, 199, 533, 25674, 774, 8, 785, 304, 339, 327, 5723, 2295, 1077, 1736, 367, 1263, 4865, 14, 9322, 787, 12470, 543, 3365, 272, 327, 14745, 5084, 14, 339, 347, 511, 63, 362, 63, 452, 63, 4368, 63, 5808, 63, 65, 63, 513, 8, 277, 304, 267, 1006, 63, 4368, 275, 291, 14, 4620, 14, 362, 63, 452, 63, 4368, 342, 267, 291, 14, 1815, 8, 6074, 8, 452, 63, 4368, 12, 769, 430, 339, 347, 511, 63, 1989, 63, 521, 63, 466, 63, 765, 8, 277, 304, 267, 291, 14, 4620, 14, 362, 63, 521, 63, 466, 342, 421, 199, 533, 15825, 8447, 774, 8, 2796, 14, 1746, 12, 25674, 774, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 4620, 275, 15825, 2846, 342, 421, 199, 533, 473, 1259, 8447, 774, 8, 52, 311, 3567, 1746, 12, 25674, 774, 304, 339, 347, 3613, 8, 277, 304, 267, 377, 311, 3567, 1746, 14, 5996, 8, 277, 9, 267, 291, 14, 4620, 275, 473, 1259, 27097, 8, 277, 14, 952, 63, 2932, 63, 1317, 1012, 339, 347, 2218, 63, 2932, 63, 1317, 8, 277, 304, 267, 3529, 63, 515, 275, 291, 14, 362, 63, 2791, 63, 515, 480, 396, 14, 2932, 531, 267, 289, 275, 1551, 8, 2791, 63, 515, 12, 298, 87, 531, 267, 289, 14, 952, 8, 21174, 63, 26900, 9, 267, 289, 14, 1600, 342, 267, 372, 3529, 63, 515, 421, 199, 21174, 63, 26900, 275, 408, 199, 15947, 26, 9454, 748, 3902, 689, 199, 4612, 26, 18, 14, 16, 199, 2514, 36, 998, 6809, 501, 20875, 3519, 15, 6868, 915, 501, 13887, 4254, 1698, 373, 17, 14, 16, 501, 742, 199, 15947, 26, 2524, 4554, 199, 6685, 26, 1535, 17, 32, 2694, 14, 957, 199, 7438, 840, 7089, 26, 7155, 15378, 1079, 52, 1196, 993, 58, 199, 25797, 879, 5357, 540, 27, 12874, 29, 12923, 30795, 26, 8175, 2566, 26, 20216, 14, 1117, 69, 32, 2694, 14, 957, 199, 7438, 7363, 26, 7155, 15378, 1079, 52, 1196, 993, 58, 199, 7438, 3902, 26, 7155, 15378, 1046, 52, 16, 11444, 1427, 58, 199, 29508, 26, 34, 1810, 17142, 28358, 2235, 369, 199, 3902, 26, 2524, 4554, 199, 3902, 26, 9454, 748, 3902, 689, 199, 624, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Kraxi/YTplaylist
venv/Lib/site-packages/flask/testsuite/config.py
556
11820
# -*- coding: utf-8 -*- """ flask.testsuite.config ~~~~~~~~~~~~~~~~~~~~~~ Configuration and instances. :copyright: (c) 2011 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ import os import sys import flask import pkgutil import unittest from contextlib import contextmanager from flask.testsuite import FlaskTestCase # config keys used for the ConfigTestCase TEST_KEY = 'foo' SECRET_KEY = 'devkey' class ConfigTestCase(FlaskTestCase): def common_object_test(self, app): self.assert_equal(app.secret_key, 'devkey') self.assert_equal(app.config['TEST_KEY'], 'foo') self.assert_not_in('ConfigTestCase', app.config) def test_config_from_file(self): app = flask.Flask(__name__) app.config.from_pyfile(__file__.rsplit('.', 1)[0] + '.py') self.common_object_test(app) def test_config_from_object(self): app = flask.Flask(__name__) app.config.from_object(__name__) self.common_object_test(app) def test_config_from_class(self): class Base(object): TEST_KEY = 'foo' class Test(Base): SECRET_KEY = 'devkey' app = flask.Flask(__name__) app.config.from_object(Test) self.common_object_test(app) def test_config_from_envvar(self): env = os.environ try: os.environ = {} app = flask.Flask(__name__) try: app.config.from_envvar('FOO_SETTINGS') except RuntimeError as e: self.assert_true("'FOO_SETTINGS' is not set" in str(e)) else: self.assert_true(0, 'expected exception') self.assert_false(app.config.from_envvar('FOO_SETTINGS', silent=True)) os.environ = {'FOO_SETTINGS': __file__.rsplit('.', 1)[0] + '.py'} self.assert_true(app.config.from_envvar('FOO_SETTINGS')) self.common_object_test(app) finally: os.environ = env def test_config_from_envvar_missing(self): env = os.environ try: os.environ = {'FOO_SETTINGS': 'missing.cfg'} try: app = flask.Flask(__name__) app.config.from_envvar('FOO_SETTINGS') except IOError as e: msg = str(e) self.assert_true(msg.startswith('[Errno 2] Unable to load configuration ' 'file (No such file or directory):')) self.assert_true(msg.endswith("missing.cfg'")) else: self.fail('expected IOError') self.assertFalse(app.config.from_envvar('FOO_SETTINGS', silent=True)) finally: os.environ = env def test_config_missing(self): app = flask.Flask(__name__) try: app.config.from_pyfile('missing.cfg') except IOError as e: msg = str(e) self.assert_true(msg.startswith('[Errno 2] Unable to load configuration ' 'file (No such file or directory):')) self.assert_true(msg.endswith("missing.cfg'")) else: self.assert_true(0, 'expected config') self.assert_false(app.config.from_pyfile('missing.cfg', silent=True)) def test_session_lifetime(self): app = flask.Flask(__name__) app.config['PERMANENT_SESSION_LIFETIME'] = 42 self.assert_equal(app.permanent_session_lifetime.seconds, 42) class LimitedLoaderMockWrapper(object): def __init__(self, loader): self.loader = loader def __getattr__(self, name): if name in ('archive', 'get_filename'): msg = 'Mocking a loader which does not have `%s.`' % name raise AttributeError(msg) return getattr(self.loader, name) @contextmanager def patch_pkgutil_get_loader(wrapper_class=LimitedLoaderMockWrapper): """Patch pkgutil.get_loader to give loader without get_filename or archive. This provides for tests where a system has custom loaders, e.g. Google App Engine's HardenedModulesHook, which have neither the `get_filename` method nor the `archive` attribute. """ old_get_loader = pkgutil.get_loader def get_loader(*args, **kwargs): return wrapper_class(old_get_loader(*args, **kwargs)) try: pkgutil.get_loader = get_loader yield finally: pkgutil.get_loader = old_get_loader class InstanceTestCase(FlaskTestCase): def test_explicit_instance_paths(self): here = os.path.abspath(os.path.dirname(__file__)) try: flask.Flask(__name__, instance_path='instance') except ValueError as e: self.assert_in('must be absolute', str(e)) else: self.fail('Expected value error') app = flask.Flask(__name__, instance_path=here) self.assert_equal(app.instance_path, here) def test_main_module_paths(self): # Test an app with '__main__' as the import name, uses cwd. from main_app import app here = os.path.abspath(os.getcwd()) self.assert_equal(app.instance_path, os.path.join(here, 'instance')) if 'main_app' in sys.modules: del sys.modules['main_app'] def test_uninstalled_module_paths(self): from config_module_app import app here = os.path.abspath(os.path.dirname(__file__)) self.assert_equal(app.instance_path, os.path.join(here, 'test_apps', 'instance')) def test_uninstalled_package_paths(self): from config_package_app import app here = os.path.abspath(os.path.dirname(__file__)) self.assert_equal(app.instance_path, os.path.join(here, 'test_apps', 'instance')) def test_installed_module_paths(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix site_packages = os.path.join(expected_prefix, 'lib', 'python2.5', 'site-packages') sys.path.append(site_packages) try: import site_app self.assert_equal(site_app.app.instance_path, os.path.join(expected_prefix, 'var', 'site_app-instance')) finally: sys.prefix = real_prefix sys.path.remove(site_packages) if 'site_app' in sys.modules: del sys.modules['site_app'] def test_installed_module_paths_with_limited_loader(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix site_packages = os.path.join(expected_prefix, 'lib', 'python2.5', 'site-packages') sys.path.append(site_packages) with patch_pkgutil_get_loader(): try: import site_app self.assert_equal(site_app.app.instance_path, os.path.join(expected_prefix, 'var', 'site_app-instance')) finally: sys.prefix = real_prefix sys.path.remove(site_packages) if 'site_app' in sys.modules: del sys.modules['site_app'] def test_installed_package_paths(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix installed_path = os.path.join(expected_prefix, 'path') sys.path.append(installed_path) try: import installed_package self.assert_equal(installed_package.app.instance_path, os.path.join(expected_prefix, 'var', 'installed_package-instance')) finally: sys.prefix = real_prefix sys.path.remove(installed_path) if 'installed_package' in sys.modules: del sys.modules['installed_package'] def test_installed_package_paths_with_limited_loader(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix installed_path = os.path.join(expected_prefix, 'path') sys.path.append(installed_path) with patch_pkgutil_get_loader(): try: import installed_package self.assert_equal(installed_package.app.instance_path, os.path.join(expected_prefix, 'var', 'installed_package-instance')) finally: sys.prefix = real_prefix sys.path.remove(installed_path) if 'installed_package' in sys.modules: del sys.modules['installed_package'] def test_prefix_package_paths(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix site_packages = os.path.join(expected_prefix, 'lib', 'python2.5', 'site-packages') sys.path.append(site_packages) try: import site_package self.assert_equal(site_package.app.instance_path, os.path.join(expected_prefix, 'var', 'site_package-instance')) finally: sys.prefix = real_prefix sys.path.remove(site_packages) if 'site_package' in sys.modules: del sys.modules['site_package'] def test_prefix_package_paths_with_limited_loader(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix site_packages = os.path.join(expected_prefix, 'lib', 'python2.5', 'site-packages') sys.path.append(site_packages) with patch_pkgutil_get_loader(): try: import site_package self.assert_equal(site_package.app.instance_path, os.path.join(expected_prefix, 'var', 'site_package-instance')) finally: sys.prefix = real_prefix sys.path.remove(site_packages) if 'site_package' in sys.modules: del sys.modules['site_package'] def test_egg_installed_paths(self): here = os.path.abspath(os.path.dirname(__file__)) expected_prefix = os.path.join(here, 'test_apps') real_prefix, sys.prefix = sys.prefix, expected_prefix site_packages = os.path.join(expected_prefix, 'lib', 'python2.5', 'site-packages') egg_path = os.path.join(site_packages, 'SiteEgg.egg') sys.path.append(site_packages) sys.path.append(egg_path) try: import site_egg # in SiteEgg.egg self.assert_equal(site_egg.app.instance_path, os.path.join(expected_prefix, 'var', 'site_egg-instance')) finally: sys.prefix = real_prefix sys.path.remove(site_packages) sys.path.remove(egg_path) if 'site_egg' in sys.modules: del sys.modules['site_egg'] def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(ConfigTestCase)) suite.addTest(unittest.makeSuite(InstanceTestCase)) return suite
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 14239, 14, 888, 272, 18294, 2878, 1714, 339, 11595, 436, 4454, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 7209, 199, 646, 28728, 199, 646, 2882, 199, 504, 15502, 492, 27608, 199, 504, 7209, 14, 14239, 492, 16704, 1746, 421, 199, 3, 1101, 2883, 1202, 367, 314, 4094, 1746, 199, 2864, 63, 3078, 275, 283, 1421, 7, 199, 12961, 63, 3078, 275, 283, 2374, 498, 7, 421, 199, 533, 4094, 1746, 8, 14182, 1746, 304, 339, 347, 2863, 63, 785, 63, 396, 8, 277, 12, 1145, 304, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 4731, 63, 498, 12, 283, 2374, 498, 358, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 888, 459, 2864, 63, 3078, 995, 283, 1421, 358, 267, 291, 14, 479, 63, 1397, 63, 262, 360, 2028, 1746, 297, 1145, 14, 888, 9, 339, 347, 511, 63, 888, 63, 504, 63, 493, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 14792, 3460, 493, 4343, 13490, 14078, 413, 2788, 16, 61, 435, 1987, 647, 358, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 785, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 785, 3460, 354, 3368, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 533, 8, 277, 304, 267, 1021, 3523, 8, 785, 304, 288, 7393, 63, 3078, 275, 283, 1421, 7, 267, 1021, 1379, 8, 1563, 304, 288, 5795, 11771, 63, 3078, 275, 283, 2374, 498, 7, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 785, 8, 774, 9, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 1813, 1391, 8, 277, 304, 267, 2589, 275, 747, 14, 2314, 267, 862, 26, 288, 747, 14, 2314, 275, 1052, 288, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 288, 862, 26, 355, 1145, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 358, 288, 871, 6064, 465, 325, 26, 355, 291, 14, 479, 63, 2052, 15587, 13046, 63, 13931, 7, 365, 440, 663, 2, 315, 620, 8, 69, 430, 288, 587, 26, 355, 291, 14, 479, 63, 2052, 8, 16, 12, 283, 2062, 1919, 358, 288, 291, 14, 479, 63, 3910, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 297, 10866, 29, 549, 430, 953, 747, 14, 2314, 275, 791, 13046, 63, 13931, 356, 636, 493, 4343, 13490, 14078, 413, 2788, 16, 61, 435, 1987, 647, 936, 288, 291, 14, 479, 63, 2052, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 1333, 288, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 267, 3753, 26, 288, 747, 14, 2314, 275, 2589, 339, 347, 511, 63, 888, 63, 504, 63, 1813, 1391, 63, 4752, 8, 277, 304, 267, 2589, 275, 747, 14, 2314, 267, 862, 26, 288, 747, 14, 2314, 275, 791, 13046, 63, 13931, 356, 283, 4752, 14, 4128, 936, 288, 862, 26, 355, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 355, 1145, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 358, 288, 871, 5925, 465, 325, 26, 355, 1499, 275, 620, 8, 69, 9, 355, 291, 14, 479, 63, 2052, 8, 1328, 14, 2460, 11894, 23288, 499, 61, 30849, 370, 2248, 2897, 283, 4490, 283, 493, 334, 1944, 4066, 570, 503, 2082, 304, 1333, 355, 291, 14, 479, 63, 2052, 8, 1328, 14, 4130, 480, 4752, 14, 4128, 7, 2237, 288, 587, 26, 355, 291, 14, 1633, 360, 2062, 5925, 358, 288, 291, 14, 3334, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 297, 10866, 29, 549, 430, 267, 3753, 26, 288, 747, 14, 2314, 275, 2589, 339, 347, 511, 63, 888, 63, 4752, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 862, 26, 288, 1145, 14, 888, 14, 504, 63, 14792, 360, 4752, 14, 4128, 358, 267, 871, 5925, 465, 325, 26, 288, 1499, 275, 620, 8, 69, 9, 288, 291, 14, 479, 63, 2052, 8, 1328, 14, 2460, 11894, 23288, 499, 61, 30849, 370, 2248, 2897, 283, 3147, 283, 493, 334, 1944, 4066, 570, 503, 2082, 304, 1333, 288, 291, 14, 479, 63, 2052, 8, 1328, 14, 4130, 480, 4752, 14, 4128, 7, 2237, 267, 587, 26, 288, 291, 14, 479, 63, 2052, 8, 16, 12, 283, 2062, 1101, 358, 267, 291, 14, 479, 63, 3910, 8, 571, 14, 888, 14, 504, 63, 14792, 360, 4752, 14, 4128, 297, 10866, 29, 549, 430, 339, 347, 511, 63, 1730, 63, 27674, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 459, 4227, 6588, 1309, 63, 12763, 63, 2673, 38, 10931, 418, 275, 5685, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 19904, 63, 1730, 63, 27674, 14, 4515, 12, 5685, 9, 421, 199, 533, 23954, 5455, 3346, 4590, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5077, 304, 267, 291, 14, 3422, 275, 5077, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 315, 661, 6404, 297, 283, 362, 63, 1501, 735, 288, 1499, 275, 283, 3346, 316, 282, 5077, 1314, 1630, 440, 1172, 18633, 83, 14, 19097, 450, 536, 288, 746, 4281, 8, 1328, 9, 267, 372, 2519, 8, 277, 14, 3422, 12, 536, 9, 421, 199, 32, 14237, 199, 318, 3371, 63, 4600, 1974, 63, 362, 63, 3422, 8, 5029, 63, 533, 29, 7219, 5703, 5455, 3346, 4590, 304, 272, 408, 11173, 28728, 14, 362, 63, 3422, 370, 8120, 5077, 1928, 664, 63, 1501, 503, 6359, 14, 339, 961, 6571, 367, 2295, 2382, 282, 2656, 965, 3537, 25520, 12, 325, 14 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 7209, 14, 14239, 14, 888, 272, 18294, 2878, 1714, 339, 11595, 436, 4454, 14, 339, 520, 7307, 26, 334, 67, 9, 7760, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 199, 646, 747, 199, 646, 984, 199, 646, 7209, 199, 646, 28728, 199, 646, 2882, 199, 504, 15502, 492, 27608, 199, 504, 7209, 14, 14239, 492, 16704, 1746, 421, 199, 3, 1101, 2883, 1202, 367, 314, 4094, 1746, 199, 2864, 63, 3078, 275, 283, 1421, 7, 199, 12961, 63, 3078, 275, 283, 2374, 498, 7, 421, 199, 533, 4094, 1746, 8, 14182, 1746, 304, 339, 347, 2863, 63, 785, 63, 396, 8, 277, 12, 1145, 304, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 4731, 63, 498, 12, 283, 2374, 498, 358, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 888, 459, 2864, 63, 3078, 995, 283, 1421, 358, 267, 291, 14, 479, 63, 1397, 63, 262, 360, 2028, 1746, 297, 1145, 14, 888, 9, 339, 347, 511, 63, 888, 63, 504, 63, 493, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 14792, 3460, 493, 4343, 13490, 14078, 413, 2788, 16, 61, 435, 1987, 647, 358, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 785, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 785, 3460, 354, 3368, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 533, 8, 277, 304, 267, 1021, 3523, 8, 785, 304, 288, 7393, 63, 3078, 275, 283, 1421, 7, 267, 1021, 1379, 8, 1563, 304, 288, 5795, 11771, 63, 3078, 275, 283, 2374, 498, 7, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 14, 504, 63, 785, 8, 774, 9, 267, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 339, 347, 511, 63, 888, 63, 504, 63, 1813, 1391, 8, 277, 304, 267, 2589, 275, 747, 14, 2314, 267, 862, 26, 288, 747, 14, 2314, 275, 1052, 288, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 288, 862, 26, 355, 1145, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 358, 288, 871, 6064, 465, 325, 26, 355, 291, 14, 479, 63, 2052, 15587, 13046, 63, 13931, 7, 365, 440, 663, 2, 315, 620, 8, 69, 430, 288, 587, 26, 355, 291, 14, 479, 63, 2052, 8, 16, 12, 283, 2062, 1919, 358, 288, 291, 14, 479, 63, 3910, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 297, 10866, 29, 549, 430, 953, 747, 14, 2314, 275, 791, 13046, 63, 13931, 356, 636, 493, 4343, 13490, 14078, 413, 2788, 16, 61, 435, 1987, 647, 936, 288, 291, 14, 479, 63, 2052, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 1333, 288, 291, 14, 2330, 63, 785, 63, 396, 8, 571, 9, 267, 3753, 26, 288, 747, 14, 2314, 275, 2589, 339, 347, 511, 63, 888, 63, 504, 63, 1813, 1391, 63, 4752, 8, 277, 304, 267, 2589, 275, 747, 14, 2314, 267, 862, 26, 288, 747, 14, 2314, 275, 791, 13046, 63, 13931, 356, 283, 4752, 14, 4128, 936, 288, 862, 26, 355, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 355, 1145, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 358, 288, 871, 5925, 465, 325, 26, 355, 1499, 275, 620, 8, 69, 9, 355, 291, 14, 479, 63, 2052, 8, 1328, 14, 2460, 11894, 23288, 499, 61, 30849, 370, 2248, 2897, 283, 4490, 283, 493, 334, 1944, 4066, 570, 503, 2082, 304, 1333, 355, 291, 14, 479, 63, 2052, 8, 1328, 14, 4130, 480, 4752, 14, 4128, 7, 2237, 288, 587, 26, 355, 291, 14, 1633, 360, 2062, 5925, 358, 288, 291, 14, 3334, 8, 571, 14, 888, 14, 504, 63, 1813, 1391, 360, 13046, 63, 13931, 297, 10866, 29, 549, 430, 267, 3753, 26, 288, 747, 14, 2314, 275, 2589, 339, 347, 511, 63, 888, 63, 4752, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 862, 26, 288, 1145, 14, 888, 14, 504, 63, 14792, 360, 4752, 14, 4128, 358, 267, 871, 5925, 465, 325, 26, 288, 1499, 275, 620, 8, 69, 9, 288, 291, 14, 479, 63, 2052, 8, 1328, 14, 2460, 11894, 23288, 499, 61, 30849, 370, 2248, 2897, 283, 3147, 283, 493, 334, 1944, 4066, 570, 503, 2082, 304, 1333, 288, 291, 14, 479, 63, 2052, 8, 1328, 14, 4130, 480, 4752, 14, 4128, 7, 2237, 267, 587, 26, 288, 291, 14, 479, 63, 2052, 8, 16, 12, 283, 2062, 1101, 358, 267, 291, 14, 479, 63, 3910, 8, 571, 14, 888, 14, 504, 63, 14792, 360, 4752, 14, 4128, 297, 10866, 29, 549, 430, 339, 347, 511, 63, 1730, 63, 27674, 8, 277, 304, 267, 1145, 275, 7209, 14, 14182, 3460, 354, 3368, 267, 1145, 14, 888, 459, 4227, 6588, 1309, 63, 12763, 63, 2673, 38, 10931, 418, 275, 5685, 267, 291, 14, 479, 63, 1452, 8, 571, 14, 19904, 63, 1730, 63, 27674, 14, 4515, 12, 5685, 9, 421, 199, 533, 23954, 5455, 3346, 4590, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 5077, 304, 267, 291, 14, 3422, 275, 5077, 339, 347, 636, 5675, 721, 277, 12, 536, 304, 267, 340, 536, 315, 661, 6404, 297, 283, 362, 63, 1501, 735, 288, 1499, 275, 283, 3346, 316, 282, 5077, 1314, 1630, 440, 1172, 18633, 83, 14, 19097, 450, 536, 288, 746, 4281, 8, 1328, 9, 267, 372, 2519, 8, 277, 14, 3422, 12, 536, 9, 421, 199, 32, 14237, 199, 318, 3371, 63, 4600, 1974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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dsfsdgsbngfggb/odoo
addons/account/wizard/account_move_line_select.py
385
2800
# -*- 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 osv class account_move_line_select(osv.osv_memory): """ Account move line select """ _name = "account.move.line.select" _description = "Account move line select" def open_window(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') account_obj = self.pool.get('account.account') fiscalyear_obj = self.pool.get('account.fiscalyear') if context is None: context = {} if 'fiscalyear' not in context: fiscalyear_ids = fiscalyear_obj.search(cr, uid, [('state', '=', 'draft')]) else: fiscalyear_ids = [context['fiscalyear']] fiscalyears = fiscalyear_obj.browse(cr, uid, fiscalyear_ids, context=context) period_ids = [] if fiscalyears: for fiscalyear in fiscalyears: for period in fiscalyear.period_ids: period_ids.append(period.id) domain = str(('period_id', 'in', period_ids)) result = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_line_tree1') id = result and result[1] or False result = act_obj.read(cr, uid, [id])[0] result['context'] = { 'fiscalyear': False, 'account_id': context['active_id'], 'active_id': context['active_id'], } if context['active_id']: acc_data = account_obj.browse(cr, uid, context['active_id']).child_consol_ids if acc_data: result['context'].update({'consolidate_children': True}) result['domain']=result['domain'][0:-1]+','+domain+result['domain'][-1] return result # 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, 9506, 199, 199, 533, 2933, 63, 1185, 63, 604, 63, 2416, 8, 4795, 14, 4795, 63, 4844, 304, 272, 408, 267, 9973, 4057, 1004, 3504, 272, 408, 272, 485, 354, 275, 298, 2048, 14, 1185, 14, 604, 14, 2416, 2, 272, 485, 1802, 275, 298, 6009, 4057, 1004, 3504, 2, 339, 347, 1551, 63, 3806, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 3413, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 267, 2454, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 2442, 63, 3806, 358, 267, 2933, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 358, 267, 18672, 3403, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 21260, 358, 398, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 340, 283, 21260, 7, 440, 315, 1067, 26, 288, 18672, 3403, 63, 1580, 275, 18672, 3403, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 297, 6291, 283, 7185, 2023, 267, 587, 26, 288, 18672, 3403, 63, 1580, 275, 359, 1100, 459, 21260, 6538, 398, 18672, 18431, 275, 18672, 3403, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 18672, 3403, 63, 1580, 12, 1067, 29, 1100, 9, 398, 6247, 63, 1580, 275, 942, 267, 340, 18672, 18431, 26, 288, 367, 18672, 3403, 315, 18672, 18431, 26, 355, 367, 6247, 315, 18672, 3403, 14, 5191, 63, 1580, 26, 490, 6247, 63, 1580, 14, 740, 8, 5191, 14, 344, 9, 288, 2881, 275, 620, 4725, 5191, 63, 344, 297, 283, 262, 297, 6247, 63, 1580, 430, 398, 754, 275, 3413, 63, 1113, 14, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 297, 283, 1287, 63, 1185, 63, 604, 63, 2350, 17, 358, 267, 1305, 275, 754, 436, 754, 59, 17, 61, 503, 756, 267, 754, 275, 2454, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 344, 11057, 16, 61, 267, 754, 459, 1100, 418, 275, 469, 288, 283, 21260, 356, 756, 12, 288, 283, 2048, 63, 344, 356, 1067, 459, 2682, 63, 344, 995, 288, 283, 2682, 63, 344, 356, 1067, 459, 2682, 63, 344, 995, 267, 789, 398, 340, 1067, 459, 2682, 63, 344, 2565, 288, 6907, 63, 576, 275, 2933, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 1067, 459, 2682, 63, 344, 13227, 1739, 63, 388, 7873, 63, 1580, 288, 340, 6907, 63, 576, 26, 355, 754, 459, 1100, 2278, 873, 3252, 388, 28335, 602, 63, 3223, 356, 715, 1552, 267, 754, 459, 2261, 13784, 1099, 459, 2261, 3488, 16, 6809, 17, 2807, 1673, 11, 2261, 11, 1099, 459, 2261, 31942, 17, 61, 267, 372, 754, 421, 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 ]
[ 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, 9506, 199, 199, 533, 2933, 63, 1185, 63, 604, 63, 2416, 8, 4795, 14, 4795, 63, 4844, 304, 272, 408, 267, 9973, 4057, 1004, 3504, 272, 408, 272, 485, 354, 275, 298, 2048, 14, 1185, 14, 604, 14, 2416, 2, 272, 485, 1802, 275, 298, 6009, 4057, 1004, 3504, 2, 339, 347, 1551, 63, 3806, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 3413, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 1238, 14, 576, 358, 267, 2454, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 723, 14, 3723, 14, 2442, 63, 3806, 358, 267, 2933, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 2048, 358, 267, 18672, 3403, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 2048, 14, 21260, 358, 398, 340, 1067, 365, 488, 26, 288, 1067, 275, 1052, 398, 340, 283, 21260, 7, 440, 315, 1067, 26, 288, 18672, 3403, 63, 1580, 275, 18672, 3403, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 297, 6291, 283, 7185, 2023, 267, 587, 26, 288, 18672, 3403, 63, 1580, 275, 359, 1100, 459, 21260, 6538, 398, 18672, 18431, 275, 18672, 3403, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 18672, 3403, 63, 1580, 12, 1067, 29, 1100, 9, 398, 6247, 63, 1580, 275, 942, 267, 340, 18672, 18431, 26, 288, 367, 18672, 3403, 315, 18672, 18431, 26, 355, 367, 6247, 315, 18672, 3403, 14, 5191, 63, 1580, 26, 490, 6247, 63, 1580, 14, 740, 8, 5191, 14, 344, 9, 288, 2881, 275, 620, 4725, 5191, 63, 344, 297, 283, 262, 297, 6247, 63, 1580, 430, 398, 754, 275, 3413, 63, 1113, 14, 362, 63, 785, 63, 4443, 8, 1556, 12, 1747, 12, 283, 2048, 297, 283, 1287, 63, 1185, 63, 604, 63, 2350, 17, 358, 267, 1305, 275, 754, 436, 754, 59, 17, 61, 503, 756, 267, 754, 275, 2454, 63, 1113, 14, 739, 8, 1556, 12, 1747, 12, 359, 344, 11057, 16, 61, 267, 754, 459, 1100, 418, 275, 469, 288, 283, 21260, 356, 756, 12, 288, 283, 2048, 63, 344, 356, 1067, 459, 2682, 63, 344, 995, 288, 283, 2682, 63, 344, 356, 1067, 459, 2682, 63, 344, 995, 267, 789, 398, 340, 1067, 459, 2682, 63, 344, 2565, 288, 6907, 63, 576, 275, 2933, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 1067, 459, 2682, 63, 344, 13227, 1739, 63, 388, 7873, 63, 1580, 288, 340, 6907, 63, 576, 26, 355, 754, 459, 1100, 2278, 873, 3252, 388, 28335, 602, 63, 3223, 356, 715, 1552, 267, 754, 459, 2261, 13784, 1099, 459, 2261, 3488, 16, 6809, 17, 2807, 1673, 11, 2261, 11, 1099, 459, 2261, 31942, 17, 61, 267, 372, 754, 421, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
pygeek/django
django/contrib/auth/tests/urls.py
3
3301
from django.conf.urls import patterns, url from django.contrib.auth import context_processors from django.contrib.auth.urls import urlpatterns from django.contrib.auth.views import password_reset from django.contrib.auth.decorators import login_required from django.contrib.messages.api import info from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import Template, RequestContext from django.views.decorators.cache import never_cache @never_cache def remote_user_auth_view(request): "Dummy view for remote user tests" t = Template("Username is {{ user }}.") c = RequestContext(request, {}) return HttpResponse(t.render(c)) def auth_processor_no_attr_access(request): r1 = render_to_response('context_processors/auth_attrs_no_access.html', RequestContext(request, {}, processors=[context_processors.auth])) # *After* rendering, we check whether the session was accessed return render_to_response('context_processors/auth_attrs_test_access.html', {'session_accessed':request.session.accessed}) def auth_processor_attr_access(request): r1 = render_to_response('context_processors/auth_attrs_access.html', RequestContext(request, {}, processors=[context_processors.auth])) return render_to_response('context_processors/auth_attrs_test_access.html', {'session_accessed':request.session.accessed}) def auth_processor_user(request): return render_to_response('context_processors/auth_attrs_user.html', RequestContext(request, {}, processors=[context_processors.auth])) def auth_processor_perms(request): return render_to_response('context_processors/auth_attrs_perms.html', RequestContext(request, {}, processors=[context_processors.auth])) def auth_processor_perm_in_perms(request): return render_to_response('context_processors/auth_attrs_perm_in_perms.html', RequestContext(request, {}, processors=[context_processors.auth])) def auth_processor_messages(request): info(request, "Message 1") return render_to_response('context_processors/auth_attrs_messages.html', RequestContext(request, {}, processors=[context_processors.auth])) def userpage(request): pass # special urls for auth test cases urlpatterns = urlpatterns + patterns('', (r'^logout/custom_query/$', 'django.contrib.auth.views.logout', dict(redirect_field_name='follow')), (r'^logout/next_page/$', 'django.contrib.auth.views.logout', dict(next_page='/somewhere/')), (r'^remote_user/$', remote_user_auth_view), (r'^password_reset_from_email/$', 'django.contrib.auth.views.password_reset', dict(from_email='staffmember@example.com')), (r'^login_required/$', login_required(password_reset)), (r'^login_required_login_url/$', login_required(password_reset, login_url='/somewhere/')), (r'^auth_processor_no_attr_access/$', auth_processor_no_attr_access), (r'^auth_processor_attr_access/$', auth_processor_attr_access), (r'^auth_processor_user/$', auth_processor_user), (r'^auth_processor_perms/$', auth_processor_perms), (r'^auth_processor_perm_in_perms/$', auth_processor_perm_in_perms), (r'^auth_processor_messages/$', auth_processor_messages), url(r'^userpage/(.+)/$', userpage, name="userpage"), )
bsd-3-clause
[ 504, 1639, 14, 2190, 14, 3603, 492, 7970, 12, 1166, 199, 504, 1639, 14, 2828, 14, 1178, 492, 1067, 63, 10547, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3603, 492, 26177, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 2505, 63, 3958, 199, 504, 1639, 14, 2828, 14, 1178, 14, 11582, 492, 4676, 63, 2427, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 2256, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1160, 492, 5458, 12, 22538, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 199, 32, 18178, 63, 1637, 199, 318, 3982, 63, 751, 63, 1178, 63, 1345, 8, 1069, 304, 272, 298, 11324, 2455, 367, 3982, 922, 2295, 2, 272, 307, 275, 5458, 480, 13355, 365, 8448, 922, 3586, 2685, 272, 286, 275, 22538, 8, 1069, 12, 5009, 272, 372, 6183, 8, 84, 14, 3352, 8, 67, 430, 199, 199, 318, 1790, 63, 6459, 63, 889, 63, 962, 63, 2732, 8, 1069, 304, 272, 519, 17, 275, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 889, 63, 2732, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 272, 327, 627, 10881, 10, 14066, 12, 781, 1104, 3775, 314, 2351, 1990, 13810, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 396, 63, 2732, 14, 1360, 297, 267, 791, 1730, 63, 29433, 356, 1069, 14, 1730, 14, 29433, 1552, 199, 199, 318, 1790, 63, 6459, 63, 962, 63, 2732, 8, 1069, 304, 272, 519, 17, 275, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 2732, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 396, 63, 2732, 14, 1360, 297, 267, 791, 1730, 63, 29433, 356, 1069, 14, 1730, 14, 29433, 1552, 199, 199, 318, 1790, 63, 6459, 63, 751, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 751, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 12068, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 12068, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 8220, 63, 262, 63, 12068, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 8220, 63, 262, 63, 12068, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 3431, 8, 1069, 304, 272, 2256, 8, 1069, 12, 298, 2209, 413, 531, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 3431, 14, 1360, 297, 268, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 922, 1606, 8, 1069, 304, 272, 986, 199, 199, 3, 4539, 8187, 367, 1790, 511, 5560, 199, 20050, 275, 26177, 435, 7970, 8594, 272, 334, 82, 4289, 11646, 15, 4229, 63, 1131, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 11646, 297, 1211, 8, 4876, 63, 698, 63, 354, 534, 7207, 3855, 272, 334, 82, 4289, 11646, 15, 2184, 63, 1606, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 11646, 297, 1211, 8, 2184, 63, 1606, 8805, 3972, 4509, 15, 3855, 272, 334, 82, 4289, 3846, 63, 751, 10884, 3982, 63, 751, 63, 1178, 63, 1345, 395, 272, 334, 82, 4289, 2060, 63, 3958, 63, 504, 63, 2123, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 2060, 63, 3958, 297, 1211, 8, 504, 63, 2123, 534, 7018, 1114, 32, 2694, 14, 957, 3855, 272, 334, 82, 4289, 2886, 63, 2427, 10884, 4676, 63, 2427, 8, 2060, 63, 3958, 1826, 272, 334, 82, 4289, 2886, 63, 2427, 63, 2886, 63, 633, 10884, 4676, 63, 2427, 8, 2060, 63, 3958, 12, 4676, 63, 633, 8805, 3972, 4509, 15, 3855, 339, 334, 82, 4289, 1178, 63, 6459, 63, 889, 63, 962, 63, 2732, 10884, 1790, 63, 6459, 63, 889, 63, 962, 63, 2732, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 962, 63, 2732, 10884, 1790, 63, 6459, 63, 962, 63, 2732, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 751, 10884, 1790, 63, 6459, 63, 751, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 12068, 10884, 1790, 63, 6459, 63, 12068, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 8220, 63, 262, 63, 12068, 10884, 1790, 63, 6459, 63, 8220, 63, 262, 63, 12068, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 3431, 10884, 1790, 63, 6459, 63, 3431, 395, 272, 1166, 8, 82, 4289, 751, 1606, 7985, 6977, 2447, 4268, 922, 1606, 12, 536, 628, 751, 1606, 1288, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 14, 2190, 14, 3603, 492, 7970, 12, 1166, 199, 504, 1639, 14, 2828, 14, 1178, 492, 1067, 63, 10547, 199, 504, 1639, 14, 2828, 14, 1178, 14, 3603, 492, 26177, 199, 504, 1639, 14, 2828, 14, 1178, 14, 4196, 492, 2505, 63, 3958, 199, 504, 1639, 14, 2828, 14, 1178, 14, 11582, 492, 4676, 63, 2427, 199, 504, 1639, 14, 2828, 14, 3431, 14, 1246, 492, 2256, 199, 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 17469, 492, 3795, 63, 475, 63, 1310, 199, 504, 1639, 14, 1160, 492, 5458, 12, 22538, 199, 504, 1639, 14, 4196, 14, 11582, 14, 1637, 492, 7078, 63, 1637, 199, 199, 32, 18178, 63, 1637, 199, 318, 3982, 63, 751, 63, 1178, 63, 1345, 8, 1069, 304, 272, 298, 11324, 2455, 367, 3982, 922, 2295, 2, 272, 307, 275, 5458, 480, 13355, 365, 8448, 922, 3586, 2685, 272, 286, 275, 22538, 8, 1069, 12, 5009, 272, 372, 6183, 8, 84, 14, 3352, 8, 67, 430, 199, 199, 318, 1790, 63, 6459, 63, 889, 63, 962, 63, 2732, 8, 1069, 304, 272, 519, 17, 275, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 889, 63, 2732, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 272, 327, 627, 10881, 10, 14066, 12, 781, 1104, 3775, 314, 2351, 1990, 13810, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 396, 63, 2732, 14, 1360, 297, 267, 791, 1730, 63, 29433, 356, 1069, 14, 1730, 14, 29433, 1552, 199, 199, 318, 1790, 63, 6459, 63, 962, 63, 2732, 8, 1069, 304, 272, 519, 17, 275, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 2732, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 396, 63, 2732, 14, 1360, 297, 267, 791, 1730, 63, 29433, 356, 1069, 14, 1730, 14, 29433, 1552, 199, 199, 318, 1790, 63, 6459, 63, 751, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 751, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 12068, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 12068, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 8220, 63, 262, 63, 12068, 8, 1069, 304, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 8220, 63, 262, 63, 12068, 14, 1360, 297, 267, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 1790, 63, 6459, 63, 3431, 8, 1069, 304, 272, 2256, 8, 1069, 12, 298, 2209, 413, 531, 272, 372, 3795, 63, 475, 63, 1310, 360, 1100, 63, 10547, 15, 1178, 63, 3288, 63, 3431, 14, 1360, 297, 268, 22538, 8, 1069, 12, 5479, 21620, 1524, 1100, 63, 10547, 14, 1178, 2459, 199, 199, 318, 922, 1606, 8, 1069, 304, 272, 986, 199, 199, 3, 4539, 8187, 367, 1790, 511, 5560, 199, 20050, 275, 26177, 435, 7970, 8594, 272, 334, 82, 4289, 11646, 15, 4229, 63, 1131, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 11646, 297, 1211, 8, 4876, 63, 698, 63, 354, 534, 7207, 3855, 272, 334, 82, 4289, 11646, 15, 2184, 63, 1606, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 11646, 297, 1211, 8, 2184, 63, 1606, 8805, 3972, 4509, 15, 3855, 272, 334, 82, 4289, 3846, 63, 751, 10884, 3982, 63, 751, 63, 1178, 63, 1345, 395, 272, 334, 82, 4289, 2060, 63, 3958, 63, 504, 63, 2123, 10884, 283, 1176, 14, 2828, 14, 1178, 14, 4196, 14, 2060, 63, 3958, 297, 1211, 8, 504, 63, 2123, 534, 7018, 1114, 32, 2694, 14, 957, 3855, 272, 334, 82, 4289, 2886, 63, 2427, 10884, 4676, 63, 2427, 8, 2060, 63, 3958, 1826, 272, 334, 82, 4289, 2886, 63, 2427, 63, 2886, 63, 633, 10884, 4676, 63, 2427, 8, 2060, 63, 3958, 12, 4676, 63, 633, 8805, 3972, 4509, 15, 3855, 339, 334, 82, 4289, 1178, 63, 6459, 63, 889, 63, 962, 63, 2732, 10884, 1790, 63, 6459, 63, 889, 63, 962, 63, 2732, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 962, 63, 2732, 10884, 1790, 63, 6459, 63, 962, 63, 2732, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 751, 10884, 1790, 63, 6459, 63, 751, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 12068, 10884, 1790, 63, 6459, 63, 12068, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 8220, 63, 262, 63, 12068, 10884, 1790, 63, 6459, 63, 8220, 63, 262, 63, 12068, 395, 272, 334, 82, 4289, 1178, 63, 6459, 63, 3431, 10884, 1790, 63, 6459, 63, 3431, 395, 272, 1166, 8, 82, 4289, 751, 1606, 7985, 6977, 2447, 4268, 922, 1606, 12, 536, 628, 751, 1606, 1288, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
legalosLOTR/mdb
MDB/gui.py
1
12480
#!/usr/bin/python import sys import wx import wx.lib.agw.ultimatelistctrl as ULC from wx.lib.mixins.listctrl import ColumnSorterMixin import sqlite3 from DBbuilder import create_database, is_in_db, DBbuilderThread, get_from_db import os import wx_signal import wx.html from html_window import ClickableHtmlWindow from dialogs import HtmlDialog, PrefsDialog import config from update import UpdateThread from multiprocessing.pool import ThreadPool #CLASSES# class MyFrame(wx.Frame, ColumnSorterMixin): def __init__(self, parent, conn, cur): wx.Frame.__init__(self, parent, -1, "MDB") self.set_icon() self.conn = conn self.cur = cur self.db_thread = None self.upd_thread = None self.Bind(wx_signal.EVT_FILE_DONE, self.on_file_done) self.Bind(wx_signal.EVT_SHOW_MSG, self.on_show_msg) self.Bind(wx.EVT_CLOSE, self.on_close) self.add_menu() self.add_sb() self.total_rows = 0 self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.display_width = wx.GetDisplaySize()[0] self.itemDataMap = {} self.lst = self.build_list() ColumnSorterMixin.__init__(self, 6) self.sizer.Add(self.lst, 1, wx.EXPAND) self.Layout() def set_icon(self): ib = wx.IconBundle() ib.AddIconFromFile(config.get_resource('images', 'MDB_all.ico'), wx.BITMAP_TYPE_ICO) self.SetIcons(ib) def on_close(self, evt): if (self.db_thread is not None): self.db_thread.exit_now.set() self.db_thread.gui_ready.set() self.db_thread.join() if (self.upd_thread is not None): self.upd_thread.join() self.Destroy() def add_sb(self): sb = wx.StatusBar(self) self.sb = sb sb.SetFieldsCount(2) sb.SetStatusWidths([-2, -1]) sb.SetStatusText("0 Files", 1) self.SetStatusBar(sb) def build_list(self): lst = ULC.UltimateListCtrl( self, wx.ID_ANY, agwStyle=wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT) self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, lst) lst.InsertColumn(0, "Title") lst.InsertColumn(1, "Rating") lst.InsertColumn(2, "Year") lst.InsertColumn(3, "Genre") lst.InsertColumn(4, "Runtime") lst.InsertColumn(5, "Details") lst.SetColumnWidth(0, 100) lst.SetColumnWidth(1, 50) lst.SetColumnWidth(2, 50) lst.SetColumnWidth(3, 100) lst.SetColumnWidth(4, 100) lst.SetColumnWidth(5, -3) return lst def add_menu(self): menuBar = wx.MenuBar() menu = wx.Menu() m_open = menu.Append(wx.ID_OPEN, "&Open\tCtrl+O", "Open a folder.") self.Bind(wx.EVT_MENU, self.open_folder, m_open) m_prefs = menu.Append(wx.ID_PREFERENCES, "&Preferences", "Preferences") self.Bind(wx.EVT_MENU, self.on_prefs, m_prefs) m_exit = menu.Append(wx.ID_EXIT, "&Exit\tCtrl+Q", "Exit") self.Bind(wx.EVT_MENU, self.on_close, m_exit) menuBar.Append(menu, "&File") menu = wx.Menu() m_about = menu.Append(wx.ID_ANY, "&About", "Information about this program") self.Bind(wx.EVT_MENU, self.on_about, m_about) m_upd = menu.Append(wx.ID_ANY, "&Check For Updates", "Check For Updates") self.Bind(wx.EVT_MENU, self.on_chk_upd, m_upd) menuBar.Append(menu, "&Help") self.SetMenuBar(menuBar) def on_chk_upd(self, evt): check_for_updates(self, True) def on_prefs(self, evt): dlg = PrefsDialog(parent=self, items_map=config.prefs_item_map) dlg.ShowModal() dlg.Destroy() def open_folder(self, evt): dlg = wx.DirDialog(self, "Choose a directory:", style=wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST #| wx.DD_CHANGE_DIR ) if dlg.ShowModal() == wx.ID_OK: target_dir = dlg.GetPath() else: return dlg.Destroy() #create new lst self.itemDataMap.clear() self.lst.Destroy() self.lst = self.build_list() ColumnSorterMixin.__init__(self, 6) self.sizer.Add(self.lst, 1, wx.EXPAND) self.Layout() self.Refresh() # switch to this dir self.total_rows = 0 self.update_sb() os.chdir(target_dir) files_with_data, files_wo_data = process_dir('.', self.conn, self.cur) for f in files_with_data: self.add_row(f) if len(files_wo_data) > 0: start_dbbuilder(self, files_wo_data) def on_about(self, evt): abt_dlg = HtmlDialog(self, content=config.abt_dlg_content) abt_dlg.ShowModal() abt_dlg.Destroy() def GetListCtrl(self): return self.lst def OnColClick(self, event): event.Skip() self.Refresh() def add_row(self, filename): # get info from db, build info panel, add to list, update # itemdatamap data = get_from_db(self.conn, self.cur, filename) index = self.lst.InsertStringItem(sys.maxint, data['title']) self.lst.SetItemData(index, index) self.itemDataMap[index] = (data['title'], data['rating'], data['year'], data['genre'], data['runtime'], data['title']) self.lst.SetStringItem(index, 1, unicode(data["rating"])) self.lst.SetStringItem(index, 2, unicode(data["year"])) self.lst.SetStringItem(index, 3, data["genre"]) self.lst.SetStringItem(index, 4, data["runtime"]) self.lst.SetItemWindow(index, 5, self.build_info_panel(data), expand=True) self.total_rows += 1 self.update_sb() def update_sb(self): if (self.total_rows == 1): self.sb.SetStatusText("1 File", 1) else: self.sb.SetStatusText("{0} Files".format(self.total_rows), 1) def build_info_panel(self, data): html_win = ClickableHtmlWindow(self.lst, size=(-1, 180)) html_win.attach_to_frame(self, 0) #style=wx.html.HW_SCROLLBAR_NEVER) html_text = u"<table><tr>" img_file = os.path.join(config.images_folder, data['filename'] + '.jpg') if os.path.exists(img_file): html_text += u'<td width="100" rowspan="2">\ <img src="{0}"></td>\n'.format(img_file) else: html_text += u'<td width="100" rowspan="2"></td>' # imdb icon html_text += u'<td><a href="http://imdb.com/title/{0}">\ <img src="{1}"></a></td></tr>'.format(data['imdbID'], config.get_resource('images', 'imdb-logo.png')) print html_text # details html_text += u"<tr><td>" + self.generate_label_text(data) + u"</td></tr>" html_text += u"</table>" html_win.SetPage(html_text) return html_win def make_wrappable(self, txt): wrap_points = ['.', '-', ']', ')'] for point in wrap_points: txt = txt.replace(point, point + ' ') return txt def generate_label_text(self, data): data2 = [('Title', data['title']), ('Filename', self.make_wrappable(data['filename'])), ('Director', data['director']), ('Actors', data['actors']), ('Plot', data['plot']), ] res = u"<table cellspacing=0 cellpadding=2>" for item in data2: res += u'<tr valign="top"><td valign="top"><b>{0}</b></td>\ <td valign="top">{1}</td></tr>\n'.\ format(item[0], item[1]) res += u"</table>" #print '' #print res return res def on_file_done(self, evt): print "event recieved containing", evt.filename self.add_row(evt.filename) self.db_thread.gui_ready.set() def on_show_msg(self, evt): if (evt.html): dlg = HtmlDialog(self, content=evt.content) dlg.ShowModal() dlg.Destroy() else: wx.MessageBox(evt.content['body'], evt.content['title'], style=wx.OK | wx.CENTER, parent=self) #HELPER FUNCTIONS# def is_movie_file(filename): if (filename.split('.')[-1] in config.movie_formats): return True else: return False def start_dbbuilder(frame, files_wo_data): if (frame.db_thread is not None): frame.db_thread.exit_now.set() frame.db_thread.gui_ready.set() frame.db_thread.join() threadpool = ThreadPool(config.imdb_thread_pool_size) frame.db_thread = DBbuilderThread(frame, files_wo_data, threadpool) frame.db_thread.start() def process_dir(directory, conn, cur): files_with_data = [] files_wo_data = [] for fil in os.listdir(directory): if os.path.isdir(os.path.join(directory, fil)): fil_children = os.listdir(os.path.join(directory, fil)) for c in fil_children: if is_movie_file(c): if is_in_db(conn, cur, c): files_with_data.append(c) else: files_wo_data.append(c) else: if is_movie_file(fil): if is_in_db(conn, cur, fil): files_with_data.append(fil) else: files_wo_data.append(fil) return files_with_data, files_wo_data def check_and_setup(): try: os.mkdir(config.mdb_dir) except OSError, e: pass try: os.mkdir(config.images_folder) except OSError, e: pass if (os.path.exists(config.db_file) and \ config.config['db_version'] < config.db_version): # db_version is old, make new db file os.unlink(config.db_file) if (not os.path.exists(config.db_file)): create_db = True else: create_db = False conn = sqlite3.connect(config.db_file) conn.row_factory = sqlite3.Row cur = conn.cursor() if (create_db): create_database(conn, cur) config.config['db_version'] = config.db_version config.config.write() config.post_process() return conn, cur def check_for_updates(frame, force=False): if (frame.upd_thread is not None): frame.upd_thread.exit_now = True frame.upd_thread.join() frame.upd_thread = UpdateThread(frame, force) frame.upd_thread.start() #MAIN# def main(): conn, cur = check_and_setup() if len(sys.argv) == 1: # no args, use curdir target_files = None else: target_files = sys.argv[1:] if (target_files is None): # use cwd as target_files files_with_data, files_wo_data = process_dir(u'.', conn, cur) else: files_with_data = [] files_wo_data = [] #target_files should be in cwd #make all target_files non_absolute for i in range(len(target_files)): target_files[i] = unicode(os.path.basename(target_files[i]), 'utf-8') for fil in target_files: if os.path.isdir(fil): f_with, f_wo = process_dir(fil, conn, cur) files_with_data.extend(f_with) files_wo_data.extend(f_wo) else: if is_movie_file(fil): if is_in_db(conn, cur, fil): files_with_data.append(fil) else: files_wo_data.append(fil) print 'files_with_data', files_with_data print 'files_wo_data', files_wo_data #spawn threads if (config.platform == 'windows' and config.config['debug']): app = wx.App(redirect=True) else: app = wx.App(redirect=False) if (not config.config['debug']): wx.Log_SetActiveTarget(wx.LogStderr()) frame = MyFrame(None, conn, cur) check_for_updates(frame) app.SetTopWindow(frame) frame.Maximize() for f in files_with_data: frame.add_row(f) if len(files_wo_data) > 0: start_dbbuilder(frame, files_wo_data) frame.Show() frame.Layout() app.MainLoop() if __name__ == '__main__': main()
isc
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 199, 646, 4818, 199, 646, 4818, 14, 773, 14, 643, 87, 14, 1141, 17684, 513, 12476, 465, 738, 7027, 199, 504, 4818, 14, 773, 14, 30192, 14, 513, 12476, 492, 4996, 51, 3968, 4256, 199, 646, 11723, 19, 199, 504, 6249, 5649, 492, 1218, 63, 4659, 12, 365, 63, 262, 63, 697, 12, 6249, 5649, 4436, 12, 664, 63, 504, 63, 697, 199, 646, 747, 199, 646, 4818, 63, 4653, 199, 646, 4818, 14, 1360, 199, 504, 3517, 63, 3806, 492, 26147, 461, 12957, 4301, 199, 504, 487, 18238, 492, 20880, 5619, 12, 510, 7655, 5619, 199, 646, 1101, 199, 504, 1678, 492, 6162, 4436, 199, 504, 12866, 14, 2293, 492, 11086, 5453, 421, 199, 3, 13748, 3, 199, 533, 4932, 3160, 8, 6323, 14, 3160, 12, 4996, 51, 3968, 4256, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 2557, 12, 1094, 304, 267, 4818, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 446, 17, 12, 298, 45, 2846, 531, 267, 291, 14, 409, 63, 4677, 342, 267, 291, 14, 1631, 275, 2557, 267, 291, 14, 895, 275, 1094, 267, 291, 14, 697, 63, 2671, 275, 488, 267, 291, 14, 27517, 63, 2671, 275, 488, 398, 291, 14, 8198, 8, 6323, 63, 4653, 14, 12093, 63, 3817, 63, 22162, 12, 291, 14, 265, 63, 493, 63, 4456, 9, 267, 291, 14, 8198, 8, 6323, 63, 4653, 14, 12093, 63, 19085, 63, 9740, 12, 291, 14, 265, 63, 2384, 63, 1328, 9, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18219, 12, 291, 14, 265, 63, 1600, 9, 267, 291, 14, 525, 63, 4470, 342, 267, 291, 14, 525, 63, 9264, 342, 267, 291, 14, 2923, 63, 3838, 275, 378, 398, 291, 14, 19158, 275, 4818, 14, 28072, 8, 6323, 14, 22634, 9, 267, 291, 14, 1084, 12017, 8, 277, 14, 19158, 9, 398, 291, 14, 2918, 63, 2063, 275, 4818, 14, 1002, 7687, 2320, 3430, 16, 61, 267, 291, 14, 1053, 1451, 2956, 275, 1052, 398, 291, 14, 6916, 275, 291, 14, 1506, 63, 513, 342, 267, 4996, 51, 3968, 4256, 855, 826, 721, 277, 12, 1227, 9, 267, 291, 14, 19158, 14, 1123, 8, 277, 14, 6916, 12, 413, 12, 4818, 14, 20612, 9, 267, 291, 14, 4798, 342, 339, 347, 663, 63, 4677, 8, 277, 304, 267, 26242, 275, 4818, 14, 8954, 12320, 342, 267, 26242, 14, 1123, 8954, 26637, 8, 888, 14, 362, 63, 1927, 360, 4782, 297, 283, 45, 2846, 63, 452, 14, 12802, 659, 288, 4818, 14, 30189, 63, 2711, 63, 948, 47, 9, 267, 291, 14, 1084, 41, 8704, 8, 1892, 9, 20950, 347, 641, 63, 1600, 8, 277, 12, 16330, 304, 267, 340, 334, 277, 14, 697, 63, 2671, 365, 440, 488, 304, 288, 291, 14, 697, 63, 2671, 14, 2224, 63, 2131, 14, 409, 342, 288, 291, 14, 697, 63, 2671, 14, 5885, 63, 2179, 14, 409, 342, 288, 291, 14, 697, 63, 2671, 14, 904, 342, 267, 340, 334, 277, 14, 27517, 63, 2671, 365, 440, 488, 304, 288, 291, 14, 27517, 63, 2671, 14, 904, 342, 267, 291, 14, 14704, 342, 339, 347, 1050, 63, 9264, 8, 277, 304, 267, 20088, 275, 4818, 14, 3694, 5281, 8, 277, 9, 267, 291, 14, 9264, 275, 20088, 267, 20088, 14, 1084, 7304, 2353, 8, 18, 9, 267, 20088, 14, 1084, 3694, 6216, 83, 11468, 18, 12, 446, 17, 566, 267, 20088, 14, 1084, 3694, 1872, 480, 16, 16920, 401, 413, 9, 267, 291, 14, 1084, 3694, 5281, 8, 9264, 9, 339, 347, 1900, 63, 513, 8, 277, 304, 267, 9877, 275, 738, 7027, 14, 18505, 2906, 323, 1296, 9778, 8, 288, 291, 12, 4818, 14, 998, 63, 8974, 12, 1839, 87, 6609, 29, 6323, 14, 7027, 63, 17356, 1204, 4818, 14, 7027, 63, 20271, 24392, 1204, 288, 4818, 14, 7027, 63, 14784, 24392, 1204, 4818, 14, 7027, 63, 16425, 63, 899, 44, 1204, 738, 7027, 14, 1293, 35, 63, 13533, 63, 23129, 63, 11415, 63, 13509, 9, 398, 291, 14, 8198, 8, 6323, 14, 12093, 63, 4924, 63, 3978, 63, 1981, 13884, 12, 291, 14, 3314, 2001, 12040, 12, 9877, 9, 398, 9877, 14, 9971, 4547, 8, 16, 12, 298, 6888, 531, 267, 9877, 14, 9971, 4547, 8, 17, 12, 298, 32533, 531, 267, 9877, 14, 9971, 4547, 8, 18, 12, 298, 15731, 531, 267, 9877, 14, 9971, 4547, 8, 19, 12, 298, 8168, 264, 531, 267, 9877, 14, 9971, 4547, 8, 20, 12, 298, 14357, 531, 267, 9877, 14, 9971, 4547, 8, 21, 12, 298, 11347, 531, 398, 9877, 14, 1084, 4547, 6216, 8, 16, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 17, 12, 5238, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 18, 12, 5238, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 19, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 20, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 21, 12, 446, 19, 9, 398, 372, 9877, 339, 347, 1050, 63, 4470, 8, 277, 304, 267, 6269, 5281, 275, 4818, 14, 5977, 5281, 342, 267, 6269, 275, 4818, 14, 5977, 342, 398, 333, 63, 1490, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 9935, 12, 11746, 4299, 60, 84, 9778, 11, 47, 401, 2490, 298, 4299, 282, 4922, 2685, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 1490, 63, 3741, 12, 333, 63, 1490, 9, 398, 333, 63, 17253, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 4225, 15849, 22243, 12, 11746, 30772, 401, 298, 30772, 531, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 265, 63, 17253, 12, 333, 63, 17253, 9, 398, 333, 63, 2224, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 17219, 12, 11746, 6699, 60, 84, 9778, 11, 49, 401, 298, 6699, 531, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 265, 63, 1600, 12, 333, 63, 2224, 9, 398, 6269, 5281, 14, 8310, 8, 4470, 12, 11746, 1173, 531, 398, 6269, 275, 4818, 14, 5977, 342, 398, 333, 63, 10254, 275, 6269, 14, 8310, 8, 6323, 14 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 646, 984, 199, 646, 4818, 199, 646, 4818, 14, 773, 14, 643, 87, 14, 1141, 17684, 513, 12476, 465, 738, 7027, 199, 504, 4818, 14, 773, 14, 30192, 14, 513, 12476, 492, 4996, 51, 3968, 4256, 199, 646, 11723, 19, 199, 504, 6249, 5649, 492, 1218, 63, 4659, 12, 365, 63, 262, 63, 697, 12, 6249, 5649, 4436, 12, 664, 63, 504, 63, 697, 199, 646, 747, 199, 646, 4818, 63, 4653, 199, 646, 4818, 14, 1360, 199, 504, 3517, 63, 3806, 492, 26147, 461, 12957, 4301, 199, 504, 487, 18238, 492, 20880, 5619, 12, 510, 7655, 5619, 199, 646, 1101, 199, 504, 1678, 492, 6162, 4436, 199, 504, 12866, 14, 2293, 492, 11086, 5453, 421, 199, 3, 13748, 3, 199, 533, 4932, 3160, 8, 6323, 14, 3160, 12, 4996, 51, 3968, 4256, 304, 272, 347, 636, 826, 721, 277, 12, 1676, 12, 2557, 12, 1094, 304, 267, 4818, 14, 3160, 855, 826, 721, 277, 12, 1676, 12, 446, 17, 12, 298, 45, 2846, 531, 267, 291, 14, 409, 63, 4677, 342, 267, 291, 14, 1631, 275, 2557, 267, 291, 14, 895, 275, 1094, 267, 291, 14, 697, 63, 2671, 275, 488, 267, 291, 14, 27517, 63, 2671, 275, 488, 398, 291, 14, 8198, 8, 6323, 63, 4653, 14, 12093, 63, 3817, 63, 22162, 12, 291, 14, 265, 63, 493, 63, 4456, 9, 267, 291, 14, 8198, 8, 6323, 63, 4653, 14, 12093, 63, 19085, 63, 9740, 12, 291, 14, 265, 63, 2384, 63, 1328, 9, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18219, 12, 291, 14, 265, 63, 1600, 9, 267, 291, 14, 525, 63, 4470, 342, 267, 291, 14, 525, 63, 9264, 342, 267, 291, 14, 2923, 63, 3838, 275, 378, 398, 291, 14, 19158, 275, 4818, 14, 28072, 8, 6323, 14, 22634, 9, 267, 291, 14, 1084, 12017, 8, 277, 14, 19158, 9, 398, 291, 14, 2918, 63, 2063, 275, 4818, 14, 1002, 7687, 2320, 3430, 16, 61, 267, 291, 14, 1053, 1451, 2956, 275, 1052, 398, 291, 14, 6916, 275, 291, 14, 1506, 63, 513, 342, 267, 4996, 51, 3968, 4256, 855, 826, 721, 277, 12, 1227, 9, 267, 291, 14, 19158, 14, 1123, 8, 277, 14, 6916, 12, 413, 12, 4818, 14, 20612, 9, 267, 291, 14, 4798, 342, 339, 347, 663, 63, 4677, 8, 277, 304, 267, 26242, 275, 4818, 14, 8954, 12320, 342, 267, 26242, 14, 1123, 8954, 26637, 8, 888, 14, 362, 63, 1927, 360, 4782, 297, 283, 45, 2846, 63, 452, 14, 12802, 659, 288, 4818, 14, 30189, 63, 2711, 63, 948, 47, 9, 267, 291, 14, 1084, 41, 8704, 8, 1892, 9, 20950, 347, 641, 63, 1600, 8, 277, 12, 16330, 304, 267, 340, 334, 277, 14, 697, 63, 2671, 365, 440, 488, 304, 288, 291, 14, 697, 63, 2671, 14, 2224, 63, 2131, 14, 409, 342, 288, 291, 14, 697, 63, 2671, 14, 5885, 63, 2179, 14, 409, 342, 288, 291, 14, 697, 63, 2671, 14, 904, 342, 267, 340, 334, 277, 14, 27517, 63, 2671, 365, 440, 488, 304, 288, 291, 14, 27517, 63, 2671, 14, 904, 342, 267, 291, 14, 14704, 342, 339, 347, 1050, 63, 9264, 8, 277, 304, 267, 20088, 275, 4818, 14, 3694, 5281, 8, 277, 9, 267, 291, 14, 9264, 275, 20088, 267, 20088, 14, 1084, 7304, 2353, 8, 18, 9, 267, 20088, 14, 1084, 3694, 6216, 83, 11468, 18, 12, 446, 17, 566, 267, 20088, 14, 1084, 3694, 1872, 480, 16, 16920, 401, 413, 9, 267, 291, 14, 1084, 3694, 5281, 8, 9264, 9, 339, 347, 1900, 63, 513, 8, 277, 304, 267, 9877, 275, 738, 7027, 14, 18505, 2906, 323, 1296, 9778, 8, 288, 291, 12, 4818, 14, 998, 63, 8974, 12, 1839, 87, 6609, 29, 6323, 14, 7027, 63, 17356, 1204, 4818, 14, 7027, 63, 20271, 24392, 1204, 288, 4818, 14, 7027, 63, 14784, 24392, 1204, 4818, 14, 7027, 63, 16425, 63, 899, 44, 1204, 738, 7027, 14, 1293, 35, 63, 13533, 63, 23129, 63, 11415, 63, 13509, 9, 398, 291, 14, 8198, 8, 6323, 14, 12093, 63, 4924, 63, 3978, 63, 1981, 13884, 12, 291, 14, 3314, 2001, 12040, 12, 9877, 9, 398, 9877, 14, 9971, 4547, 8, 16, 12, 298, 6888, 531, 267, 9877, 14, 9971, 4547, 8, 17, 12, 298, 32533, 531, 267, 9877, 14, 9971, 4547, 8, 18, 12, 298, 15731, 531, 267, 9877, 14, 9971, 4547, 8, 19, 12, 298, 8168, 264, 531, 267, 9877, 14, 9971, 4547, 8, 20, 12, 298, 14357, 531, 267, 9877, 14, 9971, 4547, 8, 21, 12, 298, 11347, 531, 398, 9877, 14, 1084, 4547, 6216, 8, 16, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 17, 12, 5238, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 18, 12, 5238, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 19, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 20, 12, 2948, 9, 267, 9877, 14, 1084, 4547, 6216, 8, 21, 12, 446, 19, 9, 398, 372, 9877, 339, 347, 1050, 63, 4470, 8, 277, 304, 267, 6269, 5281, 275, 4818, 14, 5977, 5281, 342, 267, 6269, 275, 4818, 14, 5977, 342, 398, 333, 63, 1490, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 9935, 12, 11746, 4299, 60, 84, 9778, 11, 47, 401, 2490, 298, 4299, 282, 4922, 2685, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 1490, 63, 3741, 12, 333, 63, 1490, 9, 398, 333, 63, 17253, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 4225, 15849, 22243, 12, 11746, 30772, 401, 298, 30772, 531, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 265, 63, 17253, 12, 333, 63, 17253, 9, 398, 333, 63, 2224, 275, 6269, 14, 8310, 8, 6323, 14, 998, 63, 17219, 12, 11746, 6699, 60, 84, 9778, 11, 49, 401, 298, 6699, 531, 267, 291, 14, 8198, 8, 6323, 14, 12093, 63, 18223, 12, 291, 14, 265, 63, 1600, 12, 333, 63, 2224, 9, 398, 6269, 5281, 14, 8310, 8, 4470, 12, 11746, 1173, 531, 398, 6269, 275, 4818, 14, 5977, 342, 398, 333, 63, 10254, 275, 6269, 14, 8310, 8, 6323, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
xxd3vin/spp-sdk
opt/Python27/Lib/site-packages/numpy/ma/tests/test_old_ma.py
81
34283
import numpy import types from numpy.ma import * from numpy.core.numerictypes import float32 from numpy.ma.core import umath from numpy.testing import * import sys if sys.version_info[0] >= 3: from functools import reduce pi = numpy.pi def eq(v, w, msg=''): result = allclose(v, w) if not result: print """Not eq:%s %s ---- %s""" % (msg, str(v), str(w)) return result class TestMa(TestCase): def setUp (self): x = numpy.array([1., 1., 1., -2., pi / 2.0, 4., 5., -10., 10., 1., 2., 3.]) y = numpy.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.]) a10 = 10. m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0] m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0 , 0, 1] xm = array(x, mask=m1) ym = array(y, mask=m2) z = numpy.array([-.5, 0., .5, .8]) zm = array(z, mask=[0, 1, 0, 0]) xf = numpy.where(m1, 1e+20, x) s = x.shape xm.set_fill_value(1e+20) self.d = (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) def test_testBasic1d(self): "Test of basic array creation and properties in 1 dimension." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d self.assertFalse(isMaskedArray(x)) self.assertTrue(isMaskedArray(xm)) self.assertEqual(shape(xm), s) self.assertEqual(xm.shape, s) self.assertEqual(xm.dtype, x.dtype) self.assertEqual(xm.size , reduce(lambda x, y:x * y, s)) self.assertEqual(count(xm) , len(m1) - reduce(lambda x, y:x + y, m1)) self.assertTrue(eq(xm, xf)) self.assertTrue(eq(filled(xm, 1.e20), xf)) self.assertTrue(eq(x, xm)) def test_testBasic2d(self): "Test of basic array creation and properties in 2 dimensions." for s in [(4, 3), (6, 2)]: (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d x.shape = s y.shape = s xm.shape = s ym.shape = s xf.shape = s self.assertFalse(isMaskedArray(x)) self.assertTrue(isMaskedArray(xm)) self.assertEqual(shape(xm), s) self.assertEqual(xm.shape, s) self.assertEqual(xm.size , reduce(lambda x, y:x * y, s)) self.assertEqual(count(xm) , len(m1) - reduce(lambda x, y:x + y, m1)) self.assertTrue(eq(xm, xf)) self.assertTrue(eq(filled(xm, 1.e20), xf)) self.assertTrue(eq(x, xm)) self.setUp() def test_testArithmetic (self): "Test of basic arithmetic." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d a2d = array([[1, 2], [0, 4]]) a2dm = masked_array(a2d, [[0, 0], [1, 0]]) self.assertTrue(eq (a2d * a2d, a2d * a2dm)) self.assertTrue(eq (a2d + a2d, a2d + a2dm)) self.assertTrue(eq (a2d - a2d, a2d - a2dm)) for s in [(12,), (4, 3), (2, 6)]: x = x.reshape(s) y = y.reshape(s) xm = xm.reshape(s) ym = ym.reshape(s) xf = xf.reshape(s) self.assertTrue(eq(-x, -xm)) self.assertTrue(eq(x + y, xm + ym)) self.assertTrue(eq(x - y, xm - ym)) self.assertTrue(eq(x * y, xm * ym)) olderr = numpy.seterr(divide='ignore', invalid='ignore') try: self.assertTrue(eq(x / y, xm / ym)) finally: numpy.seterr(**olderr) self.assertTrue(eq(a10 + y, a10 + ym)) self.assertTrue(eq(a10 - y, a10 - ym)) self.assertTrue(eq(a10 * y, a10 * ym)) olderr = numpy.seterr(divide='ignore', invalid='ignore') try: self.assertTrue(eq(a10 / y, a10 / ym)) finally: numpy.seterr(**olderr) self.assertTrue(eq(x + a10, xm + a10)) self.assertTrue(eq(x - a10, xm - a10)) self.assertTrue(eq(x * a10, xm * a10)) self.assertTrue(eq(x / a10, xm / a10)) self.assertTrue(eq(x ** 2, xm ** 2)) self.assertTrue(eq(abs(x) ** 2.5, abs(xm) ** 2.5)) self.assertTrue(eq(x ** y, xm ** ym)) self.assertTrue(eq(numpy.add(x, y), add(xm, ym))) self.assertTrue(eq(numpy.subtract(x, y), subtract(xm, ym))) self.assertTrue(eq(numpy.multiply(x, y), multiply(xm, ym))) olderr = numpy.seterr(divide='ignore', invalid='ignore') try: self.assertTrue(eq(numpy.divide(x, y), divide(xm, ym))) finally: numpy.seterr(**olderr) def test_testMixedArithmetic(self): na = numpy.array([1]) ma = array([1]) self.assertTrue(isinstance(na + ma, MaskedArray)) self.assertTrue(isinstance(ma + na, MaskedArray)) def test_testUfuncs1 (self): "Test various functions such as sin, cos." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d self.assertTrue (eq(numpy.cos(x), cos(xm))) self.assertTrue (eq(numpy.cosh(x), cosh(xm))) self.assertTrue (eq(numpy.sin(x), sin(xm))) self.assertTrue (eq(numpy.sinh(x), sinh(xm))) self.assertTrue (eq(numpy.tan(x), tan(xm))) self.assertTrue (eq(numpy.tanh(x), tanh(xm))) olderr = numpy.seterr(divide='ignore', invalid='ignore') try: self.assertTrue (eq(numpy.sqrt(abs(x)), sqrt(xm))) self.assertTrue (eq(numpy.log(abs(x)), log(xm))) self.assertTrue (eq(numpy.log10(abs(x)), log10(xm))) finally: numpy.seterr(**olderr) self.assertTrue (eq(numpy.exp(x), exp(xm))) self.assertTrue (eq(numpy.arcsin(z), arcsin(zm))) self.assertTrue (eq(numpy.arccos(z), arccos(zm))) self.assertTrue (eq(numpy.arctan(z), arctan(zm))) self.assertTrue (eq(numpy.arctan2(x, y), arctan2(xm, ym))) self.assertTrue (eq(numpy.absolute(x), absolute(xm))) self.assertTrue (eq(numpy.equal(x, y), equal(xm, ym))) self.assertTrue (eq(numpy.not_equal(x, y), not_equal(xm, ym))) self.assertTrue (eq(numpy.less(x, y), less(xm, ym))) self.assertTrue (eq(numpy.greater(x, y), greater(xm, ym))) self.assertTrue (eq(numpy.less_equal(x, y), less_equal(xm, ym))) self.assertTrue (eq(numpy.greater_equal(x, y), greater_equal(xm, ym))) self.assertTrue (eq(numpy.conjugate(x), conjugate(xm))) self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((xm, ym)))) self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((x, y)))) self.assertTrue (eq(numpy.concatenate((x, y)), concatenate((xm, y)))) self.assertTrue (eq(numpy.concatenate((x, y, x)), concatenate((x, ym, x)))) def test_xtestCount (self): "Test count" ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0]) if sys.version_info[0] >= 3: self.assertTrue(isinstance(count(ott), numpy.integer)) else: self.assertTrue(isinstance(count(ott), types.IntType)) self.assertEqual(3, count(ott)) self.assertEqual(1, count(1)) self.assertTrue (eq(0, array(1, mask=[1]))) ott = ott.reshape((2, 2)) assert isinstance(count(ott, 0), numpy.ndarray) if sys.version_info[0] >= 3: assert isinstance(count(ott), numpy.integer) else: assert isinstance(count(ott), types.IntType) self.assertTrue (eq(3, count(ott))) assert getmask(count(ott, 0)) is nomask self.assertTrue (eq([1, 2], count(ott, 0))) def test_testMinMax (self): "Test minimum and maximum." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d xr = numpy.ravel(x) #max doesn't work if shaped xmr = ravel(xm) #true because of careful selection of data self.assertTrue(eq(max(xr), maximum(xmr))) #true because of careful selection of data self.assertTrue(eq(min(xr), minimum(xmr))) def test_testAddSumProd (self): "Test add, sum, product." (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d self.assertTrue (eq(numpy.add.reduce(x), add.reduce(x))) self.assertTrue (eq(numpy.add.accumulate(x), add.accumulate(x))) self.assertTrue (eq(4, sum(array(4), axis=0))) self.assertTrue (eq(4, sum(array(4), axis=0))) self.assertTrue (eq(numpy.sum(x, axis=0), sum(x, axis=0))) self.assertTrue (eq(numpy.sum(filled(xm, 0), axis=0), sum(xm, axis=0))) self.assertTrue (eq(numpy.sum(x, 0), sum(x, 0))) self.assertTrue (eq(numpy.product(x, axis=0), product(x, axis=0))) self.assertTrue (eq(numpy.product(x, 0), product(x, 0))) self.assertTrue (eq(numpy.product(filled(xm, 1), axis=0), product(xm, axis=0))) if len(s) > 1: self.assertTrue (eq(numpy.concatenate((x, y), 1), concatenate((xm, ym), 1))) self.assertTrue (eq(numpy.add.reduce(x, 1), add.reduce(x, 1))) self.assertTrue (eq(numpy.sum(x, 1), sum(x, 1))) self.assertTrue (eq(numpy.product(x, 1), product(x, 1))) def test_testCI(self): "Test of conversions and indexing" x1 = numpy.array([1, 2, 4, 3]) x2 = array(x1, mask=[1, 0, 0, 0]) x3 = array(x1, mask=[0, 1, 0, 1]) x4 = array(x1) # test conversion to strings junk, garbage = str(x2), repr(x2) assert eq(numpy.sort(x1), sort(x2, fill_value=0)) # tests of indexing assert type(x2[1]) is type(x1[1]) assert x1[1] == x2[1] assert x2[0] is masked assert eq(x1[2], x2[2]) assert eq(x1[2:5], x2[2:5]) assert eq(x1[:], x2[:]) assert eq(x1[1:], x3[1:]) x1[2] = 9 x2[2] = 9 assert eq(x1, x2) x1[1:3] = 99 x2[1:3] = 99 assert eq(x1, x2) x2[1] = masked assert eq(x1, x2) x2[1:3] = masked assert eq(x1, x2) x2[:] = x1 x2[1] = masked assert allequal(getmask(x2), array([0, 1, 0, 0])) x3[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0]) assert allequal(getmask(x3), array([0, 1, 1, 0])) x4[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0]) assert allequal(getmask(x4), array([0, 1, 1, 0])) assert allequal(x4, array([1, 2, 3, 4])) x1 = numpy.arange(5) * 1.0 x2 = masked_values(x1, 3.0) assert eq(x1, x2) assert allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask) assert eq(3.0, x2.fill_value) x1 = array([1, 'hello', 2, 3], object) x2 = numpy.array([1, 'hello', 2, 3], object) s1 = x1[1] s2 = x2[1] self.assertEqual(type(s2), str) self.assertEqual(type(s1), str) self.assertEqual(s1, s2) assert x1[1:1].shape == (0,) def test_testCopySize(self): "Tests of some subtle points of copying and sizing." n = [0, 0, 1, 0, 0] m = make_mask(n) m2 = make_mask(m) self.assertTrue(m is m2) m3 = make_mask(m, copy=1) self.assertTrue(m is not m3) x1 = numpy.arange(5) y1 = array(x1, mask=m) self.assertTrue(y1._data is not x1) self.assertTrue(allequal(x1, y1._data)) self.assertTrue(y1.mask is m) y1a = array(y1, copy=0) self.assertTrue(y1a.mask is y1.mask) y2 = array(x1, mask=m, copy=0) self.assertTrue(y2.mask is m) self.assertTrue(y2[2] is masked) y2[2] = 9 self.assertTrue(y2[2] is not masked) self.assertTrue(y2.mask is not m) self.assertTrue(allequal(y2.mask, 0)) y3 = array(x1 * 1.0, mask=m) self.assertTrue(filled(y3).dtype is (x1 * 1.0).dtype) x4 = arange(4) x4[2] = masked y4 = resize(x4, (8,)) self.assertTrue(eq(concatenate([x4, x4]), y4)) self.assertTrue(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0])) y5 = repeat(x4, (2, 2, 2, 2), axis=0) self.assertTrue(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3])) y6 = repeat(x4, 2, axis=0) self.assertTrue(eq(y5, y6)) def test_testPut(self): "Test of put" d = arange(5) n = [0, 0, 0, 1, 1] m = make_mask(n) x = array(d, mask=m) self.assertTrue(x[3] is masked) self.assertTrue(x[4] is masked) x[[1, 4]] = [10, 40] self.assertTrue(x.mask is not m) self.assertTrue(x[3] is masked) self.assertTrue(x[4] is not masked) self.assertTrue(eq(x, [0, 10, 2, -1, 40])) x = array(d, mask=m) x.put([0, 1, 2], [-1, 100, 200]) self.assertTrue(eq(x, [-1, 100, 200, 0, 0])) self.assertTrue(x[3] is masked) self.assertTrue(x[4] is masked) def test_testMaPut(self): (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1] i = numpy.nonzero(m)[0] put(ym, i, zm) assert all(take(ym, i, axis=0) == zm) def test_testOddFeatures(self): "Test of other odd features" x = arange(20); x = x.reshape(4, 5) x.flat[5] = 12 assert x[1, 0] == 12 z = x + 10j * x assert eq(z.real, x) assert eq(z.imag, 10 * x) assert eq((z * conjugate(z)).real, 101 * x * x) z.imag[...] = 0.0 x = arange(10) x[3] = masked assert str(x[3]) == str(masked) c = x >= 8 assert count(where(c, masked, masked)) == 0 assert shape(where(c, masked, masked)) == c.shape z = where(c , x, masked) assert z.dtype is x.dtype assert z[3] is masked assert z[4] is masked assert z[7] is masked assert z[8] is not masked assert z[9] is not masked assert eq(x, z) z = where(c , masked, x) assert z.dtype is x.dtype assert z[3] is masked assert z[4] is not masked assert z[7] is not masked assert z[8] is masked assert z[9] is masked z = masked_where(c, x) assert z.dtype is x.dtype assert z[3] is masked assert z[4] is not masked assert z[7] is not masked assert z[8] is masked assert z[9] is masked assert eq(x, z) x = array([1., 2., 3., 4., 5.]) c = array([1, 1, 1, 0, 0]) x[2] = masked z = where(c, x, -x) assert eq(z, [1., 2., 0., -4., -5]) c[0] = masked z = where(c, x, -x) assert eq(z, [1., 2., 0., -4., -5]) assert z[0] is masked assert z[1] is not masked assert z[2] is masked assert eq(masked_where(greater(x, 2), x), masked_greater(x, 2)) assert eq(masked_where(greater_equal(x, 2), x), masked_greater_equal(x, 2)) assert eq(masked_where(less(x, 2), x), masked_less(x, 2)) assert eq(masked_where(less_equal(x, 2), x), masked_less_equal(x, 2)) assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)) assert eq(masked_where(equal(x, 2), x), masked_equal(x, 2)) assert eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)) assert eq(masked_inside(range(5), 1, 3), [0, 199, 199, 199, 4]) assert eq(masked_outside(range(5), 1, 3), [199, 1, 2, 3, 199]) assert eq(masked_inside(array(range(5), mask=[1, 0, 0, 0, 0]), 1, 3).mask, [1, 1, 1, 1, 0]) assert eq(masked_outside(array(range(5), mask=[0, 1, 0, 0, 0]), 1, 3).mask, [1, 1, 0, 0, 1]) assert eq(masked_equal(array(range(5), mask=[1, 0, 0, 0, 0]), 2).mask, [1, 0, 1, 0, 0]) assert eq(masked_not_equal(array([2, 2, 1, 2, 1], mask=[1, 0, 0, 0, 0]), 2).mask, [1, 0, 1, 0, 1]) assert eq(masked_where([1, 1, 0, 0, 0], [1, 2, 3, 4, 5]), [99, 99, 3, 4, 5]) atest = ones((10, 10, 10), dtype=float32) btest = zeros(atest.shape, MaskType) ctest = masked_where(btest, atest) assert eq(atest, ctest) z = choose(c, (-x, x)) assert eq(z, [1., 2., 0., -4., -5]) assert z[0] is masked assert z[1] is not masked assert z[2] is masked x = arange(6) x[5] = masked y = arange(6) * 10 y[2] = masked c = array([1, 1, 1, 0, 0, 0], mask=[1, 0, 0, 0, 0, 0]) cm = c.filled(1) z = where(c, x, y) zm = where(cm, x, y) assert eq(z, zm) assert getmask(zm) is nomask assert eq(zm, [0, 1, 2, 30, 40, 50]) z = where(c, masked, 1) assert eq(z, [99, 99, 99, 1, 1, 1]) z = where(c, 1, masked) assert eq(z, [99, 1, 1, 99, 99, 99]) def test_testMinMax(self): "Test of minumum, maximum." assert eq(minimum([1, 2, 3], [4, 0, 9]), [1, 0, 3]) assert eq(maximum([1, 2, 3], [4, 0, 9]), [4, 2, 9]) x = arange(5) y = arange(5) - 2 x[3] = masked y[0] = masked assert eq(minimum(x, y), where(less(x, y), x, y)) assert eq(maximum(x, y), where(greater(x, y), x, y)) assert minimum(x) == 0 assert maximum(x) == 4 def test_testTakeTransposeInnerOuter(self): "Test of take, transpose, inner, outer products" x = arange(24) y = numpy.arange(24) x[5:6] = masked x = x.reshape(2, 3, 4) y = y.reshape(2, 3, 4) assert eq(numpy.transpose(y, (2, 0, 1)), transpose(x, (2, 0, 1))) assert eq(numpy.take(y, (2, 0, 1), 1), take(x, (2, 0, 1), 1)) assert eq(numpy.inner(filled(x, 0), filled(y, 0)), inner(x, y)) assert eq(numpy.outer(filled(x, 0), filled(y, 0)), outer(x, y)) y = array(['abc', 1, 'def', 2, 3], object) y[2] = masked t = take(y, [0, 3, 4]) assert t[0] == 'abc' assert t[1] == 2 assert t[2] == 3 def test_testInplace(self): """Test of inplace operations and rich comparisons""" y = arange(10) x = arange(10) xm = arange(10) xm[2] = masked x += 1 assert eq(x, y + 1) xm += 1 assert eq(x, y + 1) x = arange(10) xm = arange(10) xm[2] = masked x -= 1 assert eq(x, y - 1) xm -= 1 assert eq(xm, y - 1) x = arange(10) * 1.0 xm = arange(10) * 1.0 xm[2] = masked x *= 2.0 assert eq(x, y * 2) xm *= 2.0 assert eq(xm, y * 2) x = arange(10) * 2 xm = arange(10) xm[2] = masked x /= 2 assert eq(x, y) xm /= 2 assert eq(x, y) x = arange(10) * 1.0 xm = arange(10) * 1.0 xm[2] = masked x /= 2.0 assert eq(x, y / 2.0) xm /= arange(10) assert eq(xm, ones((10,))) x = arange(10).astype(float32) xm = arange(10) xm[2] = masked x += 1. assert eq(x, y + 1.) def test_testPickle(self): "Test of pickling" import pickle x = arange(12) x[4:10:2] = masked x = x.reshape(4, 3) s = pickle.dumps(x) y = pickle.loads(s) assert eq(x, y) def test_testMasked(self): "Test of masked element" xx = arange(6) xx[1] = masked self.assertTrue(str(masked) == '--') self.assertTrue(xx[1] is masked) self.assertEqual(filled(xx[1], 0), 0) # don't know why these should raise an exception... #self.assertRaises(Exception, lambda x,y: x+y, masked, masked) #self.assertRaises(Exception, lambda x,y: x+y, masked, 2) #self.assertRaises(Exception, lambda x,y: x+y, masked, xx) #self.assertRaises(Exception, lambda x,y: x+y, xx, masked) def test_testAverage1(self): "Test of average." ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0]) self.assertTrue(eq(2.0, average(ott, axis=0))) self.assertTrue(eq(2.0, average(ott, weights=[1., 1., 2., 1.]))) result, wts = average(ott, weights=[1., 1., 2., 1.], returned=1) self.assertTrue(eq(2.0, result)) self.assertTrue(wts == 4.0) ott[:] = masked self.assertTrue(average(ott, axis=0) is masked) ott = array([0., 1., 2., 3.], mask=[1, 0, 0, 0]) ott = ott.reshape(2, 2) ott[:, 1] = masked self.assertTrue(eq(average(ott, axis=0), [2.0, 0.0])) self.assertTrue(average(ott, axis=1)[0] is masked) self.assertTrue(eq([2., 0.], average(ott, axis=0))) result, wts = average(ott, axis=0, returned=1) self.assertTrue(eq(wts, [1., 0.])) def test_testAverage2(self): "More tests of average." w1 = [0, 1, 1, 1, 1, 0] w2 = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 0, 1]] x = arange(6) self.assertTrue(allclose(average(x, axis=0), 2.5)) self.assertTrue(allclose(average(x, axis=0, weights=w1), 2.5)) y = array([arange(6), 2.0 * arange(6)]) self.assertTrue(allclose(average(y, None), numpy.add.reduce(numpy.arange(6)) * 3. / 12.)) self.assertTrue(allclose(average(y, axis=0), numpy.arange(6) * 3. / 2.)) self.assertTrue(allclose(average(y, axis=1), [average(x, axis=0), average(x, axis=0) * 2.0])) self.assertTrue(allclose(average(y, None, weights=w2), 20. / 6.)) self.assertTrue(allclose(average(y, axis=0, weights=w2), [0., 1., 2., 3., 4., 10.])) self.assertTrue(allclose(average(y, axis=1), [average(x, axis=0), average(x, axis=0) * 2.0])) m1 = zeros(6) m2 = [0, 0, 1, 1, 0, 0] m3 = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0]] m4 = ones(6) m5 = [0, 1, 1, 1, 1, 1] self.assertTrue(allclose(average(masked_array(x, m1), axis=0), 2.5)) self.assertTrue(allclose(average(masked_array(x, m2), axis=0), 2.5)) self.assertTrue(average(masked_array(x, m4), axis=0) is masked) self.assertEqual(average(masked_array(x, m5), axis=0), 0.0) self.assertEqual(count(average(masked_array(x, m4), axis=0)), 0) z = masked_array(y, m3) self.assertTrue(allclose(average(z, None), 20. / 6.)) self.assertTrue(allclose(average(z, axis=0), [0., 1., 99., 99., 4.0, 7.5])) self.assertTrue(allclose(average(z, axis=1), [2.5, 5.0])) self.assertTrue(allclose(average(z, axis=0, weights=w2), [0., 1., 99., 99., 4.0, 10.0])) a = arange(6) b = arange(6) * 3 r1, w1 = average([[a, b], [b, a]], axis=1, returned=1) self.assertEqual(shape(r1) , shape(w1)) self.assertEqual(r1.shape , w1.shape) r2, w2 = average(ones((2, 2, 3)), axis=0, weights=[3, 1], returned=1) self.assertEqual(shape(w2) , shape(r2)) r2, w2 = average(ones((2, 2, 3)), returned=1) self.assertEqual(shape(w2) , shape(r2)) r2, w2 = average(ones((2, 2, 3)), weights=ones((2, 2, 3)), returned=1) self.assertTrue(shape(w2) == shape(r2)) a2d = array([[1, 2], [0, 4]], float) a2dm = masked_array(a2d, [[0, 0], [1, 0]]) a2da = average(a2d, axis=0) self.assertTrue(eq (a2da, [0.5, 3.0])) a2dma = average(a2dm, axis=0) self.assertTrue(eq(a2dma, [1.0, 3.0])) a2dma = average(a2dm, axis=None) self.assertTrue(eq(a2dma, 7. / 3.)) a2dma = average(a2dm, axis=1) self.assertTrue(eq(a2dma, [1.5, 4.0])) def test_testToPython(self): self.assertEqual(1, int(array(1))) self.assertEqual(1.0, float(array(1))) self.assertEqual(1, int(array([[[1]]]))) self.assertEqual(1.0, float(array([[1]]))) self.assertRaises(TypeError, float, array([1, 1])) self.assertRaises(ValueError, bool, array([0, 1])) self.assertRaises(ValueError, bool, array([0, 0], mask=[0, 1])) def test_testScalarArithmetic(self): xm = array(0, mask=1) #TODO FIXME: Find out what the following raises a warning in r8247 err_status = numpy.geterr() try: numpy.seterr(divide='ignore') self.assertTrue((1 / array(0)).mask) finally: numpy.seterr(**err_status) self.assertTrue((1 + xm).mask) self.assertTrue((-xm).mask) self.assertTrue((-xm).mask) self.assertTrue(maximum(xm, xm).mask) self.assertTrue(minimum(xm, xm).mask) self.assertTrue(xm.filled().dtype is xm._data.dtype) x = array(0, mask=0) self.assertTrue(x.filled() == x._data) self.assertEqual(str(xm), str(masked_print_option)) def test_testArrayMethods(self): a = array([1, 3, 2]) b = array([1, 3, 2], mask=[1, 0, 1]) self.assertTrue(eq(a.any(), a._data.any())) self.assertTrue(eq(a.all(), a._data.all())) self.assertTrue(eq(a.argmax(), a._data.argmax())) self.assertTrue(eq(a.argmin(), a._data.argmin())) self.assertTrue(eq(a.choose(0, 1, 2, 3, 4), a._data.choose(0, 1, 2, 3, 4))) self.assertTrue(eq(a.compress([1, 0, 1]), a._data.compress([1, 0, 1]))) self.assertTrue(eq(a.conj(), a._data.conj())) self.assertTrue(eq(a.conjugate(), a._data.conjugate())) m = array([[1, 2], [3, 4]]) self.assertTrue(eq(m.diagonal(), m._data.diagonal())) self.assertTrue(eq(a.sum(), a._data.sum())) self.assertTrue(eq(a.take([1, 2]), a._data.take([1, 2]))) self.assertTrue(eq(m.transpose(), m._data.transpose())) def test_testArrayAttributes(self): a = array([1, 3, 2]) b = array([1, 3, 2], mask=[1, 0, 1]) self.assertEqual(a.ndim, 1) def test_testAPI(self): self.assertFalse([m for m in dir(numpy.ndarray) if m not in dir(MaskedArray) and not m.startswith('_')]) def test_testSingleElementSubscript(self): a = array([1, 3, 2]) b = array([1, 3, 2], mask=[1, 0, 1]) self.assertEqual(a[0].shape, ()) self.assertEqual(b[0].shape, ()) self.assertEqual(b[1].shape, ()) class TestUfuncs(TestCase): def setUp(self): self.d = (array([1.0, 0, -1, pi / 2] * 2, mask=[0, 1] + [0] * 6), array([1.0, 0, -1, pi / 2] * 2, mask=[1, 0] + [0] * 6),) def test_testUfuncRegression(self): f_invalid_ignore = ['sqrt', 'arctanh', 'arcsin', 'arccos', 'arccosh', 'arctanh', 'log', 'log10', 'divide', 'true_divide', 'floor_divide', 'remainder', 'fmod'] for f in ['sqrt', 'log', 'log10', 'exp', 'conjugate', 'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh', 'absolute', 'fabs', 'negative', # 'nonzero', 'around', 'floor', 'ceil', # 'sometrue', 'alltrue', 'logical_not', 'add', 'subtract', 'multiply', 'divide', 'true_divide', 'floor_divide', 'remainder', 'fmod', 'hypot', 'arctan2', 'equal', 'not_equal', 'less_equal', 'greater_equal', 'less', 'greater', 'logical_and', 'logical_or', 'logical_xor', ]: try: uf = getattr(umath, f) except AttributeError: uf = getattr(fromnumeric, f) mf = getattr(numpy.ma, f) args = self.d[:uf.nin] olderr = numpy.geterr() try: if f in f_invalid_ignore: numpy.seterr(invalid='ignore') if f in ['arctanh', 'log', 'log10']: numpy.seterr(divide='ignore') ur = uf(*args) mr = mf(*args) finally: numpy.seterr(**olderr) self.assertTrue(eq(ur.filled(0), mr.filled(0), f)) self.assertTrue(eqmask(ur.mask, mr.mask)) def test_reduce(self): a = self.d[0] self.assertFalse(alltrue(a, axis=0)) self.assertTrue(sometrue(a, axis=0)) self.assertEqual(sum(a[:3], axis=0), 0) self.assertEqual(product(a, axis=0), 0) def test_minmax(self): a = arange(1, 13).reshape(3, 4) amask = masked_where(a < 5, a) self.assertEqual(amask.max(), a.max()) self.assertEqual(amask.min(), 5) self.assertTrue((amask.max(0) == a.max(0)).all()) self.assertTrue((amask.min(0) == [5, 6, 7, 8]).all()) self.assertTrue(amask.max(1)[0].mask) self.assertTrue(amask.min(1)[0].mask) def test_nonzero(self): for t in "?bhilqpBHILQPfdgFDGO": x = array([1, 0, 2, 0], mask=[0, 0, 1, 1]) self.assertTrue(eq(nonzero(x), [0])) class TestArrayMethods(TestCase): def setUp(self): x = numpy.array([ 8.375, 7.545, 8.828, 8.5 , 1.757, 5.928, 8.43 , 7.78 , 9.865, 5.878, 8.979, 4.732, 3.012, 6.022, 5.095, 3.116, 5.238, 3.957, 6.04 , 9.63 , 7.712, 3.382, 4.489, 6.479, 7.189, 9.645, 5.395, 4.961, 9.894, 2.893, 7.357, 9.828, 6.272, 3.758, 6.693, 0.993]) X = x.reshape(6, 6) XX = x.reshape(3, 2, 2, 3) m = numpy.array([0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0]) mx = array(data=x, mask=m) mX = array(data=X, mask=m.reshape(X.shape)) mXX = array(data=XX, mask=m.reshape(XX.shape)) m2 = numpy.array([1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1]) m2x = array(data=x, mask=m2) m2X = array(data=X, mask=m2.reshape(X.shape)) m2XX = array(data=XX, mask=m2.reshape(XX.shape)) self.d = (x, X, XX, m, mx, mX, mXX) #------------------------------------------------------ def test_trace(self): (x, X, XX, m, mx, mX, mXX,) = self.d mXdiag = mX.diagonal() self.assertEqual(mX.trace(), mX.diagonal().compressed().sum()) self.assertTrue(eq(mX.trace(), X.trace() - sum(mXdiag.mask * X.diagonal(), axis=0))) def test_clip(self): (x, X, XX, m, mx, mX, mXX,) = self.d clipped = mx.clip(2, 8) self.assertTrue(eq(clipped.mask, mx.mask)) self.assertTrue(eq(clipped._data, x.clip(2, 8))) self.assertTrue(eq(clipped._data, mx._data.clip(2, 8))) def test_ptp(self): (x, X, XX, m, mx, mX, mXX,) = self.d (n, m) = X.shape self.assertEqual(mx.ptp(), mx.compressed().ptp()) rows = numpy.zeros(n, numpy.float_) cols = numpy.zeros(m, numpy.float_) for k in range(m): cols[k] = mX[:, k].compressed().ptp() for k in range(n): rows[k] = mX[k].compressed().ptp() self.assertTrue(eq(mX.ptp(0), cols)) self.assertTrue(eq(mX.ptp(1), rows)) def test_swapaxes(self): (x, X, XX, m, mx, mX, mXX,) = self.d mXswapped = mX.swapaxes(0, 1) self.assertTrue(eq(mXswapped[-1], mX[:, -1])) mXXswapped = mXX.swapaxes(0, 2) self.assertEqual(mXXswapped.shape, (2, 2, 3, 3)) def test_cumprod(self): (x, X, XX, m, mx, mX, mXX,) = self.d mXcp = mX.cumprod(0) self.assertTrue(eq(mXcp._data, mX.filled(1).cumprod(0))) mXcp = mX.cumprod(1) self.assertTrue(eq(mXcp._data, mX.filled(1).cumprod(1))) def test_cumsum(self): (x, X, XX, m, mx, mX, mXX,) = self.d mXcp = mX.cumsum(0) self.assertTrue(eq(mXcp._data, mX.filled(0).cumsum(0))) mXcp = mX.cumsum(1) self.assertTrue(eq(mXcp._data, mX.filled(0).cumsum(1))) def test_varstd(self): (x, X, XX, m, mx, mX, mXX,) = self.d self.assertTrue(eq(mX.var(axis=None), mX.compressed().var())) self.assertTrue(eq(mX.std(axis=None), mX.compressed().std())) self.assertTrue(eq(mXX.var(axis=3).shape, XX.var(axis=3).shape)) self.assertTrue(eq(mX.var().shape, X.var().shape)) (mXvar0, mXvar1) = (mX.var(axis=0), mX.var(axis=1)) for k in range(6): self.assertTrue(eq(mXvar1[k], mX[k].compressed().var())) self.assertTrue(eq(mXvar0[k], mX[:, k].compressed().var())) self.assertTrue(eq(numpy.sqrt(mXvar0[k]), mX[:, k].compressed().std())) def eqmask(m1, m2): if m1 is nomask: return m2 is nomask if m2 is nomask: return m1 is nomask return (m1 == m2).all() #def timingTest(): # for f in [testf, testinplace]: # for n in [1000,10000,50000]: # t = testta(n, f) # t1 = testtb(n, f) # t2 = testtc(n, f) # print f.test_name # print """\ #n = %7d #numpy time (ms) %6.1f #MA maskless ratio %6.1f #MA masked ratio %6.1f #""" % (n, t*1000.0, t1/t, t2/t) #def testta(n, f): # x=numpy.arange(n) + 1.0 # tn0 = time.time() # z = f(x) # return time.time() - tn0 #def testtb(n, f): # x=arange(n) + 1.0 # tn0 = time.time() # z = f(x) # return time.time() - tn0 #def testtc(n, f): # x=arange(n) + 1.0 # x[0] = masked # tn0 = time.time() # z = f(x) # return time.time() - tn0 #def testf(x): # for i in range(25): # y = x **2 + 2.0 * x - 1.0 # w = x **2 + 1.0 # z = (y / w) ** 2 # return z #testf.test_name = 'Simple arithmetic' #def testinplace(x): # for i in range(25): # y = x**2 # y += 2.0*x # y -= 1.0 # y /= x # return y #testinplace.test_name = 'Inplace operations' if __name__ == "__main__": run_module_suite()
mit
[ 646, 2680, 199, 646, 2943, 199, 504, 2680, 14, 391, 492, 627, 199, 504, 2680, 14, 1018, 14, 10563, 322, 9798, 492, 2069, 708, 199, 504, 2680, 14, 391, 14, 1018, 492, 399, 3442, 199, 504, 2680, 14, 4776, 492, 627, 199, 199, 646, 984, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 687, 9143, 492, 7114, 199, 199, 1038, 275, 2680, 14, 1038, 199, 318, 3850, 8, 86, 12, 336, 12, 1499, 9280, 272, 754, 275, 1006, 1600, 8, 86, 12, 336, 9, 272, 340, 440, 754, 26, 267, 870, 408, 1763, 3850, 2689, 83, 199, 5, 83, 199, 375, 199, 5, 83, 624, 450, 334, 1328, 12, 620, 8, 86, 395, 620, 8, 87, 430, 272, 372, 754, 199, 199, 533, 1379, 11903, 8, 1746, 304, 272, 347, 3613, 334, 277, 304, 267, 671, 275, 2680, 14, 1144, 779, 17, 2020, 413, 2020, 413, 2020, 446, 18, 2020, 6682, 1182, 499, 14, 16, 12, 841, 2020, 959, 2020, 446, 709, 2020, 1616, 2020, 413, 2020, 499, 2020, 650, 14444, 267, 612, 275, 2680, 14, 1144, 779, 21, 2020, 378, 2020, 650, 2020, 499, 2020, 446, 17, 2020, 446, 20, 2020, 378, 2020, 446, 709, 2020, 1616, 2020, 413, 2020, 378, 2020, 650, 14444, 267, 282, 709, 275, 1616, 14, 267, 333, 17, 275, 359, 17, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 61, 267, 333, 18, 275, 359, 16, 12, 378, 12, 413, 12, 378, 12, 378, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 2360, 378, 12, 413, 61, 267, 17725, 275, 1625, 8, 88, 12, 3656, 29, 77, 17, 9, 267, 612, 77, 275, 1625, 8, 89, 12, 3656, 29, 77, 18, 9, 267, 1315, 275, 2680, 14, 1144, 11468, 14, 21, 12, 378, 2020, 1275, 21, 12, 1275, 24, 566, 267, 1315, 77, 275, 1625, 8, 90, 12, 3656, 1524, 16, 12, 413, 12, 378, 12, 378, 566, 267, 27366, 275, 2680, 14, 4509, 8, 77, 17, 12, 413, 69, 11, 1165, 12, 671, 9, 267, 308, 275, 671, 14, 1392, 267, 17725, 14, 409, 63, 4498, 63, 585, 8, 17, 69, 11, 1165, 9, 267, 291, 14, 68, 275, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 339, 347, 511, 63, 396, 6845, 17, 68, 8, 277, 304, 267, 298, 774, 402, 5678, 1625, 7143, 436, 4382, 315, 413, 6240, 2122, 267, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 267, 291, 14, 3334, 8, 374, 5144, 20999, 8, 88, 430, 267, 291, 14, 1815, 8, 374, 5144, 20999, 8, 10198, 430, 267, 291, 14, 629, 8, 1392, 8, 10198, 395, 308, 9, 267, 291, 14, 629, 8, 10198, 14, 1392, 12, 308, 9, 267, 291, 14, 629, 8, 10198, 14, 2271, 12, 671, 14, 2271, 9, 267, 291, 14, 629, 8, 10198, 14, 890, 2360, 7114, 8, 2734, 671, 12, 612, 26, 88, 627, 612, 12, 308, 430, 267, 291, 14, 629, 8, 835, 8, 10198, 9, 2360, 822, 8, 77, 17, 9, 446, 7114, 8, 2734, 671, 12, 612, 26, 88, 435, 612, 12, 333, 17, 430, 267, 291, 14, 1815, 8, 4077, 8, 10198, 12, 27366, 430, 267, 291, 14, 1815, 8, 4077, 8, 17647, 8, 10198, 12, 413, 14, 69, 1165, 395, 27366, 430, 267, 291, 14, 1815, 8, 4077, 8, 88, 12, 17725, 430, 339, 347, 511, 63, 396, 6845, 18, 68, 8, 277, 304, 267, 298, 774, 402, 5678, 1625, 7143, 436, 4382, 315, 499, 7365, 2122, 267, 367, 308, 315, 3842, 20, 12, 650, 395, 334, 22, 12, 499, 19532, 288, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 288, 671, 14, 1392, 275, 308, 288, 612, 14, 1392, 275, 308, 288, 17725, 14, 1392, 275, 308, 288, 612, 77, 14, 1392, 275, 308, 288, 27366, 14, 1392, 275, 308, 953, 291, 14, 3334, 8, 374, 5144, 20999, 8, 88, 430, 288, 291, 14, 1815, 8, 374, 5144, 20999, 8, 10198, 430, 288, 291, 14, 629, 8, 1392, 8, 10198, 395, 308, 9, 288, 291, 14, 629, 8, 10198, 14, 1392, 12, 308, 9, 288, 291, 14, 629, 8, 10198, 14, 890, 2360, 7114, 8, 2734, 671, 12, 612, 26, 88, 627, 612, 12, 308, 430, 288, 291, 14, 629, 8, 835, 8, 10198, 9, 2360, 822, 8, 77, 17, 9, 446, 7114, 8, 2734, 671, 12, 612, 26, 88, 435, 612, 12, 333, 17, 430, 288, 291, 14, 1815, 8, 4077, 8, 10198, 12, 27366, 430, 288, 291, 14, 1815, 8, 4077, 8, 17647, 8, 10198, 12, 413, 14, 69, 1165, 395, 27366, 430, 288, 291, 14, 1815, 8, 4077, 8, 88, 12, 17725, 430, 288, 291, 14, 5996, 342, 339, 347, 511, 63, 396, 26291, 18764, 334, 277, 304, 267, 298, 774, 402, 5678, 24166, 2122, 267, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 267, 282, 18, 68, 275, 1625, 4038, 17, 12, 499, 467, 359, 16, 12, 841, 3934, 267, 282, 18, 6428, 275, 9742, 63, 1144, 8, 65, 18, 68, 12, 3474, 16, 12, 378, 467, 359, 17, 12, 378, 3934, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 627, 282, 18, 68, 12, 282, 18, 68, 627, 282, 18, 6428, 430, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 435, 282, 18, 68, 12, 282, 18, 68, 435, 282, 18, 6428, 430, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 446, 282, 18, 68, 12, 282, 18, 68, 446, 282, 18, 6428, 430, 267, 367, 308, 315, 3842, 713, 4706, 334, 20, 12, 650 ]
[ 2680, 199, 646, 2943, 199, 504, 2680, 14, 391, 492, 627, 199, 504, 2680, 14, 1018, 14, 10563, 322, 9798, 492, 2069, 708, 199, 504, 2680, 14, 391, 14, 1018, 492, 399, 3442, 199, 504, 2680, 14, 4776, 492, 627, 199, 199, 646, 984, 199, 692, 984, 14, 1023, 63, 815, 59, 16, 61, 2356, 650, 26, 272, 687, 9143, 492, 7114, 199, 199, 1038, 275, 2680, 14, 1038, 199, 318, 3850, 8, 86, 12, 336, 12, 1499, 9280, 272, 754, 275, 1006, 1600, 8, 86, 12, 336, 9, 272, 340, 440, 754, 26, 267, 870, 408, 1763, 3850, 2689, 83, 199, 5, 83, 199, 375, 199, 5, 83, 624, 450, 334, 1328, 12, 620, 8, 86, 395, 620, 8, 87, 430, 272, 372, 754, 199, 199, 533, 1379, 11903, 8, 1746, 304, 272, 347, 3613, 334, 277, 304, 267, 671, 275, 2680, 14, 1144, 779, 17, 2020, 413, 2020, 413, 2020, 446, 18, 2020, 6682, 1182, 499, 14, 16, 12, 841, 2020, 959, 2020, 446, 709, 2020, 1616, 2020, 413, 2020, 499, 2020, 650, 14444, 267, 612, 275, 2680, 14, 1144, 779, 21, 2020, 378, 2020, 650, 2020, 499, 2020, 446, 17, 2020, 446, 20, 2020, 378, 2020, 446, 709, 2020, 1616, 2020, 413, 2020, 378, 2020, 650, 14444, 267, 282, 709, 275, 1616, 14, 267, 333, 17, 275, 359, 17, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 12, 413, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 61, 267, 333, 18, 275, 359, 16, 12, 378, 12, 413, 12, 378, 12, 378, 12, 413, 12, 413, 12, 378, 12, 378, 12, 378, 2360, 378, 12, 413, 61, 267, 17725, 275, 1625, 8, 88, 12, 3656, 29, 77, 17, 9, 267, 612, 77, 275, 1625, 8, 89, 12, 3656, 29, 77, 18, 9, 267, 1315, 275, 2680, 14, 1144, 11468, 14, 21, 12, 378, 2020, 1275, 21, 12, 1275, 24, 566, 267, 1315, 77, 275, 1625, 8, 90, 12, 3656, 1524, 16, 12, 413, 12, 378, 12, 378, 566, 267, 27366, 275, 2680, 14, 4509, 8, 77, 17, 12, 413, 69, 11, 1165, 12, 671, 9, 267, 308, 275, 671, 14, 1392, 267, 17725, 14, 409, 63, 4498, 63, 585, 8, 17, 69, 11, 1165, 9, 267, 291, 14, 68, 275, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 339, 347, 511, 63, 396, 6845, 17, 68, 8, 277, 304, 267, 298, 774, 402, 5678, 1625, 7143, 436, 4382, 315, 413, 6240, 2122, 267, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 267, 291, 14, 3334, 8, 374, 5144, 20999, 8, 88, 430, 267, 291, 14, 1815, 8, 374, 5144, 20999, 8, 10198, 430, 267, 291, 14, 629, 8, 1392, 8, 10198, 395, 308, 9, 267, 291, 14, 629, 8, 10198, 14, 1392, 12, 308, 9, 267, 291, 14, 629, 8, 10198, 14, 2271, 12, 671, 14, 2271, 9, 267, 291, 14, 629, 8, 10198, 14, 890, 2360, 7114, 8, 2734, 671, 12, 612, 26, 88, 627, 612, 12, 308, 430, 267, 291, 14, 629, 8, 835, 8, 10198, 9, 2360, 822, 8, 77, 17, 9, 446, 7114, 8, 2734, 671, 12, 612, 26, 88, 435, 612, 12, 333, 17, 430, 267, 291, 14, 1815, 8, 4077, 8, 10198, 12, 27366, 430, 267, 291, 14, 1815, 8, 4077, 8, 17647, 8, 10198, 12, 413, 14, 69, 1165, 395, 27366, 430, 267, 291, 14, 1815, 8, 4077, 8, 88, 12, 17725, 430, 339, 347, 511, 63, 396, 6845, 18, 68, 8, 277, 304, 267, 298, 774, 402, 5678, 1625, 7143, 436, 4382, 315, 499, 7365, 2122, 267, 367, 308, 315, 3842, 20, 12, 650, 395, 334, 22, 12, 499, 19532, 288, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 288, 671, 14, 1392, 275, 308, 288, 612, 14, 1392, 275, 308, 288, 17725, 14, 1392, 275, 308, 288, 612, 77, 14, 1392, 275, 308, 288, 27366, 14, 1392, 275, 308, 953, 291, 14, 3334, 8, 374, 5144, 20999, 8, 88, 430, 288, 291, 14, 1815, 8, 374, 5144, 20999, 8, 10198, 430, 288, 291, 14, 629, 8, 1392, 8, 10198, 395, 308, 9, 288, 291, 14, 629, 8, 10198, 14, 1392, 12, 308, 9, 288, 291, 14, 629, 8, 10198, 14, 890, 2360, 7114, 8, 2734, 671, 12, 612, 26, 88, 627, 612, 12, 308, 430, 288, 291, 14, 629, 8, 835, 8, 10198, 9, 2360, 822, 8, 77, 17, 9, 446, 7114, 8, 2734, 671, 12, 612, 26, 88, 435, 612, 12, 333, 17, 430, 288, 291, 14, 1815, 8, 4077, 8, 10198, 12, 27366, 430, 288, 291, 14, 1815, 8, 4077, 8, 17647, 8, 10198, 12, 413, 14, 69, 1165, 395, 27366, 430, 288, 291, 14, 1815, 8, 4077, 8, 88, 12, 17725, 430, 288, 291, 14, 5996, 342, 339, 347, 511, 63, 396, 26291, 18764, 334, 277, 304, 267, 298, 774, 402, 5678, 24166, 2122, 267, 334, 88, 12, 612, 12, 282, 709, 12, 333, 17, 12, 333, 18, 12, 17725, 12, 612, 77, 12, 1315, 12, 1315, 77, 12, 27366, 12, 308, 9, 275, 291, 14, 68, 267, 282, 18, 68, 275, 1625, 4038, 17, 12, 499, 467, 359, 16, 12, 841, 3934, 267, 282, 18, 6428, 275, 9742, 63, 1144, 8, 65, 18, 68, 12, 3474, 16, 12, 378, 467, 359, 17, 12, 378, 3934, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 627, 282, 18, 68, 12, 282, 18, 68, 627, 282, 18, 6428, 430, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 435, 282, 18, 68, 12, 282, 18, 68, 435, 282, 18, 6428, 430, 267, 291, 14, 1815, 8, 4077, 334, 65, 18, 68, 446, 282, 18, 68, 12, 282, 18, 68, 446, 282, 18, 6428, 430, 267, 367, 308, 315, 3842, 713, 4706, 334, 20, 12, 650, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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ationpage.py
2
23776
#!/usr/bin/env python # # BitBake Graphical GTK User Interface # # Copyright (C) 2012 Intel Corporation # # Authored by Dongxiao Xu <dongxiao.xu@intel.com> # Authored by Shane Wang <shane.wang@intel.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 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, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import gtk import glib import re from bb.ui.crumbs.progressbar import HobProgressBar from bb.ui.crumbs.hobcolor import HobColors from bb.ui.crumbs.hobwidget import hic, HobImageButton, HobInfoButton, HobAltButton, HobButton from bb.ui.crumbs.hoblistmodel import RecipeListModel from bb.ui.crumbs.hobpages import HobPage from bb.ui.crumbs.hig.retrieveimagedialog import RetrieveImageDialog # # ImageConfigurationPage # class ImageConfigurationPage (HobPage): __dummy_machine__ = "--select a machine--" __dummy_image__ = "--select an image recipe--" __custom_image__ = "Select from my image recipes" def __init__(self, builder): super(ImageConfigurationPage, self).__init__(builder, "Image configuration") self.image_combo_id = None # we use machine_combo_changed_by_manual to identify the machine is changed by code # or by manual. If by manual, all user's recipe selection and package selection are # cleared. self.machine_combo_changed_by_manual = True self.stopping = False self.warning_shift = 0 self.custom_image_selected = None self.create_visual_elements() def create_visual_elements(self): # create visual elements self.toolbar = gtk.Toolbar() self.toolbar.set_orientation(gtk.ORIENTATION_HORIZONTAL) self.toolbar.set_style(gtk.TOOLBAR_BOTH) my_images_button = self.append_toolbar_button(self.toolbar, "Images", hic.ICON_IMAGES_DISPLAY_FILE, hic.ICON_IMAGES_HOVER_FILE, "Open previously built images", self.my_images_button_clicked_cb) settings_button = self.append_toolbar_button(self.toolbar, "Settings", hic.ICON_SETTINGS_DISPLAY_FILE, hic.ICON_SETTINGS_HOVER_FILE, "View additional build settings", self.settings_button_clicked_cb) self.config_top_button = self.add_onto_top_bar(self.toolbar) self.gtable = gtk.Table(40, 40, True) self.create_config_machine() self.create_config_baseimg() self.config_build_button = self.create_config_build_button() def _remove_all_widget(self): children = self.gtable.get_children() or [] for child in children: self.gtable.remove(child) children = self.box_group_area.get_children() or [] for child in children: self.box_group_area.remove(child) children = self.get_children() or [] for child in children: self.remove(child) def _pack_components(self, pack_config_build_button = False): self._remove_all_widget() self.pack_start(self.config_top_button, expand=False, fill=False) self.pack_start(self.group_align, expand=True, fill=True) self.box_group_area.pack_start(self.gtable, expand=True, fill=True) if pack_config_build_button: self.box_group_area.pack_end(self.config_build_button, expand=False, fill=False) else: box = gtk.HBox(False, 6) box.show() subbox = gtk.HBox(False, 0) subbox.set_size_request(205, 49) subbox.show() box.add(subbox) self.box_group_area.pack_end(box, False, False) def show_machine(self): self.progress_bar.reset() self._pack_components(pack_config_build_button = False) self.set_config_machine_layout(show_progress_bar = False) self.show_all() def update_progress_bar(self, title, fraction, status=None): if self.stopping == False: self.progress_bar.update(fraction) self.progress_bar.set_text(title) self.progress_bar.set_rcstyle(status) def show_info_populating(self): self._pack_components(pack_config_build_button = False) self.set_config_machine_layout(show_progress_bar = True) self.show_all() def show_info_populated(self): self.progress_bar.reset() self._pack_components(pack_config_build_button = False) self.set_config_machine_layout(show_progress_bar = False) self.set_config_baseimg_layout() self.show_all() def show_baseimg_selected(self): self.progress_bar.reset() self._pack_components(pack_config_build_button = True) self.set_config_machine_layout(show_progress_bar = False) self.set_config_baseimg_layout() self.show_all() if self.builder.recipe_model.get_selected_image() == self.builder.recipe_model.__custom_image__: self.just_bake_button.hide() def add_warnings_bar(self): #create the warnings bar shown when recipes parsing generates warnings color = HobColors.KHAKI warnings_bar = gtk.EventBox() warnings_bar.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) warnings_bar.set_flags(gtk.CAN_DEFAULT) warnings_bar.grab_default() build_stop_tab = gtk.Table(10, 20, True) warnings_bar.add(build_stop_tab) icon = gtk.Image() icon_pix_buffer = gtk.gdk.pixbuf_new_from_file(hic.ICON_INDI_ALERT_FILE) icon.set_from_pixbuf(icon_pix_buffer) build_stop_tab.attach(icon, 0, 2, 0, 10) label = gtk.Label() label.set_alignment(0.0, 0.5) warnings_nb = len(self.builder.parsing_warnings) if warnings_nb == 1: label.set_markup("<span size='x-large'><b>1 recipe parsing warning</b></span>") else: label.set_markup("<span size='x-large'><b>%s recipe parsing warnings</b></span>" % warnings_nb) build_stop_tab.attach(label, 2, 12, 0, 10) view_warnings_button = HobButton("View warnings") view_warnings_button.connect('clicked', self.view_warnings_button_clicked_cb) build_stop_tab.attach(view_warnings_button, 15, 19, 1, 9) return warnings_bar def disable_warnings_bar(self): if self.builder.parsing_warnings: if hasattr(self, 'warnings_bar'): self.warnings_bar.hide_all() self.builder.parsing_warnings = [] def create_config_machine(self): self.machine_title = gtk.Label() self.machine_title.set_alignment(0.0, 0.5) mark = "<span %s>Select a machine</span>" % self.span_tag('x-large', 'bold') self.machine_title.set_markup(mark) self.machine_title_desc = gtk.Label() self.machine_title_desc.set_alignment(0.0, 0.5) mark = ("<span %s>Your selection is the profile of the target machine for which you" " are building the image.\n</span>") % (self.span_tag('medium')) self.machine_title_desc.set_markup(mark) self.machine_combo = gtk.combo_box_new_text() self.machine_combo.connect("changed", self.machine_combo_changed_cb) icon_file = hic.ICON_LAYERS_DISPLAY_FILE hover_file = hic.ICON_LAYERS_HOVER_FILE self.layer_button = HobImageButton("Layers", "Add support for machines, software, etc.", icon_file, hover_file) self.layer_button.connect("clicked", self.layer_button_clicked_cb) markup = "Layers are a powerful mechanism to extend the Yocto Project " markup += "with your own functionality.\n" markup += "For more on layers, check the <a href=\"" markup += "http://www.yoctoproject.org/docs/current/dev-manual/" markup += "dev-manual.html#understanding-and-using-layers\">reference manual</a>." self.layer_info_icon = HobInfoButton("<b>Layers</b>" + "*" + markup, self.get_parent()) self.progress_bar = HobProgressBar() self.stop_button = HobAltButton("Stop") self.stop_button.connect("clicked", self.stop_button_clicked_cb) self.machine_separator = gtk.HSeparator() def set_config_machine_layout(self, show_progress_bar = False): self.gtable.attach(self.machine_title, 0, 40, 0, 4) self.gtable.attach(self.machine_title_desc, 0, 40, 4, 6) self.gtable.attach(self.machine_combo, 0, 12, 7, 10) self.gtable.attach(self.layer_button, 14, 36, 7, 12) self.gtable.attach(self.layer_info_icon, 36, 40, 7, 11) if show_progress_bar: #self.gtable.attach(self.progress_box, 0, 40, 15, 18) self.gtable.attach(self.progress_bar, 0, 37, 15, 18) self.gtable.attach(self.stop_button, 37, 40, 15, 18, 0, 0) if self.builder.parsing_warnings: self.warnings_bar = self.add_warnings_bar() self.gtable.attach(self.warnings_bar, 0, 40, 14, 18) self.warning_shift = 4 else: self.warning_shift = 0 self.gtable.attach(self.machine_separator, 0, 40, 13, 14) def create_config_baseimg(self): self.image_title = gtk.Label() self.image_title.set_alignment(0, 1.0) mark = "<span %s>Select an image recipe</span>" % self.span_tag('x-large', 'bold') self.image_title.set_markup(mark) self.image_title_desc = gtk.Label() self.image_title_desc.set_alignment(0, 0.5) mark = ("<span %s>Image recipes are a starting point for the type of image you want. " "You can build them as \n" "they are or edit them to suit your needs.\n</span>") % self.span_tag('medium') self.image_title_desc.set_markup(mark) self.image_combo = gtk.combo_box_new_text() self.image_combo.set_row_separator_func(self.combo_separator_func, None) self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb) self.image_desc = gtk.Label() self.image_desc.set_alignment(0.0, 0.5) self.image_desc.set_size_request(256, -1) self.image_desc.set_justify(gtk.JUSTIFY_LEFT) self.image_desc.set_line_wrap(True) # button to view recipes icon_file = hic.ICON_RCIPE_DISPLAY_FILE hover_file = hic.ICON_RCIPE_HOVER_FILE self.view_adv_configuration_button = HobImageButton("Advanced configuration", "Select image types, package formats, etc", icon_file, hover_file) self.view_adv_configuration_button.connect("clicked", self.view_adv_configuration_button_clicked_cb) self.image_separator = gtk.HSeparator() def combo_separator_func(self, model, iter, user_data): name = model.get_value(iter, 0) if name == "--Separator--": return True def set_config_baseimg_layout(self): self.gtable.attach(self.image_title, 0, 40, 15+self.warning_shift, 17+self.warning_shift) self.gtable.attach(self.image_title_desc, 0, 40, 18+self.warning_shift, 22+self.warning_shift) self.gtable.attach(self.image_combo, 0, 12, 23+self.warning_shift, 26+self.warning_shift) self.gtable.attach(self.image_desc, 0, 12, 27+self.warning_shift, 33+self.warning_shift) self.gtable.attach(self.view_adv_configuration_button, 14, 36, 23+self.warning_shift, 28+self.warning_shift) self.gtable.attach(self.image_separator, 0, 40, 35+self.warning_shift, 36+self.warning_shift) def create_config_build_button(self): # Create the "Build packages" and "Build image" buttons at the bottom button_box = gtk.HBox(False, 6) # create button "Build image" self.just_bake_button = HobButton("Build image") self.just_bake_button.set_tooltip_text("Build the image recipe as it is") self.just_bake_button.connect("clicked", self.just_bake_button_clicked_cb) button_box.pack_end(self.just_bake_button, expand=False, fill=False) # create button "Edit image recipe" self.edit_image_button = HobAltButton("Edit image recipe") self.edit_image_button.set_tooltip_text("Customize the recipes and packages to be included in your image") self.edit_image_button.connect("clicked", self.edit_image_button_clicked_cb) button_box.pack_end(self.edit_image_button, expand=False, fill=False) return button_box def stop_button_clicked_cb(self, button): self.stopping = True self.progress_bar.set_text("Stopping recipe parsing") self.progress_bar.set_rcstyle("stop") self.builder.cancel_parse_sync() def view_warnings_button_clicked_cb(self, button): self.builder.show_warning_dialog() def machine_combo_changed_idle_cb(self): self.builder.window.set_cursor(None) def machine_combo_changed_cb(self, machine_combo): self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) self.builder.wait(0.1) #wait for combo and cursor to update self.stopping = False self.builder.parsing_warnings = [] combo_item = machine_combo.get_active_text() if not combo_item or combo_item == self.__dummy_machine__: return # remove __dummy_machine__ item from the store list after first user selection # because it is no longer valid combo_store = machine_combo.get_model() if len(combo_store) and (combo_store[0][0] == self.__dummy_machine__): machine_combo.remove_text(0) self.builder.configuration.curr_mach = combo_item if self.machine_combo_changed_by_manual: self.builder.configuration.clear_selection() # reset machine_combo_changed_by_manual self.machine_combo_changed_by_manual = True self.builder.configuration.selected_image = None # Do reparse recipes self.builder.populate_recipe_package_info_async() glib.idle_add(self.machine_combo_changed_idle_cb) def update_machine_combo(self): self.disable_warnings_bar() all_machines = [self.__dummy_machine__] + self.builder.parameters.all_machines model = self.machine_combo.get_model() model.clear() for machine in all_machines: self.machine_combo.append_text(machine) self.machine_combo.set_active(0) def switch_machine_combo(self): self.disable_warnings_bar() self.machine_combo_changed_by_manual = False model = self.machine_combo.get_model() active = 0 while active < len(model): if model[active][0] == self.builder.configuration.curr_mach: self.machine_combo.set_active(active) return active += 1 if model[0][0] != self.__dummy_machine__: self.machine_combo.insert_text(0, self.__dummy_machine__) self.machine_combo.set_active(0) def update_image_desc(self): desc = "" selected_image = self.image_combo.get_active_text() if selected_image and selected_image in self.builder.recipe_model.pn_path.keys(): image_path = self.builder.recipe_model.pn_path[selected_image] image_iter = self.builder.recipe_model.get_iter(image_path) desc = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_DESC) mark = ("<span %s>%s</span>\n") % (self.span_tag('small'), desc) self.image_desc.set_markup(mark) def image_combo_changed_idle_cb(self, selected_image, selected_recipes, selected_packages): self.builder.update_recipe_model(selected_image, selected_recipes) self.builder.update_package_model(selected_packages) self.builder.window_sensitive(True) def image_combo_changed_cb(self, combo): self.builder.window_sensitive(False) selected_image = self.image_combo.get_active_text() if selected_image == self.__custom_image__: topdir = self.builder.get_topdir() images_dir = topdir + "/recipes/images/" self.builder.ensure_dir(images_dir) dialog = RetrieveImageDialog(images_dir, "Select from my image recipes", self.builder, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) response = dialog.run() if response == gtk.RESPONSE_OK: image_name = dialog.get_filename() head, tail = os.path.split(image_name) selected_image = os.path.splitext(tail)[0] self.custom_image_selected = selected_image self.update_image_combo(self.builder.recipe_model, selected_image) else: selected_image = self.__dummy_image__ self.update_image_combo(self.builder.recipe_model, None) dialog.destroy() else: if self.custom_image_selected: self.custom_image_selected = None self.update_image_combo(self.builder.recipe_model, selected_image) if not selected_image or (selected_image == self.__dummy_image__): self.builder.window_sensitive(True) self.just_bake_button.hide() self.edit_image_button.hide() return # remove __dummy_image__ item from the store list after first user selection # because it is no longer valid combo_store = combo.get_model() if len(combo_store) and (combo_store[0][0] == self.__dummy_image__): combo.remove_text(0) self.builder.customized = False selected_recipes = [] image_path = self.builder.recipe_model.pn_path[selected_image] image_iter = self.builder.recipe_model.get_iter(image_path) selected_packages = self.builder.recipe_model.get_value(image_iter, self.builder.recipe_model.COL_INSTALL).split() self.update_image_desc() self.builder.recipe_model.reset() self.builder.package_model.reset() self.show_baseimg_selected() if selected_image == self.builder.recipe_model.__custom_image__: self.just_bake_button.hide() glib.idle_add(self.image_combo_changed_idle_cb, selected_image, selected_recipes, selected_packages) def _image_combo_connect_signal(self): if not self.image_combo_id: self.image_combo_id = self.image_combo.connect("changed", self.image_combo_changed_cb) def _image_combo_disconnect_signal(self): if self.image_combo_id: self.image_combo.disconnect(self.image_combo_id) self.image_combo_id = None def update_image_combo(self, recipe_model, selected_image): # Update the image combo according to the images in the recipe_model # populate image combo filter = {RecipeListModel.COL_TYPE : ['image']} image_model = recipe_model.tree_model(filter) image_model.set_sort_column_id(recipe_model.COL_NAME, gtk.SORT_ASCENDING) active = 0 cnt = 0 white_pattern = [] if self.builder.parameters.image_white_pattern: for i in self.builder.parameters.image_white_pattern.split(): white_pattern.append(re.compile(i)) black_pattern = [] if self.builder.parameters.image_black_pattern: for i in self.builder.parameters.image_black_pattern.split(): black_pattern.append(re.compile(i)) black_pattern.append(re.compile("hob-image")) it = image_model.get_iter_first() self._image_combo_disconnect_signal() model = self.image_combo.get_model() model.clear() # Set a indicator text to combo store when first open if not selected_image: self.image_combo.append_text(self.__dummy_image__) cnt = cnt + 1 self.image_combo.append_text(self.__custom_image__) self.image_combo.append_text("--Separator--") cnt = cnt + 2 topdir = self.builder.get_topdir() # append and set active while it: path = image_model.get_path(it) it = image_model.iter_next(it) image_name = image_model[path][recipe_model.COL_NAME] if image_name == self.builder.recipe_model.__custom_image__: continue if black_pattern: allow = True for pattern in black_pattern: if pattern.search(image_name): allow = False break elif white_pattern: allow = False for pattern in white_pattern: if pattern.search(image_name): allow = True break else: allow = True file_name = image_model[path][recipe_model.COL_FILE] if file_name and topdir in file_name: allow = False if allow: self.image_combo.append_text(image_name) if image_name == selected_image: active = cnt cnt = cnt + 1 self.image_combo.append_text(self.builder.recipe_model.__custom_image__) if selected_image == self.builder.recipe_model.__custom_image__: active = cnt if self.custom_image_selected: self.image_combo.append_text("--Separator--") self.image_combo.append_text(self.custom_image_selected) cnt = cnt + 2 if self.custom_image_selected == selected_image: active = cnt self.image_combo.set_active(active) if active != 0: self.show_baseimg_selected() self._image_combo_connect_signal() def layer_button_clicked_cb(self, button): # Create a layer selection dialog self.builder.show_layer_selection_dialog() def view_adv_configuration_button_clicked_cb(self, button): # Create an advanced settings dialog response, settings_changed = self.builder.show_adv_settings_dialog() if not response: return if settings_changed: self.builder.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) self.builder.wait(0.1) #wait for adv_settings_dialog to terminate self.builder.reparse_post_adv_settings() self.builder.window.set_cursor(None) def just_bake_button_clicked_cb(self, button): self.builder.parsing_warnings = [] self.builder.just_bake() def edit_image_button_clicked_cb(self, button): self.builder.configuration.initial_selected_image = self.builder.configuration.selected_image self.builder.show_recipes() def my_images_button_clicked_cb(self, button): self.builder.show_load_my_images_dialog() def settings_button_clicked_cb(self, button): # Create an advanced settings dialog response, settings_changed = self.builder.show_simple_settings_dialog() if not response: return if settings_changed: self.builder.reparse_post_adv_settings()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 10199, 34, 1728, 11513, 2652, 598, 15263, 2876, 14816, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 263, 20619, 11098, 199, 3, 199, 3, 3590, 2908, 701, 577, 951, 88, 18939, 1323, 85, 665, 19664, 88, 18939, 14, 88, 85, 32, 22264, 14, 957, 30, 199, 3, 3590, 2908, 701, 5244, 5865, 644, 621, 665, 609, 5865, 14, 87, 621, 32, 22264, 14, 957, 30, 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, 1015, 499, 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, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 646, 8116, 199, 646, 486, 773, 199, 646, 295, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 5734, 1700, 492, 869, 2873, 11504, 5281, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 2326, 492, 869, 2873, 20094, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 3440, 492, 394, 530, 12, 869, 2873, 3491, 4259, 12, 869, 2873, 2354, 4259, 12, 869, 2873, 16985, 4259, 12, 869, 2873, 4259, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 513, 1238, 492, 799, 8233, 1296, 1685, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 5856, 492, 869, 2873, 3276, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 72, 528, 14, 14270, 1569, 7196, 492, 13939, 3491, 5619, 199, 199, 3, 199, 3, 6047, 5688, 3276, 199, 3, 199, 533, 6047, 5688, 3276, 334, 40, 2873, 3276, 304, 339, 636, 5869, 63, 6744, 363, 275, 4320, 2416, 282, 6844, 306, 2, 272, 636, 5869, 63, 1569, 363, 257, 275, 4320, 2416, 376, 1834, 17121, 306, 2, 272, 636, 4229, 63, 1569, 363, 221, 275, 298, 5446, 687, 3002, 1834, 17121, 83, 2, 339, 347, 636, 826, 721, 277, 12, 6545, 304, 267, 1613, 8, 3491, 5688, 3276, 12, 291, 2843, 826, 721, 5649, 12, 298, 3491, 2897, 531, 398, 291, 14, 1569, 63, 12650, 63, 344, 275, 488, 267, 327, 781, 675, 6844, 63, 12650, 63, 2489, 63, 991, 63, 9285, 370, 10405, 314, 6844, 365, 2896, 701, 1233, 267, 327, 503, 701, 8722, 14, 982, 701, 8722, 12, 1006, 922, 1159, 17121, 7267, 436, 2559, 7267, 787, 267, 327, 20518, 14, 267, 291, 14, 6744, 63, 12650, 63, 2489, 63, 991, 63, 9285, 275, 715, 267, 291, 14, 2379, 4073, 275, 756, 267, 291, 14, 3764, 63, 4723, 275, 378, 267, 291, 14, 4229, 63, 1569, 63, 5511, 275, 488, 267, 291, 14, 981, 63, 16948, 63, 5527, 342, 339, 347, 1218, 63, 16948, 63, 5527, 8, 277, 304, 267, 327, 1218, 13104, 4008, 267, 291, 14, 13951, 275, 8116, 14, 29630, 342, 267, 291, 14, 13951, 14, 409, 63, 17001, 8, 12275, 14, 726, 25451, 2594, 63, 25968, 9, 267, 291, 14, 13951, 14, 409, 63, 2487, 8, 12275, 14, 9731, 13895, 63, 28784, 9, 398, 3002, 63, 4782, 63, 3887, 275, 291, 14, 740, 63, 13951, 63, 3887, 8, 277, 14, 13951, 12, 288, 298, 18882, 401, 288, 394, 530, 14, 15903, 63, 1469, 5383, 63, 20993, 63, 3817, 12, 288, 394, 530, 14, 15903, 63, 1469, 5383, 63, 2979, 2111, 63, 3817, 12, 288, 298, 4299, 10889, 6137, 5935, 401, 288, 291, 14, 1662, 63, 4782, 63, 3887, 63, 11276, 63, 2894, 9, 267, 2202, 63, 3887, 275, 291, 14, 740, 63, 13951, 63, 3887, 8, 277, 14, 13951, 12, 288, 298, 5268, 401, 288, 394, 530, 14, 15903, 63, 13931, 63, 20993, 63, 3817, 12, 288, 394, 530, 14, 15903, 63, 13931, 63, 2979, 2111, 63, 3817, 12, 288, 298, 2768, 4722, 1900, 2202, 401, 288, 291, 14, 1751, 63, 3887, 63, 11276, 63, 2894, 9, 398, 291, 14, 888, 63, 2119, 63, 3887, 275, 291, 14, 525, 63, 26296, 63, 2119, 63, 1700, 8, 277, 14, 13951, 9, 398, 291, 14, 71, 1224, 275, 8116, 14, 3186, 8, 2167, 12, 6335, 12, 715, 9, 267, 291, 14, 981, 63, 888, 63, 6744, 342, 267, 291, 14, 981, 63, 888, 63, 1095, 4060, 342, 267, 291, 14, 888, 63, 1506, 63, 3887, 275, 291, 14, 981, 63, 888, 63, 1506, 63, 3887, 342, 339, 347, 485, 2168, 63, 452, 63, 3440, 8, 277, 304, 267, 4978, 275, 291, 14, 71, 1224, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 71, 1224, 14, 2168, 8, 1739, 9, 267, 4978, 275, 291, 14, 1977, 63, 923, 63, 6789, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 1977, 63, 923, 63, 6789, 14, 2168, 8, 1739, 9, 267, 4978, 275, 291, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 2168, 8, 1739, 9, 339, 347, 485, 1389, 63, 4608, 8, 277, 12, 1706, 63, 888, 63, 1506, 63, 3887, 275, 756, 304, 267, 291, 423, 2168, 63, 452, 63, 3440, 342, 267, 291, 14, 1389, 63, 928, 8, 277, 14, 888, 63, 2119, 63, 3887, 12, 6544, 29, 797, 12, 5554, 29, 797, 9, 267, 291, 14, 1389, 63, 928, 8, 277, 14, 923, 63, 5743, 12, 6544, 29, 549, 12, 5554, 29, 549, 9, 398, 291, 14, 1977, 63, 923, 63, 6789, 14, 1389, 63, 928, 8, 277, 14, 71, 1224, 12, 6544, 29, 549, 12, 5554, 29, 549, 9, 267, 340, 1706, 63, 888, 63, 1506, 63, 3887, 26, 288 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 10199, 34, 1728, 11513, 2652, 598, 15263, 2876, 14816, 199, 3, 199, 3, 1898, 334, 35, 9, 6029, 263, 20619, 11098, 199, 3, 199, 3, 3590, 2908, 701, 577, 951, 88, 18939, 1323, 85, 665, 19664, 88, 18939, 14, 88, 85, 32, 22264, 14, 957, 30, 199, 3, 3590, 2908, 701, 5244, 5865, 644, 621, 665, 609, 5865, 14, 87, 621, 32, 22264, 14, 957, 30, 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, 1015, 499, 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, 3180, 199, 3, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 11315, 13, 10067, 8217, 14, 199, 199, 646, 8116, 199, 646, 486, 773, 199, 646, 295, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 5734, 1700, 492, 869, 2873, 11504, 5281, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 2326, 492, 869, 2873, 20094, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 3440, 492, 394, 530, 12, 869, 2873, 3491, 4259, 12, 869, 2873, 2354, 4259, 12, 869, 2873, 16985, 4259, 12, 869, 2873, 4259, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 513, 1238, 492, 799, 8233, 1296, 1685, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 526, 66, 5856, 492, 869, 2873, 3276, 199, 504, 14027, 14, 1907, 14, 1556, 23135, 14, 72, 528, 14, 14270, 1569, 7196, 492, 13939, 3491, 5619, 199, 199, 3, 199, 3, 6047, 5688, 3276, 199, 3, 199, 533, 6047, 5688, 3276, 334, 40, 2873, 3276, 304, 339, 636, 5869, 63, 6744, 363, 275, 4320, 2416, 282, 6844, 306, 2, 272, 636, 5869, 63, 1569, 363, 257, 275, 4320, 2416, 376, 1834, 17121, 306, 2, 272, 636, 4229, 63, 1569, 363, 221, 275, 298, 5446, 687, 3002, 1834, 17121, 83, 2, 339, 347, 636, 826, 721, 277, 12, 6545, 304, 267, 1613, 8, 3491, 5688, 3276, 12, 291, 2843, 826, 721, 5649, 12, 298, 3491, 2897, 531, 398, 291, 14, 1569, 63, 12650, 63, 344, 275, 488, 267, 327, 781, 675, 6844, 63, 12650, 63, 2489, 63, 991, 63, 9285, 370, 10405, 314, 6844, 365, 2896, 701, 1233, 267, 327, 503, 701, 8722, 14, 982, 701, 8722, 12, 1006, 922, 1159, 17121, 7267, 436, 2559, 7267, 787, 267, 327, 20518, 14, 267, 291, 14, 6744, 63, 12650, 63, 2489, 63, 991, 63, 9285, 275, 715, 267, 291, 14, 2379, 4073, 275, 756, 267, 291, 14, 3764, 63, 4723, 275, 378, 267, 291, 14, 4229, 63, 1569, 63, 5511, 275, 488, 267, 291, 14, 981, 63, 16948, 63, 5527, 342, 339, 347, 1218, 63, 16948, 63, 5527, 8, 277, 304, 267, 327, 1218, 13104, 4008, 267, 291, 14, 13951, 275, 8116, 14, 29630, 342, 267, 291, 14, 13951, 14, 409, 63, 17001, 8, 12275, 14, 726, 25451, 2594, 63, 25968, 9, 267, 291, 14, 13951, 14, 409, 63, 2487, 8, 12275, 14, 9731, 13895, 63, 28784, 9, 398, 3002, 63, 4782, 63, 3887, 275, 291, 14, 740, 63, 13951, 63, 3887, 8, 277, 14, 13951, 12, 288, 298, 18882, 401, 288, 394, 530, 14, 15903, 63, 1469, 5383, 63, 20993, 63, 3817, 12, 288, 394, 530, 14, 15903, 63, 1469, 5383, 63, 2979, 2111, 63, 3817, 12, 288, 298, 4299, 10889, 6137, 5935, 401, 288, 291, 14, 1662, 63, 4782, 63, 3887, 63, 11276, 63, 2894, 9, 267, 2202, 63, 3887, 275, 291, 14, 740, 63, 13951, 63, 3887, 8, 277, 14, 13951, 12, 288, 298, 5268, 401, 288, 394, 530, 14, 15903, 63, 13931, 63, 20993, 63, 3817, 12, 288, 394, 530, 14, 15903, 63, 13931, 63, 2979, 2111, 63, 3817, 12, 288, 298, 2768, 4722, 1900, 2202, 401, 288, 291, 14, 1751, 63, 3887, 63, 11276, 63, 2894, 9, 398, 291, 14, 888, 63, 2119, 63, 3887, 275, 291, 14, 525, 63, 26296, 63, 2119, 63, 1700, 8, 277, 14, 13951, 9, 398, 291, 14, 71, 1224, 275, 8116, 14, 3186, 8, 2167, 12, 6335, 12, 715, 9, 267, 291, 14, 981, 63, 888, 63, 6744, 342, 267, 291, 14, 981, 63, 888, 63, 1095, 4060, 342, 267, 291, 14, 888, 63, 1506, 63, 3887, 275, 291, 14, 981, 63, 888, 63, 1506, 63, 3887, 342, 339, 347, 485, 2168, 63, 452, 63, 3440, 8, 277, 304, 267, 4978, 275, 291, 14, 71, 1224, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 71, 1224, 14, 2168, 8, 1739, 9, 267, 4978, 275, 291, 14, 1977, 63, 923, 63, 6789, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 1977, 63, 923, 63, 6789, 14, 2168, 8, 1739, 9, 267, 4978, 275, 291, 14, 362, 63, 3223, 342, 503, 942, 267, 367, 1982, 315, 4978, 26, 288, 291, 14, 2168, 8, 1739, 9, 339, 347, 485, 1389, 63, 4608, 8, 277, 12, 1706, 63, 888, 63, 1506, 63, 3887, 275, 756, 304, 267, 291, 423, 2168, 63, 452, 63, 3440, 342, 267, 291, 14, 1389, 63, 928, 8, 277, 14, 888, 63, 2119, 63, 3887, 12, 6544, 29, 797, 12, 5554, 29, 797, 9, 267, 291, 14, 1389, 63, 928, 8, 277, 14, 923, 63, 5743, 12, 6544, 29, 549, 12, 5554, 29, 549, 9, 398, 291, 14, 1977, 63, 923, 63, 6789, 14, 1389, 63, 928, 8, 277, 14, 71, 1224, 12, 6544, 29, 549, 12, 5554, 29, 549, 9, 267, 340, 1706, 63, 888, 63, 1506, 63, 3887, 26, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
raffaelespazzoli/origin
vendor/github.com/google/certificate-transparency/cpp/server/ct-dns-server-test.py
33
10792
import base64 import dns.resolver import dns.rdatatype import logging import math import os import random import shlex import signal import subprocess import sys import time NUMBER_OF_CERTS = 100 basepath = os.path.dirname(sys.argv[0]) sys.path.append(os.path.join(basepath, '../../python')) from ct.crypto import merkle from ct.proto import ct_pb2 tmpdir = sys.argv[1] class CTDNSLookup: def __init__(self, nameservers, port): self.resolver = dns.resolver.Resolver(configure=False) self.resolver.nameservers = nameservers self.resolver.port = port def Get(self, name): answers = self.resolver.query(name, 'TXT') assert answers.rdtype == dns.rdatatype.TXT return answers def GetOne(self, name): answers = self.Get(name) assert len(answers) == 1 txt = answers[0] assert len(txt.strings) == 1 return txt.strings[0] def GetSTH(self): sth_str = self.GetOne('sth.example.com') sth = ct_pb2.SignedTreeHead() parts = str(sth_str).split('.') sth.tree_size = int(parts[0]) sth.timestamp = int(parts[1]) sth.sha256_root_hash = base64.b64decode(parts[2]) #FIXME(benl): decompose signature into its parts #sth.signature = base64.b64decode(parts[3]) return sth def GetEntry(self, level, index, size): return self.GetOne(str(level) + '.' + str(index) + '.' + str(size) + '.tree.example.com') def GetLeafHash(self, index): return self.GetOne(str(index) + '.leafhash.example.com') class DNSServerRunner: def Run(self, cmd): args = shlex.split(cmd) self.proc = subprocess.Popen(args) def OpenSSL(*params): logging.info("RUN: openssl " + str(params)) null = open("/dev/null") subprocess.check_call(("openssl",) + params, stdout=null, stderr=null) class timeout: def __init__(self, seconds, error_message='Timeout'): self.seconds = seconds self.error_message = error_message def handle_timeout(self, signum, frame): raise TimeoutError(self.error_message) def __enter__(self): signal.signal(signal.SIGALRM, self.handle_timeout) signal.alarm(self.seconds) def __exit__(self, type, value, traceback): signal.alarm(0) class CTServer: def __init__(self, cmd, base, ca): self.cmd_ = cmd self.base_ = base self.ca_ = ca self.GenerateKey() def __del__(self): self.proc.terminate() self.proc.wait() def PrivateKey(self): return self.base_ + "-ct-server-private-key.pem" def PublicKey(self): return self.base_ + "-ct-server-public-key.pem" def Database(self): return self.base_ + "-database.sqlite" def GenerateKey(self): OpenSSL("ecparam", "-out", self.PrivateKey(), "-name", "secp256r1", "-genkey") OpenSSL("ec", "-in", self.PrivateKey(), "-pubout", "-out", self.PublicKey()) def URL(self): return "http://localhost:9999/" def Run(self): cmd = (self.cmd_ + " -key " + self.PrivateKey() + " -trusted_cert_file " + self.ca_.RootCertificate() + " -sqlite_db " + self.Database() + " -tree_signing_frequency_seconds 1" + " -logtostderr") logging.info("RUN: " + cmd) args = shlex.split(cmd) self.proc = subprocess.Popen(args, stdout=subprocess.PIPE) with timeout(10): while self.proc.stdout.readline() != "READY\n": continue RootConfig = """[ req ] distinguished_name=req_distinguished_name prompt=no x509_extensions=v3_ca [ req_distinguished_name ] countryName=GB stateOrProvinceName=Wales localityName=Erw Wen 0.organizationName=Certificate Transparency Test CA [ v3_ca ] subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer:always basicConstraints=CA:TRUE """ CAConfig = """[ ca ] default_ca = CA_default [ CA_default ] default_startdate = 120601000000Z default_enddate = 220601000000Z default_md = sha1 unique_subject = no email_in_dn = no policy = policy_default serial = {serial} database = {database} [ policy_default ] countryName = supplied organizationName = supplied stateOrProvinceName = optional localityName = optional commonName = optional """ RequestConfig = """[ req ] distinguished_name=req_distinguished_name prompt=no [ req_distinguished_name ] countryName=GB stateOrProvinceName=Wales localityName=Erw Wen 0.organizationName={subject} # For the precert [ pre ] subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer:always basicConstraints=CA:FALSE 1.3.6.1.4.1.11129.2.4.3=critical,ASN1:NULL # For the simple cert, without embedded proof extensions [ simple ] subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer:always basicConstraints=CA:FALSE # For the cert with an embedded proof [ embedded ] subjectKeyIdentifier=hash authorityKeyIdentifier=keyid:always,issuer:always basicConstraints=CA:FALSE """ def WriteFile(name, content): with open(name, "w") as f: f.write(content) class CA: def __init__(self, base): self.base_ = base os.mkdir(self.Directory()) open(self.Database(), "w") WriteFile(self.Serial(), "0000000000000001") WriteFile(self.RootConfig(), RootConfig) ca_config = CAConfig.format(database = self.Database(), serial = self.Serial()) WriteFile(self.CAConfig(), ca_config) self.GenerateRootCertificate() os.mkdir(self.IssuedCertificates()) def Directory(self): """Where the CA does house-keeping""" return self.base_ + "-housekeeping" def Database(self): return self.Directory() + "/database" def Serial(self): return self.Directory() + "/serial" def RootConfig(self): return self.base_ + "-root-config" def CAConfig(self): return self.base_ + "-ca-config" def PrivateKey(self): return self.base_ + "-private-key.pem" def RootCertificate(self): return self.base_ + "-cert.pem" def TempFile(self, name): return self.base_ + "-temp-" + name def RequestConfig(self): return self.TempFile("req-config") def IssuedCertificates(self): return self.base_ + "-issued" def IssuedFile(self, name, subject): return self.IssuedCertificates() + "/" + name + "-" + subject + ".pem" def IssuedPrivateKey(self, subject): return self.IssuedFile("private-key", subject) def IssuedCertificate(self, subject): return self.IssuedFile("certificate", subject) def GenerateRootCertificate(self): csr = self.TempFile("csr") OpenSSL("req", "-new", "-newkey", "rsa:2048", "-keyout", self.PrivateKey(), "-out", csr, "-config", self.RootConfig(), "-nodes") OpenSSL("ca", "-in", csr, "-selfsign", "-keyfile", self.PrivateKey(), "-config", self.CAConfig(), "-extfile", self.RootConfig(), "-extensions", "v3_ca", "-outdir", self.Directory(), "-out", self.RootCertificate(), "-batch") def CreateAndLogCert(self, ct_server, subject): WriteFile(self.RequestConfig(), RequestConfig.format(subject=subject)) csr = self.TempFile("csr") OpenSSL("req", "-new", "-newkey", "rsa:1024", "-keyout", self.IssuedPrivateKey(subject), "-out", csr, "-config", self.RequestConfig(), "-nodes") OpenSSL("ca", "-in", csr, "-cert", self.RootCertificate(), "-keyfile", self.PrivateKey(), "-config", self.CAConfig(), "-extfile", self.RequestConfig(), "-extensions", "simple", "-outdir", self.Directory(), "-out", self.IssuedCertificate(subject), "-batch") # Reverse the order of these to show a bug in ct-server where # it accepts the CA cert even though there's a redundant extra # cert in the chain. At least, I think its a bug. certs = (open(self.IssuedCertificate(subject)).read() + open(self.RootCertificate()).read()) chain_file = self.TempFile("chain") WriteFile(chain_file, certs) subprocess.check_call(("client/ct", "upload", "-ct_server_submission", chain_file, "-ct_server", ct_server.URL(), "-ct_server_public_key", ct_server.PublicKey(), "-ct_server_response_out", self.TempFile("sct"))) logging.basicConfig(level="WARNING") # Set up our test CA ca = CA(tmpdir + "/ct-test-ca") # Run a CT server ct_cmd = basepath + "/ct-server" ct_server = CTServer(ct_cmd, tmpdir + "/ct-test", ca) ct_server.Run() # Add nn certs to the CT server for x in range(NUMBER_OF_CERTS): ca.CreateAndLogCert(ct_server, "TestCertificate" + str(x)) # Make sure server has had enough time to assimilate all certs time.sleep(2) # We'll need the DB for the DNS server db = ct_server.Database() # Kill the CT server (shared database access not currently supported) del ct_server # Now run the DNS server from the same database server_cmd = basepath + "/ct-dns-server --port=1111 --domain=example.com. --db=" + db runner = DNSServerRunner() runner.Run(server_cmd) # Get the STH lookup = CTDNSLookup(['127.0.0.1'], 1111) sth = lookup.GetSTH() logging.info("sth = " + str(sth)) logging.info("size = " + str(sth.tree_size)) assert sth.tree_size == NUMBER_OF_CERTS # test all the entries for index in range(NUMBER_OF_CERTS): leaf_hash = lookup.GetLeafHash(index) logging.info("index = " + str(index) + " hash = " + leaf_hash) verifier = merkle.MerkleVerifier() audit_path = [] for level in range(0, verifier.audit_path_length(index, sth.tree_size)): hash = lookup.GetEntry(level, index, sth.tree_size) logging.info("hash = " + hash) audit_path.append(base64.b64decode(hash)) logging.info("path = " + str(map(base64.b64encode, audit_path))) assert verifier.verify_leaf_hash_inclusion(base64.b64decode(leaf_hash), index, audit_path, sth) print "DNS Server test passed"
apache-2.0
[ 646, 1300, 772, 199, 646, 6715, 14, 7717, 199, 646, 6715, 14, 82, 14184, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 2196, 199, 646, 16701, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 9190, 63, 3359, 63, 11163, 51, 275, 2948, 199, 199, 1095, 515, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 566, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1095, 515, 12, 283, 9707, 1548, 1333, 199, 504, 9428, 14, 10316, 492, 4004, 23572, 199, 504, 9428, 14, 2625, 492, 9428, 63, 3317, 18, 199, 199, 8616, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 533, 24990, 12323, 7521, 26, 272, 347, 636, 826, 721, 277, 12, 536, 5871, 12, 1844, 304, 267, 291, 14, 7717, 275, 6715, 14, 7717, 14, 12407, 8, 6472, 29, 797, 9, 267, 291, 14, 7717, 14, 28620, 275, 536, 5871, 267, 291, 14, 7717, 14, 719, 275, 1844, 339, 347, 2372, 8, 277, 12, 536, 304, 267, 17133, 275, 291, 14, 7717, 14, 1131, 8, 354, 12, 283, 17715, 358, 267, 702, 17133, 14, 82, 2271, 508, 6715, 14, 82, 14184, 14, 17715, 267, 372, 17133, 339, 347, 2372, 4395, 8, 277, 12, 536, 304, 267, 17133, 275, 291, 14, 1002, 8, 354, 9, 267, 702, 822, 8, 13379, 9, 508, 413, 267, 9444, 275, 17133, 59, 16, 61, 267, 702, 822, 8, 2424, 14, 5465, 9, 508, 413, 267, 372, 9444, 14, 5465, 59, 16, 61, 339, 347, 2372, 840, 40, 8, 277, 304, 267, 410, 72, 63, 495, 275, 291, 14, 1002, 4395, 360, 17082, 14, 2694, 14, 957, 358, 267, 410, 72, 275, 9428, 63, 3317, 18, 14, 23013, 3987, 11664, 342, 267, 4184, 275, 620, 8, 17082, 63, 495, 680, 1294, 7563, 267, 410, 72, 14, 2350, 63, 890, 275, 1109, 8, 4181, 59, 16, 566, 267, 410, 72, 14, 3954, 275, 1109, 8, 4181, 59, 17, 566, 267, 410, 72, 14, 4835, 3912, 63, 1231, 63, 2227, 275, 1300, 772, 14, 66, 772, 2708, 8, 4181, 59, 18, 566, 267, 327, 31779, 8, 18486, 76, 304, 477, 12607, 4955, 1901, 2399, 4184, 267, 327, 17082, 14, 5233, 275, 1300, 772, 14, 66, 772, 2708, 8, 4181, 59, 19, 566, 267, 372, 410, 72, 339, 347, 2372, 3900, 8, 277, 12, 2166, 12, 1478, 12, 1568, 304, 267, 372, 291, 14, 1002, 4395, 8, 495, 8, 1896, 9, 435, 7815, 435, 620, 8, 1080, 9, 435, 7815, 435, 620, 8, 890, 9, 2574, 435, 1987, 2350, 14, 2694, 14, 957, 358, 339, 347, 2372, 20475, 3476, 8, 277, 12, 1478, 304, 267, 372, 291, 14, 1002, 4395, 8, 495, 8, 1080, 9, 435, 1987, 8914, 2227, 14, 2694, 14, 957, 358, 199, 199, 533, 10237, 3120, 7446, 26, 272, 347, 3378, 8, 277, 12, 2088, 304, 267, 1249, 275, 16701, 14, 1294, 8, 1760, 9, 267, 291, 14, 4687, 275, 3873, 14, 7942, 8, 589, 9, 199, 199, 318, 14296, 2031, 1162, 304, 272, 2050, 14, 815, 480, 9390, 26, 1551, 4266, 298, 435, 620, 8, 1162, 430, 272, 2973, 275, 1551, 4769, 2374, 15, 2307, 531, 272, 3873, 14, 1074, 63, 1250, 9313, 14837, 26360, 435, 1862, 12, 3839, 29, 2307, 12, 4635, 29, 2307, 9, 199, 199, 533, 2653, 26, 272, 347, 636, 826, 721, 277, 12, 4696, 12, 1125, 63, 1188, 534, 6372, 735, 267, 291, 14, 4515, 275, 4696, 267, 291, 14, 705, 63, 1188, 275, 1125, 63, 1188, 339, 347, 2429, 63, 2593, 8, 277, 12, 2070, 453, 12, 2787, 304, 267, 746, 31886, 8, 277, 14, 705, 63, 1188, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 748, 11026, 12, 291, 14, 2479, 63, 2593, 9, 267, 4673, 14, 14160, 8, 277, 14, 4515, 9, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 4673, 14, 14160, 8, 16, 9, 199, 199, 533, 24990, 3120, 26, 272, 347, 636, 826, 721, 277, 12, 2088, 12, 1300, 12, 1704, 304, 267, 291, 14, 1760, 63, 275, 2088, 267, 291, 14, 1095, 63, 275, 1300, 267, 291, 14, 696, 63, 275, 1704, 267, 291, 14, 6864, 1197, 342, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 4687, 14, 14478, 342, 267, 291, 14, 4687, 14, 2573, 342, 339, 347, 18551, 1197, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 319, 13, 1000, 13, 4239, 13, 498, 14, 13102, 2, 5493, 347, 1684, 1197, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 319, 13, 1000, 13, 3455, 13, 498, 14, 13102, 2, 339, 347, 8692, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 4659, 14, 10659, 2, 339, 347, 7958, 1197, 8, 277, 304, 267, 14296, 480, 825, 635, 401, 355, 3905, 548, 401, 291, 14, 31757, 1062, 355, 3905, 354, 401, 298, 261, 1850, 3912, 82, 17, 401, 355, 3905, 2268, 498, 531, 267, 14296, 480, 825, 401, 355, 3905, 262, 401, 291, 14, 31757, 1062, 355, 3905, 5645, 548, 401, 355, 3905, 548, 401, 291, 14, 26238, 1012, 339, 347, 2851, 8, 277, 304, 267, 372, 298, 1014, 921, 5967, 26, 5008, 6687, 339, 347, 3378, 8, 277, 304, 267, 2088, 275, 334, 277, 14, 1760, 63, 435, 298, 446, 498, 298, 435, 291, 14, 31757, 342, 435, 2049, 298, 446, 17549, 63, 4736, 63, 493, 298, 435, 291, 14, 696, 3754, 6405, 11414, 342, 435, 2049, 298, 446, 10659, 63, 697, 298, 435, 291, 14, 7243, 342, 435, 2049, 298, 446, 2350, 63, 23238, 63, 11132, 63, 4515, 413, 2, 435, 2049, 298, 446, 793, 475, 3083, 531, 267, 2050, 14, 815, 480, 9390, 26, 298, 435, 2088, 9, 267, 1249, 275, 16701, 14, 1294, 8, 1760, 9, 267, 291, 14, 4687, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 267, 543, 2653, 8, 709, 304, 288, 1830, 291, 14, 4687, 14, 2703, 14, 6407, 342, 1137, 298, 22579, 60, 78, 582, 355, 1980, 199, 199, 6405, 2028, 275, 408, 59, 2648, 1622, 199, 2686 ]
[ 1300, 772, 199, 646, 6715, 14, 7717, 199, 646, 6715, 14, 82, 14184, 199, 646, 2050, 199, 646, 3473, 199, 646, 747, 199, 646, 2196, 199, 646, 16701, 199, 646, 4673, 199, 646, 3873, 199, 646, 984, 199, 646, 900, 199, 199, 9190, 63, 3359, 63, 11163, 51, 275, 2948, 199, 199, 1095, 515, 275, 747, 14, 515, 14, 3475, 8, 1274, 14, 3020, 59, 16, 566, 199, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 515, 14, 904, 8, 1095, 515, 12, 283, 9707, 1548, 1333, 199, 504, 9428, 14, 10316, 492, 4004, 23572, 199, 504, 9428, 14, 2625, 492, 9428, 63, 3317, 18, 199, 199, 8616, 275, 984, 14, 3020, 59, 17, 61, 199, 199, 533, 24990, 12323, 7521, 26, 272, 347, 636, 826, 721, 277, 12, 536, 5871, 12, 1844, 304, 267, 291, 14, 7717, 275, 6715, 14, 7717, 14, 12407, 8, 6472, 29, 797, 9, 267, 291, 14, 7717, 14, 28620, 275, 536, 5871, 267, 291, 14, 7717, 14, 719, 275, 1844, 339, 347, 2372, 8, 277, 12, 536, 304, 267, 17133, 275, 291, 14, 7717, 14, 1131, 8, 354, 12, 283, 17715, 358, 267, 702, 17133, 14, 82, 2271, 508, 6715, 14, 82, 14184, 14, 17715, 267, 372, 17133, 339, 347, 2372, 4395, 8, 277, 12, 536, 304, 267, 17133, 275, 291, 14, 1002, 8, 354, 9, 267, 702, 822, 8, 13379, 9, 508, 413, 267, 9444, 275, 17133, 59, 16, 61, 267, 702, 822, 8, 2424, 14, 5465, 9, 508, 413, 267, 372, 9444, 14, 5465, 59, 16, 61, 339, 347, 2372, 840, 40, 8, 277, 304, 267, 410, 72, 63, 495, 275, 291, 14, 1002, 4395, 360, 17082, 14, 2694, 14, 957, 358, 267, 410, 72, 275, 9428, 63, 3317, 18, 14, 23013, 3987, 11664, 342, 267, 4184, 275, 620, 8, 17082, 63, 495, 680, 1294, 7563, 267, 410, 72, 14, 2350, 63, 890, 275, 1109, 8, 4181, 59, 16, 566, 267, 410, 72, 14, 3954, 275, 1109, 8, 4181, 59, 17, 566, 267, 410, 72, 14, 4835, 3912, 63, 1231, 63, 2227, 275, 1300, 772, 14, 66, 772, 2708, 8, 4181, 59, 18, 566, 267, 327, 31779, 8, 18486, 76, 304, 477, 12607, 4955, 1901, 2399, 4184, 267, 327, 17082, 14, 5233, 275, 1300, 772, 14, 66, 772, 2708, 8, 4181, 59, 19, 566, 267, 372, 410, 72, 339, 347, 2372, 3900, 8, 277, 12, 2166, 12, 1478, 12, 1568, 304, 267, 372, 291, 14, 1002, 4395, 8, 495, 8, 1896, 9, 435, 7815, 435, 620, 8, 1080, 9, 435, 7815, 435, 620, 8, 890, 9, 2574, 435, 1987, 2350, 14, 2694, 14, 957, 358, 339, 347, 2372, 20475, 3476, 8, 277, 12, 1478, 304, 267, 372, 291, 14, 1002, 4395, 8, 495, 8, 1080, 9, 435, 1987, 8914, 2227, 14, 2694, 14, 957, 358, 199, 199, 533, 10237, 3120, 7446, 26, 272, 347, 3378, 8, 277, 12, 2088, 304, 267, 1249, 275, 16701, 14, 1294, 8, 1760, 9, 267, 291, 14, 4687, 275, 3873, 14, 7942, 8, 589, 9, 199, 199, 318, 14296, 2031, 1162, 304, 272, 2050, 14, 815, 480, 9390, 26, 1551, 4266, 298, 435, 620, 8, 1162, 430, 272, 2973, 275, 1551, 4769, 2374, 15, 2307, 531, 272, 3873, 14, 1074, 63, 1250, 9313, 14837, 26360, 435, 1862, 12, 3839, 29, 2307, 12, 4635, 29, 2307, 9, 199, 199, 533, 2653, 26, 272, 347, 636, 826, 721, 277, 12, 4696, 12, 1125, 63, 1188, 534, 6372, 735, 267, 291, 14, 4515, 275, 4696, 267, 291, 14, 705, 63, 1188, 275, 1125, 63, 1188, 339, 347, 2429, 63, 2593, 8, 277, 12, 2070, 453, 12, 2787, 304, 267, 746, 31886, 8, 277, 14, 705, 63, 1188, 9, 339, 347, 636, 4200, 721, 277, 304, 267, 4673, 14, 4653, 8, 4653, 14, 7864, 748, 11026, 12, 291, 14, 2479, 63, 2593, 9, 267, 4673, 14, 14160, 8, 277, 14, 4515, 9, 339, 347, 636, 2224, 721, 277, 12, 730, 12, 574, 12, 5190, 304, 267, 4673, 14, 14160, 8, 16, 9, 199, 199, 533, 24990, 3120, 26, 272, 347, 636, 826, 721, 277, 12, 2088, 12, 1300, 12, 1704, 304, 267, 291, 14, 1760, 63, 275, 2088, 267, 291, 14, 1095, 63, 275, 1300, 267, 291, 14, 696, 63, 275, 1704, 267, 291, 14, 6864, 1197, 342, 339, 347, 636, 2264, 721, 277, 304, 267, 291, 14, 4687, 14, 14478, 342, 267, 291, 14, 4687, 14, 2573, 342, 339, 347, 18551, 1197, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 319, 13, 1000, 13, 4239, 13, 498, 14, 13102, 2, 5493, 347, 1684, 1197, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 319, 13, 1000, 13, 3455, 13, 498, 14, 13102, 2, 339, 347, 8692, 8, 277, 304, 267, 372, 291, 14, 1095, 63, 435, 3905, 4659, 14, 10659, 2, 339, 347, 7958, 1197, 8, 277, 304, 267, 14296, 480, 825, 635, 401, 355, 3905, 548, 401, 291, 14, 31757, 1062, 355, 3905, 354, 401, 298, 261, 1850, 3912, 82, 17, 401, 355, 3905, 2268, 498, 531, 267, 14296, 480, 825, 401, 355, 3905, 262, 401, 291, 14, 31757, 1062, 355, 3905, 5645, 548, 401, 355, 3905, 548, 401, 291, 14, 26238, 1012, 339, 347, 2851, 8, 277, 304, 267, 372, 298, 1014, 921, 5967, 26, 5008, 6687, 339, 347, 3378, 8, 277, 304, 267, 2088, 275, 334, 277, 14, 1760, 63, 435, 298, 446, 498, 298, 435, 291, 14, 31757, 342, 435, 2049, 298, 446, 17549, 63, 4736, 63, 493, 298, 435, 291, 14, 696, 3754, 6405, 11414, 342, 435, 2049, 298, 446, 10659, 63, 697, 298, 435, 291, 14, 7243, 342, 435, 2049, 298, 446, 2350, 63, 23238, 63, 11132, 63, 4515, 413, 2, 435, 2049, 298, 446, 793, 475, 3083, 531, 267, 2050, 14, 815, 480, 9390, 26, 298, 435, 2088, 9, 267, 1249, 275, 16701, 14, 1294, 8, 1760, 9, 267, 291, 14, 4687, 275, 3873, 14, 7942, 8, 589, 12, 3839, 29, 5781, 14, 6089, 9, 267, 543, 2653, 8, 709, 304, 288, 1830, 291, 14, 4687,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Diaoul/pyjulius
pyjulius/__init__.py
1
1118
# -*- coding: utf-8 -*- # Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com> # # This file is part of pyjulius. # # pyjulius 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. # # pyjulius 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 pyjulius. If not, see <http://www.gnu.org/licenses/>. from core import * from exceptions import * from models import * import logging try: from logging import NullHandler except ImportError: class NullHandler(logging.Handler): def emit(self, record): pass __all__ = ['Client', 'Sentence', 'Word', 'Error', 'ConnectionError'] logging.getLogger(__name__).addHandler(NullHandler())
lgpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 13, 7409, 437, 29680, 1132, 23207, 1346, 665, 2391, 79, 7586, 352, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1134, 74, 13987, 527, 14, 199, 3, 199, 3, 1134, 74, 13987, 527, 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, 3, 199, 3, 1134, 74, 13987, 527, 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, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 1134, 74, 13987, 527, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 6170, 492, 627, 199, 504, 4967, 492, 627, 199, 504, 1709, 492, 627, 199, 646, 2050, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 421, 199, 363, 452, 363, 275, 788, 3041, 297, 283, 18569, 6692, 297, 283, 10155, 297, 283, 547, 297, 283, 20349, 418, 199, 4806, 14, 5572, 3460, 354, 28634, 18826, 8, 8849, 2461, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1898, 7760, 13, 7409, 437, 29680, 1132, 23207, 1346, 665, 2391, 79, 7586, 352, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1134, 74, 13987, 527, 14, 199, 3, 199, 3, 1134, 74, 13987, 527, 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, 3, 199, 3, 1134, 74, 13987, 527, 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, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 844, 199, 3, 3180, 543, 1134, 74, 13987, 527, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 504, 6170, 492, 627, 199, 504, 4967, 492, 627, 199, 504, 1709, 492, 627, 199, 646, 2050, 199, 893, 26, 272, 687, 2050, 492, 12119, 2461, 199, 2590, 3545, 26, 272, 1021, 12119, 2461, 8, 4806, 14, 2461, 304, 267, 347, 8689, 8, 277, 12, 2777, 304, 288, 986, 421, 199, 363, 452, 363, 275, 788, 3041, 297, 283, 18569, 6692, 297, 283, 10155, 297, 283, 547, 297, 283, 20349, 418, 199, 4806, 14, 5572, 3460, 354, 28634, 18826, 8, 8849, 2461, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
taknevski/tensorflow-xsmm
tensorflow/contrib/tensor_forest/hybrid/python/models/decisions_to_data_then_nn_test.py
101
4681
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for the hybrid tensor forest model.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import random # pylint: disable=unused-import from tensorflow.contrib.tensor_forest.hybrid.python.models import decisions_to_data_then_nn from tensorflow.contrib.tensor_forest.python import tensor_forest from tensorflow.python.framework import constant_op from tensorflow.python.framework import test_util from tensorflow.python.framework.ops import Operation from tensorflow.python.framework.ops import Tensor from tensorflow.python.ops import variable_scope from tensorflow.python.platform import googletest class DecisionsToDataThenNNTest(test_util.TensorFlowTestCase): def setUp(self): self.params = tensor_forest.ForestHParams( num_classes=2, num_features=31, layer_size=11, num_layers=13, num_trees=17, connection_probability=0.1, hybrid_tree_depth=4, regularization_strength=0.01, learning_rate=0.01, regularization="", weight_init_mean=0.0, weight_init_std=0.1) self.params.regression = False self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1 self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1) def testHParams(self): self.assertEquals(self.params.num_classes, 2) self.assertEquals(self.params.num_features, 31) self.assertEquals(self.params.layer_size, 11) self.assertEquals(self.params.num_layers, 13) self.assertEquals(self.params.num_trees, 17) self.assertEquals(self.params.hybrid_tree_depth, 4) self.assertEquals(self.params.connection_probability, 0.1) # Building the graphs modifies the params. with variable_scope.variable_scope("DecisionsToDataThenNNTest_testHParams"): # pylint: disable=W0612 graph_builder = decisions_to_data_then_nn.DecisionsToDataThenNN( self.params) # Tree with depth 4 should have 2**0 + 2**1 + 2**2 + 2**3 = 15 nodes. self.assertEquals(self.params.num_nodes, 15) def testConstructionPollution(self): """Ensure that graph building doesn't modify the params in a bad way.""" # pylint: disable=W0612 data = [[random.uniform(-1, 1) for i in range(self.params.num_features)] for _ in range(100)] self.assertTrue(isinstance(self.params, tensor_forest.ForestHParams)) self.assertFalse( isinstance(self.params.num_trees, tensor_forest.ForestHParams)) with variable_scope.variable_scope( "DecisionsToDataThenNNTest_testContructionPollution"): graph_builder = decisions_to_data_then_nn.DecisionsToDataThenNN( self.params) self.assertTrue(isinstance(self.params, tensor_forest.ForestHParams)) self.assertFalse( isinstance(self.params.num_trees, tensor_forest.ForestHParams)) def testInferenceConstruction(self): # pylint: disable=W0612 data = constant_op.constant( [[random.uniform(-1, 1) for i in range(self.params.num_features)] for _ in range(100)]) with variable_scope.variable_scope( "DecisionsToDataThenNNTest_testInferenceContruction"): graph_builder = decisions_to_data_then_nn.DecisionsToDataThenNN( self.params) graph = graph_builder.inference_graph(data, None) self.assertTrue(isinstance(graph, Tensor)) def testTrainingConstruction(self): # pylint: disable=W0612 data = constant_op.constant( [[random.uniform(-1, 1) for i in range(self.params.num_features)] for _ in range(100)]) labels = [1 for _ in range(100)] with variable_scope.variable_scope( "DecisionsToDataThenNNTest_testTrainingContruction"): graph_builder = decisions_to_data_then_nn.DecisionsToDataThenNN( self.params) graph = graph_builder.training_graph(data, labels, None) self.assertTrue(isinstance(graph, Operation)) if __name__ == "__main__": googletest.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 7188, 14601, 2345, 27882, 1402, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2196, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 14, 992, 492, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 1548, 492, 2345, 63, 25736, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 17954, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5878, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 1487, 559, 1356, 1378, 1451, 28226, 7178, 774, 8, 396, 63, 1974, 14, 26998, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 1162, 275, 2345, 63, 25736, 14, 21668, 40, 6007, 8, 267, 1967, 63, 2888, 29, 18, 12, 267, 1967, 63, 3179, 29, 2192, 12, 267, 4045, 63, 890, 29, 845, 12, 267, 1967, 63, 4359, 29, 969, 12, 267, 1967, 63, 14635, 29, 1196, 12, 267, 1950, 63, 17210, 29, 16, 14, 17, 12, 267, 7188, 14601, 63, 2350, 63, 4631, 29, 20, 12, 267, 21095, 63, 21049, 29, 16, 14, 614, 12, 267, 9328, 63, 1866, 29, 16, 14, 614, 12, 267, 21095, 8772, 267, 5401, 63, 826, 63, 3670, 29, 16, 14, 16, 12, 267, 5401, 63, 826, 63, 1516, 29, 16, 14, 17, 9, 272, 291, 14, 1162, 14, 12513, 275, 756, 272, 291, 14, 1162, 14, 1507, 63, 2415, 275, 499, 538, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 446, 413, 272, 291, 14, 1162, 14, 1507, 63, 16554, 275, 499, 14192, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 446, 413, 9, 819, 347, 511, 40, 6007, 8, 277, 304, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 2888, 12, 499, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 3179, 12, 7105, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1897, 63, 890, 12, 4119, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 4359, 12, 4944, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 5557, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 12, 841, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 2105, 63, 17210, 12, 378, 14, 17, 9, 339, 327, 6516, 316, 314, 18312, 26473, 314, 1862, 14, 272, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 480, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 40, 6007, 2349, 489, 327, 4287, 26, 3507, 29, 55, 1690, 713, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 14, 872, 559, 1356, 1378, 1451, 28226, 7178, 8, 881, 291, 14, 1162, 9, 2541, 327, 12178, 543, 5818, 841, 1077, 1172, 499, 538, 16, 435, 499, 538, 17, 435, 499, 538, 18, 435, 499, 538, 19, 275, 4114, 3380, 14, 489, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 2415, 12, 4114, 9, 819, 347, 511, 10264, 24022, 2206, 8, 277, 304, 272, 408, 13913, 626, 3343, 10015, 3181, 1133, 2811, 314, 1862, 315, 282, 4875, 4340, 1041, 272, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 666, 275, 3474, 2355, 14, 8830, 2801, 17, 12, 413, 9, 367, 284, 315, 1425, 8, 277, 14, 1162, 14, 1507, 63, 3179, 1874, 288, 367, 485, 315, 1425, 8, 1960, 1874, 339, 291, 14, 1815, 8, 6074, 8, 277, 14, 1162, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 272, 291, 14, 3334, 8, 267, 1228, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 339, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 267, 298, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 714, 454, 85, 414, 24022, 2206, 2349, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 14, 872, 559, 1356, 1378, 1451, 28226, 7178, 8, 881, 291, 14, 1162, 9, 2541, 291, 14, 1815, 8, 6074, 8, 277, 14, 1162, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 489, 291, 14, 3334, 8, 881, 1228, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 819, 347, 511, 29731, 10264, 8, 277, 304, 272, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 666, 275, 4413, 63, 411, 14, 4083, 8, 267, 3474, 2355, 14, 8830, 2801, 17, 12, 413, 9, 367, 284, 315, 1425, 8, 277, 14, 1162, 14, 1507, 63, 3179, 1874, 268, 367, 485, 315, 1425, 8, 1960, 3948, 339, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 267, 298, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 29731, 714, 454, 85, 414, 2349, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 314, 7188, 14601, 2345, 27882, 1402, 1041, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2196, 199, 199, 3, 4287, 26, 3507, 29, 8618, 13, 646, 199, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 27758, 14, 1548, 14, 992, 492, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 199, 504, 3228, 14, 2828, 14, 3128, 63, 25736, 14, 1548, 492, 2345, 63, 25736, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 17954, 199, 504, 3228, 14, 1548, 14, 4857, 14, 1483, 492, 5878, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1750, 63, 2645, 199, 504, 3228, 14, 1548, 14, 3246, 492, 31141, 421, 199, 533, 1487, 559, 1356, 1378, 1451, 28226, 7178, 774, 8, 396, 63, 1974, 14, 26998, 1746, 304, 819, 347, 3613, 8, 277, 304, 272, 291, 14, 1162, 275, 2345, 63, 25736, 14, 21668, 40, 6007, 8, 267, 1967, 63, 2888, 29, 18, 12, 267, 1967, 63, 3179, 29, 2192, 12, 267, 4045, 63, 890, 29, 845, 12, 267, 1967, 63, 4359, 29, 969, 12, 267, 1967, 63, 14635, 29, 1196, 12, 267, 1950, 63, 17210, 29, 16, 14, 17, 12, 267, 7188, 14601, 63, 2350, 63, 4631, 29, 20, 12, 267, 21095, 63, 21049, 29, 16, 14, 614, 12, 267, 9328, 63, 1866, 29, 16, 14, 614, 12, 267, 21095, 8772, 267, 5401, 63, 826, 63, 3670, 29, 16, 14, 16, 12, 267, 5401, 63, 826, 63, 1516, 29, 16, 14, 17, 9, 272, 291, 14, 1162, 14, 12513, 275, 756, 272, 291, 14, 1162, 14, 1507, 63, 2415, 275, 499, 538, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 446, 413, 272, 291, 14, 1162, 14, 1507, 63, 16554, 275, 499, 14192, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 446, 413, 9, 819, 347, 511, 40, 6007, 8, 277, 304, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 2888, 12, 499, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 3179, 12, 7105, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1897, 63, 890, 12, 4119, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 4359, 12, 4944, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 5557, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 27758, 63, 2350, 63, 4631, 12, 841, 9, 272, 291, 14, 2947, 8, 277, 14, 1162, 14, 2105, 63, 17210, 12, 378, 14, 17, 9, 339, 327, 6516, 316, 314, 18312, 26473, 314, 1862, 14, 272, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 480, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 40, 6007, 2349, 489, 327, 4287, 26, 3507, 29, 55, 1690, 713, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 14, 872, 559, 1356, 1378, 1451, 28226, 7178, 8, 881, 291, 14, 1162, 9, 2541, 327, 12178, 543, 5818, 841, 1077, 1172, 499, 538, 16, 435, 499, 538, 17, 435, 499, 538, 18, 435, 499, 538, 19, 275, 4114, 3380, 14, 489, 291, 14, 2947, 8, 277, 14, 1162, 14, 1507, 63, 2415, 12, 4114, 9, 819, 347, 511, 10264, 24022, 2206, 8, 277, 304, 272, 408, 13913, 626, 3343, 10015, 3181, 1133, 2811, 314, 1862, 315, 282, 4875, 4340, 1041, 272, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 666, 275, 3474, 2355, 14, 8830, 2801, 17, 12, 413, 9, 367, 284, 315, 1425, 8, 277, 14, 1162, 14, 1507, 63, 3179, 1874, 288, 367, 485, 315, 1425, 8, 1960, 1874, 339, 291, 14, 1815, 8, 6074, 8, 277, 14, 1162, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 272, 291, 14, 3334, 8, 267, 1228, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 339, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 267, 298, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 714, 454, 85, 414, 24022, 2206, 2349, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475, 63, 576, 63, 12726, 63, 4411, 14, 872, 559, 1356, 1378, 1451, 28226, 7178, 8, 881, 291, 14, 1162, 9, 2541, 291, 14, 1815, 8, 6074, 8, 277, 14, 1162, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 489, 291, 14, 3334, 8, 881, 1228, 8, 277, 14, 1162, 14, 1507, 63, 14635, 12, 2345, 63, 25736, 14, 21668, 40, 6007, 430, 819, 347, 511, 29731, 10264, 8, 277, 304, 272, 327, 4287, 26, 3507, 29, 55, 1690, 713, 272, 666, 275, 4413, 63, 411, 14, 4083, 8, 267, 3474, 2355, 14, 8830, 2801, 17, 12, 413, 9, 367, 284, 315, 1425, 8, 277, 14, 1162, 14, 1507, 63, 3179, 1874, 268, 367, 485, 315, 1425, 8, 1960, 3948, 339, 543, 1750, 63, 2645, 14, 1975, 63, 2645, 8, 267, 298, 872, 559, 1356, 1378, 1451, 28226, 7178, 774, 63, 396, 29731, 714, 454, 85, 414, 2349, 489, 3343, 63, 5649, 275, 12985, 1356, 63, 475, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
shurihell/testasia
openedx/core/lib/tests/test_js_utils.py
33
2886
""" Tests for js_utils.py """ import json from unittest import TestCase from openedx.core.lib.js_utils import ( escape_json_dumps, escape_js_string ) class TestJSUtils(TestCase): """ Test JS utils """ class NoDefaultEncoding(object): """ Helper class that has no default JSON encoding """ def __init__(self, value): self.value = value class SampleJSONEncoder(json.JSONEncoder): """ A test encoder that is used to prove that the encoder does its job before the escaping. """ # pylint: disable=method-hidden def default(self, noDefaultEncodingObj): return noDefaultEncodingObj.value.replace("<script>", "sample-encoder-was-here") def test_escape_json_dumps_escapes_unsafe_html(self): """ Test escape_json_dumps properly escapes &, <, and >. """ malicious_json = {"</script><script>alert('hello, ');</script>": "</script><script>alert('&world!');</script>"} expected_encoded_json = ( r'''{"\u003c/script\u003e\u003cscript\u003ealert('hello, ');\u003c/script\u003e": ''' r'''"\u003c/script\u003e\u003cscript\u003ealert('\u0026world!');\u003c/script\u003e"}''' ) encoded_json = escape_json_dumps(malicious_json) self.assertEquals(expected_encoded_json, encoded_json) def test_escape_json_dumps_with_custom_encoder_escapes_unsafe_html(self): """ Test escape_json_dumps first encodes with custom JSNOEncoder before escaping &, <, and > The test encoder class should first perform the replacement of "<script>" with "sample-encoder-was-here", and then should escape the remaining &, <, and >. """ malicious_json = { "</script><script>alert('hello, ');</script>": self.NoDefaultEncoding("</script><script>alert('&world!');</script>") } expected_custom_encoded_json = ( r'''{"\u003c/script\u003e\u003cscript\u003ealert('hello, ');\u003c/script\u003e": ''' r'''"\u003c/script\u003esample-encoder-was-herealert('\u0026world!');\u003c/script\u003e"}''' ) encoded_json = escape_json_dumps(malicious_json, cls=self.SampleJSONEncoder) self.assertEquals(expected_custom_encoded_json, encoded_json) def test_escape_js_string_escapes_unsafe_html(self): """ Test escape_js_string escapes &, <, and >, as well as returns a unicode type """ malicious_js_string = "</script><script>alert('hello, ');</script>" expected_escaped_js_string = unicode( r"\u003C/script\u003E\u003Cscript\u003Ealert(\u0027hello, \u0027)\u003B\u003C/script\u003E" ) escaped_js_string = escape_js_string(malicious_js_string) self.assertEquals(expected_escaped_js_string, escaped_js_string)
agpl-3.0
[ 624, 199, 2925, 367, 8586, 63, 1208, 14, 647, 199, 624, 199, 646, 2022, 199, 504, 2882, 492, 7640, 199, 504, 22709, 14, 1018, 14, 773, 14, 3596, 63, 1208, 492, 334, 272, 4772, 63, 1001, 63, 4180, 12, 4772, 63, 3596, 63, 875, 199, 9, 421, 199, 533, 1379, 42, 6195, 3024, 8, 1746, 304, 272, 408, 272, 1379, 18001, 3778, 272, 408, 339, 1021, 3091, 2698, 7630, 8, 785, 304, 267, 408, 267, 11642, 1021, 626, 965, 949, 849, 4840, 2644, 267, 408, 267, 347, 636, 826, 721, 277, 12, 574, 304, 288, 291, 14, 585, 275, 574, 339, 1021, 15227, 23069, 8, 1001, 14, 23069, 304, 267, 408, 267, 437, 511, 10295, 626, 365, 1202, 370, 557, 432, 626, 314, 10295, 1630, 2399, 3906, 2544, 314, 21375, 14, 267, 408, 267, 327, 4287, 26, 3507, 29, 765, 13, 5642, 267, 347, 849, 8, 277, 12, 949, 2698, 7630, 5665, 304, 288, 372, 949, 2698, 7630, 5665, 14, 585, 14, 1814, 6757, 1579, 7166, 298, 3271, 13, 9347, 13, 10274, 13, 1681, 531, 339, 347, 511, 63, 3765, 63, 1001, 63, 4180, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 1001, 63, 4180, 7684, 24644, 17181, 665, 12, 436, 690, 14, 267, 408, 267, 333, 17999, 17326, 63, 1001, 275, 2420, 1108, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 30, 582, 15683, 1579, 2535, 1579, 30, 9241, 20040, 7617, 10916, 12279, 1579, 30, 3570, 267, 1420, 63, 8167, 63, 1001, 275, 334, 288, 519, 2344, 91, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 360, 5006, 12, 283, 6152, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 582, 1449, 288, 519, 2344, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 2258, 85, 28193, 7617, 10916, 3779, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 3570, 2344, 267, 776, 398, 5737, 63, 1001, 275, 4772, 63, 1001, 63, 4180, 8, 2174, 530, 17326, 63, 1001, 9, 267, 291, 14, 2947, 8, 2062, 63, 8167, 63, 1001, 12, 5737, 63, 1001, 9, 339, 347, 511, 63, 3765, 63, 1001, 63, 4180, 63, 1045, 63, 4229, 63, 9347, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 1001, 63, 4180, 1642, 3752, 83, 543, 3537, 18001, 2826, 6679, 2544, 21375, 17181, 665, 12, 436, 690, 398, 710, 511, 10295, 1021, 1077, 1642, 5147, 314, 8343, 402, 3886, 1579, 4335, 543, 267, 298, 3271, 13, 9347, 13, 10274, 13, 1681, 401, 436, 2066, 1077, 4772, 314, 7971, 17181, 665, 12, 436, 690, 14, 398, 408, 267, 333, 17999, 17326, 63, 1001, 275, 469, 288, 15683, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 30, 582, 288, 291, 14, 1944, 2698, 7630, 23790, 1579, 2535, 1579, 30, 9241, 20040, 7617, 10916, 12279, 1579, 9579, 267, 789, 267, 1420, 63, 4229, 63, 8167, 63, 1001, 275, 334, 288, 519, 2344, 91, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 360, 5006, 12, 283, 6152, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 582, 1449, 288, 519, 2344, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 397, 865, 13, 9347, 13, 10274, 13, 1681, 9241, 2258, 85, 28193, 7617, 10916, 3779, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 3570, 2344, 267, 776, 398, 5737, 63, 1001, 275, 4772, 63, 1001, 63, 4180, 8, 2174, 530, 17326, 63, 1001, 12, 843, 29, 277, 14, 8176, 23069, 9, 267, 291, 14, 2947, 8, 2062, 63, 4229, 63, 8167, 63, 1001, 12, 5737, 63, 1001, 9, 339, 347, 511, 63, 3765, 63, 3596, 63, 875, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 3596, 63, 875, 24644, 17181, 665, 12, 436, 11623, 465, 5521, 465, 2529, 282, 2649, 730, 267, 408, 267, 333, 17999, 17326, 63, 3596, 63, 875, 275, 15683, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 4335, 398, 1420, 63, 13572, 63, 3596, 63, 875, 275, 2649, 8, 288, 519, 3212, 85, 8262, 35, 15, 1579, 60, 85, 8262, 37, 60, 85, 8262, 35, 1579, 60, 85, 8262, 37, 9241, 2961, 85, 28355, 5006, 12, 971, 85, 28355, 2862, 85, 8262, 34, 60, 85, 8262, 35, 15, 1579, 60, 85, 8262, 37, 2, 267, 776, 267, 11077, 63, 3596, 63, 875, 275, 4772, 63, 3596, 63, 875, 8, 2174, 530, 17326, 63, 3596, 63, 875, 9, 267, 291, 14, 2947, 8, 2062, 63, 13572, 63, 3596, 63, 875, 12, 11077, 63, 3596, 63, 875, 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 ]
[ 199, 2925, 367, 8586, 63, 1208, 14, 647, 199, 624, 199, 646, 2022, 199, 504, 2882, 492, 7640, 199, 504, 22709, 14, 1018, 14, 773, 14, 3596, 63, 1208, 492, 334, 272, 4772, 63, 1001, 63, 4180, 12, 4772, 63, 3596, 63, 875, 199, 9, 421, 199, 533, 1379, 42, 6195, 3024, 8, 1746, 304, 272, 408, 272, 1379, 18001, 3778, 272, 408, 339, 1021, 3091, 2698, 7630, 8, 785, 304, 267, 408, 267, 11642, 1021, 626, 965, 949, 849, 4840, 2644, 267, 408, 267, 347, 636, 826, 721, 277, 12, 574, 304, 288, 291, 14, 585, 275, 574, 339, 1021, 15227, 23069, 8, 1001, 14, 23069, 304, 267, 408, 267, 437, 511, 10295, 626, 365, 1202, 370, 557, 432, 626, 314, 10295, 1630, 2399, 3906, 2544, 314, 21375, 14, 267, 408, 267, 327, 4287, 26, 3507, 29, 765, 13, 5642, 267, 347, 849, 8, 277, 12, 949, 2698, 7630, 5665, 304, 288, 372, 949, 2698, 7630, 5665, 14, 585, 14, 1814, 6757, 1579, 7166, 298, 3271, 13, 9347, 13, 10274, 13, 1681, 531, 339, 347, 511, 63, 3765, 63, 1001, 63, 4180, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 1001, 63, 4180, 7684, 24644, 17181, 665, 12, 436, 690, 14, 267, 408, 267, 333, 17999, 17326, 63, 1001, 275, 2420, 1108, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 30, 582, 15683, 1579, 2535, 1579, 30, 9241, 20040, 7617, 10916, 12279, 1579, 30, 3570, 267, 1420, 63, 8167, 63, 1001, 275, 334, 288, 519, 2344, 91, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 360, 5006, 12, 283, 6152, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 582, 1449, 288, 519, 2344, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 2258, 85, 28193, 7617, 10916, 3779, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 3570, 2344, 267, 776, 398, 5737, 63, 1001, 275, 4772, 63, 1001, 63, 4180, 8, 2174, 530, 17326, 63, 1001, 9, 267, 291, 14, 2947, 8, 2062, 63, 8167, 63, 1001, 12, 5737, 63, 1001, 9, 339, 347, 511, 63, 3765, 63, 1001, 63, 4180, 63, 1045, 63, 4229, 63, 9347, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 1001, 63, 4180, 1642, 3752, 83, 543, 3537, 18001, 2826, 6679, 2544, 21375, 17181, 665, 12, 436, 690, 398, 710, 511, 10295, 1021, 1077, 1642, 5147, 314, 8343, 402, 3886, 1579, 4335, 543, 267, 298, 3271, 13, 9347, 13, 10274, 13, 1681, 401, 436, 2066, 1077, 4772, 314, 7971, 17181, 665, 12, 436, 690, 14, 398, 408, 267, 333, 17999, 17326, 63, 1001, 275, 469, 288, 15683, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 30, 582, 288, 291, 14, 1944, 2698, 7630, 23790, 1579, 2535, 1579, 30, 9241, 20040, 7617, 10916, 12279, 1579, 9579, 267, 789, 267, 1420, 63, 4229, 63, 8167, 63, 1001, 275, 334, 288, 519, 2344, 91, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 60, 85, 8262, 67, 1579, 60, 85, 8262, 4489, 5567, 360, 5006, 12, 283, 6152, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 582, 1449, 288, 519, 2344, 3212, 85, 8262, 67, 15, 1579, 60, 85, 8262, 397, 865, 13, 9347, 13, 10274, 13, 1681, 9241, 2258, 85, 28193, 7617, 10916, 3779, 85, 8262, 67, 15, 1579, 60, 85, 8262, 69, 3570, 2344, 267, 776, 398, 5737, 63, 1001, 275, 4772, 63, 1001, 63, 4180, 8, 2174, 530, 17326, 63, 1001, 12, 843, 29, 277, 14, 8176, 23069, 9, 267, 291, 14, 2947, 8, 2062, 63, 4229, 63, 8167, 63, 1001, 12, 5737, 63, 1001, 9, 339, 347, 511, 63, 3765, 63, 3596, 63, 875, 63, 3765, 83, 63, 14242, 63, 1360, 8, 277, 304, 267, 408, 267, 1379, 4772, 63, 3596, 63, 875, 24644, 17181, 665, 12, 436, 11623, 465, 5521, 465, 2529, 282, 2649, 730, 267, 408, 267, 333, 17999, 17326, 63, 3596, 63, 875, 275, 15683, 1579, 2535, 1579, 30, 9241, 360, 5006, 12, 283, 2736, 1108, 1579, 4335, 398, 1420, 63, 13572, 63, 3596, 63, 875, 275, 2649, 8, 288, 519, 3212, 85, 8262, 35, 15, 1579, 60, 85, 8262, 37, 60, 85, 8262, 35, 1579, 60, 85, 8262, 37, 9241, 2961, 85, 28355, 5006, 12, 971, 85, 28355, 2862, 85, 8262, 34, 60, 85, 8262, 35, 15, 1579, 60, 85, 8262, 37, 2, 267, 776, 267, 11077, 63, 3596, 63, 875, 275, 4772, 63, 3596, 63, 875, 8, 2174, 530, 17326, 63, 3596, 63, 875, 9, 267, 291, 14, 2947, 8, 2062, 63, 13572, 63, 3596, 63, 875, 12, 11077, 63, 3596, 63, 875, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Shugabuga/zeroclickinfo-goodies
share/goodie/currency_in/parse.py
87
2347
#!/usr/bin/python # -*- coding: utf-8 -*- # Released under the GPL v2 license # https://www.gnu.org/licenses/old-licenses/gpl-2.0.html import lxml.html import sys #url = "http://en.wikipedia.org/wiki/List_of_circulating_currencies" url = "https://secure.wikimedia.org/wikipedia/en/wiki/List_of_circulating_currencies" countries = {}; # country:[[currency, code] [currency, code],...] country = "" # store current country for each row currency = "" # store current currency for each row iso_code = "" # store current iso code for currency description = "" # store currency and iso code when saving into file def add_currency(country, currency, iso_code, countries): "Add country into countries list" country = country.encode("utf8") if country in countries: countries[country].append([currency, iso_code]) else: countries[country] = [[currency, iso_code]] def clear_text(text): "Clear text of anotations in []. When e.g. 'Ascension pound[A]' contains [A]" start = text.find("[") if start != -1: text = text[:start] return text tree = lxml.html.parse("download/page.dat").getroot() tables = tree.find_class("wikitable sortable") for table in tables: for row in table.findall('tr'): cells = row.findall('td') if len(cells) == 6: country = cells[0].text_content() currency = cells[1].text_content() iso_code = cells[3].text_content() if len(cells) == 5: currency = cells[0].text_content() iso_code = cells[2].text_content() currency = clear_text(currency) iso_code = iso_code if iso_code != "None" else "" if currency != "None" and currency != "": add_currency(country[1:], currency, iso_code, countries) "Make output file 'currency.txt' as Perl 'hash table' ready for 'CurrencyIn.pm' module" output = "currency.txt" f= open(output, "w") result = [] for country in sorted(countries): description = "" formated_record = [] for record in countries[country]: iso_code = "" if record[1] == "" else (" (" + record[1] + ")") currency = record[0] formated_record.append((currency + iso_code).encode("utf8")) description = ','.join(str(x) for x in formated_record) f.write(country.lower() + "\n" + description + "\n") f.close()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 17646, 68, 1334, 314, 14629, 373, 18, 4190, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1753, 13, 2383, 15, 11692, 13, 18, 14, 16, 14, 1360, 199, 199, 646, 14490, 14, 1360, 199, 646, 984, 199, 199, 3, 633, 275, 298, 1014, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 6092, 20529, 63, 895, 828, 2578, 2, 199, 633, 275, 298, 2859, 921, 7817, 14, 5319, 1036, 2391, 14, 1308, 15, 13961, 15, 287, 15, 6797, 15, 1296, 63, 1618, 63, 6092, 20529, 63, 895, 828, 2578, 2, 199, 199, 23598, 275, 27978, 258, 327, 9023, 7766, 59, 4968, 12, 1233, 61, 359, 4968, 12, 1233, 467, 18737, 199, 6063, 275, 3087, 263, 327, 3877, 1453, 9023, 367, 1924, 1962, 199, 4968, 275, 3087, 755, 327, 3877, 1453, 9952, 367, 1924, 1962, 199, 4595, 63, 600, 275, 3087, 755, 327, 3877, 1453, 11601, 1233, 367, 9952, 199, 1802, 275, 3087, 259, 327, 3877, 9952, 436, 11601, 1233, 1380, 13369, 1901, 570, 199, 199, 318, 1050, 63, 4968, 8, 6063, 12, 9952, 12, 11601, 63, 600, 12, 26013, 304, 272, 298, 1123, 9023, 1901, 26013, 769, 2, 272, 9023, 275, 9023, 14, 2143, 480, 1624, 24, 531, 272, 340, 9023, 315, 26013, 26, 267, 26013, 59, 6063, 1055, 740, 779, 4968, 12, 11601, 63, 600, 566, 272, 587, 26, 267, 26013, 59, 6063, 61, 275, 3474, 4968, 12, 11601, 63, 600, 2677, 199, 199, 318, 5436, 63, 505, 8, 505, 304, 272, 298, 9721, 1318, 402, 376, 357, 1298, 315, 942, 14, 3979, 325, 14, 71, 14, 283, 10534, 287, 438, 299, 1034, 59, 33, 6616, 3509, 359, 33, 8480, 272, 1343, 275, 1318, 14, 1623, 10994, 531, 272, 340, 1343, 1137, 446, 17, 26, 267, 1318, 275, 1318, 1491, 928, 61, 272, 372, 1318, 199, 199, 2350, 275, 14490, 14, 1360, 14, 1122, 480, 4249, 15, 1606, 14, 4616, 3471, 24544, 342, 199, 5987, 275, 3123, 14, 1623, 63, 533, 480, 5319, 390, 461, 4069, 461, 531, 199, 509, 1817, 315, 6716, 26, 272, 367, 1962, 315, 1817, 14, 6452, 360, 454, 735, 267, 10106, 275, 1962, 14, 6452, 360, 2076, 358, 267, 340, 822, 8, 9041, 9, 508, 1227, 26, 288, 9023, 275, 10106, 59, 16, 1055, 505, 63, 1317, 342, 288, 9952, 275, 10106, 59, 17, 1055, 505, 63, 1317, 342, 288, 11601, 63, 600, 275, 10106, 59, 19, 1055, 505, 63, 1317, 342, 398, 340, 822, 8, 9041, 9, 508, 959, 26, 288, 9952, 275, 10106, 59, 16, 1055, 505, 63, 1317, 342, 288, 11601, 63, 600, 275, 10106, 59, 18, 1055, 505, 63, 1317, 342, 398, 9952, 275, 5436, 63, 505, 8, 4968, 9, 267, 11601, 63, 600, 275, 11601, 63, 600, 340, 11601, 63, 600, 1137, 298, 403, 2, 587, 3087, 398, 340, 9952, 1137, 298, 403, 2, 436, 9952, 1137, 10812, 288, 1050, 63, 4968, 8, 6063, 59, 17, 8429, 9952, 12, 11601, 63, 600, 12, 26013, 9, 199, 199, 2, 5483, 1072, 570, 283, 4968, 14, 2424, 7, 465, 3492, 76, 283, 2227, 1817, 7, 10144, 367, 283, 19567, 607, 14, 7073, 7, 859, 2, 199, 1199, 275, 298, 4968, 14, 2424, 2, 199, 70, 29, 1551, 8, 1199, 12, 298, 87, 531, 199, 1099, 275, 942, 199, 509, 9023, 315, 3355, 8, 23598, 304, 199, 198, 1802, 275, 3087, 199, 198, 964, 972, 63, 3059, 275, 942, 421, 198, 509, 2777, 315, 26013, 59, 6063, 2189, 507, 198, 4595, 63, 600, 275, 3087, 340, 2777, 59, 17, 61, 508, 3087, 587, 1689, 1689, 435, 2777, 59, 17, 61, 435, 6099, 531, 507, 198, 4968, 275, 2777, 59, 16, 61, 507, 198, 964, 972, 63, 3059, 14, 740, 1332, 4968, 435, 11601, 63, 600, 680, 2143, 480, 1624, 24, 2237, 507, 198, 1802, 275, 12814, 904, 8, 495, 8, 88, 9, 367, 671, 315, 1824, 972, 63, 3059, 9, 199, 198, 70, 14, 952, 8, 6063, 14, 2325, 342, 435, 1867, 78, 2, 435, 221, 1369, 435, 1867, 78, 531, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 17646, 68, 1334, 314, 14629, 373, 18, 4190, 199, 3, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 1753, 13, 2383, 15, 11692, 13, 18, 14, 16, 14, 1360, 199, 199, 646, 14490, 14, 1360, 199, 646, 984, 199, 199, 3, 633, 275, 298, 1014, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 1296, 63, 1618, 63, 6092, 20529, 63, 895, 828, 2578, 2, 199, 633, 275, 298, 2859, 921, 7817, 14, 5319, 1036, 2391, 14, 1308, 15, 13961, 15, 287, 15, 6797, 15, 1296, 63, 1618, 63, 6092, 20529, 63, 895, 828, 2578, 2, 199, 199, 23598, 275, 27978, 258, 327, 9023, 7766, 59, 4968, 12, 1233, 61, 359, 4968, 12, 1233, 467, 18737, 199, 6063, 275, 3087, 263, 327, 3877, 1453, 9023, 367, 1924, 1962, 199, 4968, 275, 3087, 755, 327, 3877, 1453, 9952, 367, 1924, 1962, 199, 4595, 63, 600, 275, 3087, 755, 327, 3877, 1453, 11601, 1233, 367, 9952, 199, 1802, 275, 3087, 259, 327, 3877, 9952, 436, 11601, 1233, 1380, 13369, 1901, 570, 199, 199, 318, 1050, 63, 4968, 8, 6063, 12, 9952, 12, 11601, 63, 600, 12, 26013, 304, 272, 298, 1123, 9023, 1901, 26013, 769, 2, 272, 9023, 275, 9023, 14, 2143, 480, 1624, 24, 531, 272, 340, 9023, 315, 26013, 26, 267, 26013, 59, 6063, 1055, 740, 779, 4968, 12, 11601, 63, 600, 566, 272, 587, 26, 267, 26013, 59, 6063, 61, 275, 3474, 4968, 12, 11601, 63, 600, 2677, 199, 199, 318, 5436, 63, 505, 8, 505, 304, 272, 298, 9721, 1318, 402, 376, 357, 1298, 315, 942, 14, 3979, 325, 14, 71, 14, 283, 10534, 287, 438, 299, 1034, 59, 33, 6616, 3509, 359, 33, 8480, 272, 1343, 275, 1318, 14, 1623, 10994, 531, 272, 340, 1343, 1137, 446, 17, 26, 267, 1318, 275, 1318, 1491, 928, 61, 272, 372, 1318, 199, 199, 2350, 275, 14490, 14, 1360, 14, 1122, 480, 4249, 15, 1606, 14, 4616, 3471, 24544, 342, 199, 5987, 275, 3123, 14, 1623, 63, 533, 480, 5319, 390, 461, 4069, 461, 531, 199, 509, 1817, 315, 6716, 26, 272, 367, 1962, 315, 1817, 14, 6452, 360, 454, 735, 267, 10106, 275, 1962, 14, 6452, 360, 2076, 358, 267, 340, 822, 8, 9041, 9, 508, 1227, 26, 288, 9023, 275, 10106, 59, 16, 1055, 505, 63, 1317, 342, 288, 9952, 275, 10106, 59, 17, 1055, 505, 63, 1317, 342, 288, 11601, 63, 600, 275, 10106, 59, 19, 1055, 505, 63, 1317, 342, 398, 340, 822, 8, 9041, 9, 508, 959, 26, 288, 9952, 275, 10106, 59, 16, 1055, 505, 63, 1317, 342, 288, 11601, 63, 600, 275, 10106, 59, 18, 1055, 505, 63, 1317, 342, 398, 9952, 275, 5436, 63, 505, 8, 4968, 9, 267, 11601, 63, 600, 275, 11601, 63, 600, 340, 11601, 63, 600, 1137, 298, 403, 2, 587, 3087, 398, 340, 9952, 1137, 298, 403, 2, 436, 9952, 1137, 10812, 288, 1050, 63, 4968, 8, 6063, 59, 17, 8429, 9952, 12, 11601, 63, 600, 12, 26013, 9, 199, 199, 2, 5483, 1072, 570, 283, 4968, 14, 2424, 7, 465, 3492, 76, 283, 2227, 1817, 7, 10144, 367, 283, 19567, 607, 14, 7073, 7, 859, 2, 199, 1199, 275, 298, 4968, 14, 2424, 2, 199, 70, 29, 1551, 8, 1199, 12, 298, 87, 531, 199, 1099, 275, 942, 199, 509, 9023, 315, 3355, 8, 23598, 304, 199, 198, 1802, 275, 3087, 199, 198, 964, 972, 63, 3059, 275, 942, 421, 198, 509, 2777, 315, 26013, 59, 6063, 2189, 507, 198, 4595, 63, 600, 275, 3087, 340, 2777, 59, 17, 61, 508, 3087, 587, 1689, 1689, 435, 2777, 59, 17, 61, 435, 6099, 531, 507, 198, 4968, 275, 2777, 59, 16, 61, 507, 198, 964, 972, 63, 3059, 14, 740, 1332, 4968, 435, 11601, 63, 600, 680, 2143, 480, 1624, 24, 2237, 507, 198, 1802, 275, 12814, 904, 8, 495, 8, 88, 9, 367, 671, 315, 1824, 972, 63, 3059, 9, 199, 198, 70, 14, 952, 8, 6063, 14, 2325, 342, 435, 1867, 78, 2, 435, 221, 1369, 435, 1867, 78, 531, 199, 70, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
kfcpaladin/sze-the-game
game/models/achievements/AchievementManager.py
1
1635
from .AchievementListener import AchievementListener from models.popups import Popup class AchievementManager(object): def __init__(self, popups): self._achievements = {} self._listeners = [] self._popups = popups def __iter__(self): for achievement in self._achievements.values(): yield achievement @property def achievements(self): return self._achievements.values() def add_achievement(self, achievement): _id = achievement.id listener = AchievementListener(achievement) self._listeners.append(listener) listener.listen_unlock(self._on_unlock) listener.listen_reveal(self._on_reveal) self._achievements.setdefault(_id, achievement) def unlock_achievement(self, _id): achievement = self.get_achievement(_id) achievement.is_complete = True achievement.is_hidden = False def reveal_achievement(self, _id): achievement = self.get_achievement(_id) achievement.is_hidden = False def is_achievement_unlocked(self, _id): achievement = self.get_achievement(_id) return achievement.is_complete def get_achievement(self, _id): achievement = self._achievements.get(_id) if achievement is None: raise KeyError("Unknown achievement {0}".format(_id)) return achievement def _on_reveal(self, achievement): pass def _on_unlock(self, achievement): self._popups.add(Popup( message="Unlocked achievement\n{0}".format(achievement.id), icon=achievement.icon))
mit
[ 504, 1275, 33, 14025, 432, 434, 10464, 492, 437, 14025, 432, 434, 10464, 199, 504, 1709, 14, 1935, 15203, 492, 13244, 384, 199, 199, 533, 437, 14025, 432, 434, 2988, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4560, 15203, 304, 267, 291, 423, 1225, 1873, 432, 1470, 275, 1052, 4960, 291, 423, 17301, 275, 942, 267, 291, 423, 1935, 15203, 275, 4560, 15203, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 32194, 434, 315, 291, 423, 1225, 1873, 432, 1470, 14, 1459, 837, 288, 1995, 32194, 434, 339, 768, 1829, 272, 347, 32194, 1470, 8, 277, 304, 267, 372, 291, 423, 1225, 1873, 432, 1470, 14, 1459, 342, 339, 347, 1050, 63, 1225, 1873, 432, 434, 8, 277, 12, 32194, 434, 304, 267, 485, 344, 275, 32194, 434, 14, 344, 267, 11647, 275, 437, 14025, 432, 434, 10464, 8, 1225, 1873, 432, 434, 9, 267, 291, 423, 17301, 14, 740, 8, 9799, 9, 267, 11647, 14, 5859, 63, 17966, 8, 277, 423, 265, 63, 17966, 9, 267, 11647, 14, 5859, 63, 30496, 279, 8, 277, 423, 265, 63, 30496, 279, 9, 267, 291, 423, 1225, 1873, 432, 1470, 14, 5486, 1547, 344, 12, 32194, 434, 9, 2286, 347, 28451, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 32194, 434, 14, 374, 63, 4883, 275, 715, 267, 32194, 434, 14, 374, 63, 5642, 275, 756, 339, 347, 295, 432, 279, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 32194, 434, 14, 374, 63, 5642, 275, 756, 2286, 347, 365, 63, 1225, 1873, 432, 434, 63, 32489, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 372, 32194, 434, 14, 374, 63, 4883, 339, 347, 664, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 423, 1225, 1873, 432, 1470, 14, 362, 1547, 344, 9, 267, 340, 32194, 434, 365, 488, 26, 288, 746, 4067, 480, 5912, 32194, 434, 469, 16, 5469, 908, 1547, 344, 430, 267, 372, 32194, 434, 339, 347, 485, 265, 63, 30496, 279, 8, 277, 12, 32194, 434, 304, 267, 986, 339, 347, 485, 265, 63, 17966, 8, 277, 12, 32194, 434, 304, 267, 291, 423, 1935, 15203, 14, 525, 8, 26168, 8, 288, 1245, 628, 1358, 9325, 32194, 434, 60, 78, 91, 16, 5469, 908, 8, 1225, 1873, 432, 434, 14, 344, 395, 288, 7016, 29, 1225, 1873, 432, 434, 14, 4677, 430, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1275, 33, 14025, 432, 434, 10464, 492, 437, 14025, 432, 434, 10464, 199, 504, 1709, 14, 1935, 15203, 492, 13244, 384, 199, 199, 533, 437, 14025, 432, 434, 2988, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 4560, 15203, 304, 267, 291, 423, 1225, 1873, 432, 1470, 275, 1052, 4960, 291, 423, 17301, 275, 942, 267, 291, 423, 1935, 15203, 275, 4560, 15203, 339, 347, 636, 1661, 721, 277, 304, 267, 367, 32194, 434, 315, 291, 423, 1225, 1873, 432, 1470, 14, 1459, 837, 288, 1995, 32194, 434, 339, 768, 1829, 272, 347, 32194, 1470, 8, 277, 304, 267, 372, 291, 423, 1225, 1873, 432, 1470, 14, 1459, 342, 339, 347, 1050, 63, 1225, 1873, 432, 434, 8, 277, 12, 32194, 434, 304, 267, 485, 344, 275, 32194, 434, 14, 344, 267, 11647, 275, 437, 14025, 432, 434, 10464, 8, 1225, 1873, 432, 434, 9, 267, 291, 423, 17301, 14, 740, 8, 9799, 9, 267, 11647, 14, 5859, 63, 17966, 8, 277, 423, 265, 63, 17966, 9, 267, 11647, 14, 5859, 63, 30496, 279, 8, 277, 423, 265, 63, 30496, 279, 9, 267, 291, 423, 1225, 1873, 432, 1470, 14, 5486, 1547, 344, 12, 32194, 434, 9, 2286, 347, 28451, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 32194, 434, 14, 374, 63, 4883, 275, 715, 267, 32194, 434, 14, 374, 63, 5642, 275, 756, 339, 347, 295, 432, 279, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 32194, 434, 14, 374, 63, 5642, 275, 756, 2286, 347, 365, 63, 1225, 1873, 432, 434, 63, 32489, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 14, 362, 63, 1225, 1873, 432, 434, 1547, 344, 9, 267, 372, 32194, 434, 14, 374, 63, 4883, 339, 347, 664, 63, 1225, 1873, 432, 434, 8, 277, 12, 485, 344, 304, 267, 32194, 434, 275, 291, 423, 1225, 1873, 432, 1470, 14, 362, 1547, 344, 9, 267, 340, 32194, 434, 365, 488, 26, 288, 746, 4067, 480, 5912, 32194, 434, 469, 16, 5469, 908, 1547, 344, 430, 267, 372, 32194, 434, 339, 347, 485, 265, 63, 30496, 279, 8, 277, 12, 32194, 434, 304, 267, 986, 339, 347, 485, 265, 63, 17966, 8, 277, 12, 32194, 434, 304, 267, 291, 423, 1935, 15203, 14, 525, 8, 26168, 8, 288, 1245, 628, 1358, 9325, 32194, 434, 60, 78, 91, 16, 5469, 908, 8, 1225, 1873, 432, 434, 14, 344, 395, 288, 7016, 29, 1225, 1873, 432, 434, 14, 4677, 430, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
sexroute/commandergenius
project/jni/python/src/Lib/json/__init__.py
57
12286
r"""A simple, fast, extensible JSON encoder and decoder JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. json exposes an API familiar to uses of the standard library marshal and pickle modules. Encoding basic Python object hierarchies:: >>> import json >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]) '["foo", {"bar": ["baz", null, 1.0, 2]}]' >>> print json.dumps("\"foo\bar") "\"foo\bar" >>> print json.dumps(u'\u1234') "\u1234" >>> print json.dumps('\\') "\\" >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True) {"a": 0, "b": 0, "c": 0} >>> from StringIO import StringIO >>> io = StringIO() >>> json.dump(['streaming API'], io) >>> io.getvalue() '["streaming API"]' Compact encoding:: >>> import json >>> json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',',':')) '[1,2,3,{"4":5,"6":7}]' Pretty printing (using repr() because of extraneous whitespace in the output):: >>> import json >>> print repr(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)) '{\n "4": 5, \n "6": 7\n}' Decoding JSON:: >>> import json >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') [u'foo', {u'bar': [u'baz', None, 1.0, 2]}] >>> json.loads('"\\"foo\\bar"') u'"foo\x08ar' >>> from StringIO import StringIO >>> io = StringIO('["streaming API"]') >>> json.load(io) [u'streaming API'] Specializing JSON object decoding:: >>> import json >>> def as_complex(dct): ... if '__complex__' in dct: ... return complex(dct['real'], dct['imag']) ... return dct ... >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}', ... object_hook=as_complex) (1+2j) >>> import decimal >>> json.loads('1.1', parse_float=decimal.Decimal) Decimal('1.1') Extending JSONEncoder:: >>> import json >>> class ComplexEncoder(json.JSONEncoder): ... def default(self, obj): ... if isinstance(obj, complex): ... return [obj.real, obj.imag] ... return json.JSONEncoder.default(self, obj) ... >>> dumps(2 + 1j, cls=ComplexEncoder) '[2.0, 1.0]' >>> ComplexEncoder().encode(2 + 1j) '[2.0, 1.0]' >>> list(ComplexEncoder().iterencode(2 + 1j)) ['[', '2.0', ', ', '1.0', ']'] Using json.tool from the shell to validate and pretty-print:: $ echo '{"json":"obj"}' | python -mjson.tool { "json": "obj" } $ echo '{ 1.2:3.4}' | python -mjson.tool Expecting property name: line 1 column 2 (char 2) Note that the JSON produced by this module's default settings is a subset of YAML, so it may be used as a serializer for that as well. """ __version__ = '1.9' __all__ = [ 'dump', 'dumps', 'load', 'loads', 'JSONDecoder', 'JSONEncoder', ] __author__ = 'Bob Ippolito <bob@redivi.com>' from .decoder import JSONDecoder from .encoder import JSONEncoder _default_encoder = JSONEncoder( skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, indent=None, separators=None, encoding='utf-8', default=None, ) def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw): """Serialize ``obj`` as a JSON formatted stream to ``fp`` (a ``.write()``-supporting file-like object). If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``. If ``ensure_ascii`` is ``False``, then the some chunks written to ``fp`` may be ``unicode`` instances, subject to normal Python ``str`` to ``unicode`` coercion rules. Unless ``fp.write()`` explicitly understands ``unicode`` (as in ``codecs.getwriter()``) this is likely to cause an error. If ``check_circular`` is ``False``, then the circular reference check for container types will be skipped and a circular reference will result in an ``OverflowError`` (or worse). If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). If ``indent`` is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. ``None`` is the most compact representation. If ``separators`` is an ``(item_separator, dict_separator)`` tuple then it will be used instead of the default ``(', ', ': ')`` separators. ``(',', ':')`` is the most compact JSON representation. ``encoding`` is the character encoding for str instances, default is UTF-8. ``default(obj)`` is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError. To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the ``.default()`` method to serialize additional types), specify it with the ``cls`` kwarg. """ # cached encoder if (skipkeys is False and ensure_ascii is True and check_circular is True and allow_nan is True and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw): iterable = _default_encoder.iterencode(obj) else: if cls is None: cls = JSONEncoder iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii, check_circular=check_circular, allow_nan=allow_nan, indent=indent, separators=separators, encoding=encoding, default=default, **kw).iterencode(obj) # could accelerate with writelines in some versions of Python, at # a debuggability cost for chunk in iterable: fp.write(chunk) def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw): """Serialize ``obj`` to a JSON formatted ``str``. If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``. If ``ensure_ascii`` is ``False``, then the return value will be a ``unicode`` instance subject to normal Python ``str`` to ``unicode`` coercion rules instead of being escaped to an ASCII ``str``. If ``check_circular`` is ``False``, then the circular reference check for container types will be skipped and a circular reference will result in an ``OverflowError`` (or worse). If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``). If ``indent`` is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. ``None`` is the most compact representation. If ``separators`` is an ``(item_separator, dict_separator)`` tuple then it will be used instead of the default ``(', ', ': ')`` separators. ``(',', ':')`` is the most compact JSON representation. ``encoding`` is the character encoding for str instances, default is UTF-8. ``default(obj)`` is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError. To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the ``.default()`` method to serialize additional types), specify it with the ``cls`` kwarg. """ # cached encoder if (skipkeys is False and ensure_ascii is True and check_circular is True and allow_nan is True and cls is None and indent is None and separators is None and encoding == 'utf-8' and default is None and not kw): return _default_encoder.encode(obj) if cls is None: cls = JSONEncoder return cls( skipkeys=skipkeys, ensure_ascii=ensure_ascii, check_circular=check_circular, allow_nan=allow_nan, indent=indent, separators=separators, encoding=encoding, default=default, **kw).encode(obj) _default_decoder = JSONDecoder(encoding=None, object_hook=None) def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, **kw): """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing a JSON document) to a Python object. If the contents of ``fp`` is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed, and should be wrapped with ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode`` object and passed to ``loads()`` ``object_hook`` is an optional function that will be called with the result of any object literal decode (a ``dict``). The return value of ``object_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting). To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` kwarg. """ return loads(fp.read(), encoding=encoding, cls=cls, object_hook=object_hook, parse_float=parse_float, parse_int=parse_int, parse_constant=parse_constant, **kw) def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, **kw): """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON document) to a Python object. If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name must be specified. Encodings that are not ASCII based (such as UCS-2) are not allowed and should be decoded to ``unicode`` first. ``object_hook`` is an optional function that will be called with the result of any object literal decode (a ``dict``). The return value of ``object_hook`` will be used instead of the ``dict``. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting). ``parse_float``, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal). ``parse_int``, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float). ``parse_constant``, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN, null, true, false. This can be used to raise an exception if invalid JSON numbers are encountered. To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` kwarg. """ if (cls is None and encoding is None and object_hook is None and parse_int is None and parse_float is None and parse_constant is None and not kw): return _default_decoder.decode(s) if cls is None: cls = JSONDecoder if object_hook is not None: kw['object_hook'] = object_hook if parse_float is not None: kw['parse_float'] = parse_float if parse_int is not None: kw['parse_int'] = parse_int if parse_constant is not None: kw['parse_constant'] = parse_constant return cls(encoding=encoding, **kw).decode(s)
lgpl-2.1
[ 82, 624, 33, 3486, 12, 7377, 12, 2178, 1164, 4840, 10295, 436, 10334, 199, 199, 6243, 334, 21986, 6935, 2832, 425, 9, 665, 1014, 921, 1001, 14, 1308, 30, 365, 282, 10026, 402, 199, 21986, 6302, 334, 4220, 2054, 13, 14820, 650, 6883, 325, 1671, 9, 1202, 465, 282, 10540, 3463, 666, 199, 1058, 1461, 1475, 14, 199, 199, 1001, 444, 10553, 376, 3261, 21450, 1638, 285, 370, 4440, 402, 314, 4465, 3555, 199, 18376, 436, 5927, 4621, 14, 199, 199, 7630, 5678, 2018, 909, 394, 7081, 1500, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 2941, 1421, 297, 791, 1700, 356, 661, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 6769, 566, 272, 283, 905, 1421, 401, 2420, 1700, 582, 2097, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 6616, 272, 1306, 870, 2022, 14, 4180, 480, 4451, 1421, 60, 1700, 531, 272, 30768, 1421, 60, 1700, 2, 272, 1306, 870, 2022, 14, 4180, 8, 85, 1154, 85, 4321, 358, 272, 1867, 85, 4321, 2, 272, 1306, 870, 2022, 14, 4180, 11671, 358, 272, 9926, 2, 272, 1306, 870, 2022, 14, 4180, 6333, 67, 582, 378, 12, 298, 66, 582, 378, 12, 298, 65, 582, 378, 1386, 4069, 63, 1612, 29, 549, 9, 272, 2420, 65, 582, 378, 12, 298, 66, 582, 378, 12, 298, 67, 582, 378, 93, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 342, 272, 1306, 2022, 14, 2724, 2941, 12076, 3261, 995, 5890, 9, 272, 1306, 5890, 14, 7150, 342, 272, 283, 905, 12076, 3261, 937, 7, 199, 199, 2404, 2442, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 779, 17, 12, 18, 12, 19, 12, 1445, 20, 356, 959, 12, 283, 22, 356, 1520, 22140, 17658, 2687, 23324, 356, 1333, 272, 6730, 17, 12, 18, 12, 19, 12, 6641, 20, 582, 21, 4589, 22, 582, 23, 93, 6616, 199, 199, 27153, 16116, 334, 4941, 4700, 342, 2952, 402, 1599, 26364, 1785, 8139, 315, 314, 1072, 304, 26, 339, 1306, 492, 2022, 272, 1306, 870, 4700, 8, 1001, 14, 4180, 3252, 20, 356, 959, 12, 283, 22, 356, 1520, 1386, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 430, 272, 5041, 60, 78, 259, 298, 20, 582, 959, 12, 971, 78, 259, 298, 22, 582, 1520, 60, 78, 6834, 199, 199, 872, 1523, 4840, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 3640, 360, 905, 1421, 401, 2420, 1700, 582, 905, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 10374, 272, 359, 85, 7, 1421, 297, 469, 85, 7, 1700, 356, 359, 85, 7, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 9420, 61, 272, 1306, 2022, 14, 3640, 14088, 15022, 1421, 1103, 1700, 9008, 272, 399, 4065, 1421, 60, 88, 2036, 285, 7, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 360, 905, 12076, 3261, 937, 358, 272, 1306, 2022, 14, 912, 8, 2308, 9, 272, 359, 85, 1159, 84, 1091, 316, 3261, 418, 199, 199, 12246, 9147, 4840, 909, 15952, 447, 339, 1306, 492, 2022, 272, 1306, 347, 465, 63, 5254, 8, 20660, 304, 272, 2263, 258, 340, 2560, 5254, 12217, 315, 16354, 26, 272, 2263, 260, 372, 6114, 8, 20660, 459, 3093, 995, 16354, 459, 14688, 1105, 272, 2263, 258, 372, 16354, 272, 2263, 272, 1306, 2022, 14, 3640, 360, 6641, 363, 5254, 5727, 2549, 12, 298, 3093, 582, 413, 12, 298, 14688, 582, 499, 7293, 272, 2263, 258, 909, 63, 3664, 29, 305, 63, 5254, 9, 272, 334, 17, 11, 18, 74, 9, 272, 1306, 492, 6107, 272, 1306, 2022, 14, 3640, 360, 17, 14, 17, 297, 2198, 63, 1609, 29, 6355, 14, 6745, 9, 272, 6345, 360, 17, 14, 17, 358, 199, 199, 4377, 1098, 4840, 6679, 447, 339, 1306, 492, 2022, 272, 1306, 1021, 19178, 6679, 8, 1001, 14, 23069, 304, 272, 2263, 258, 347, 849, 8, 277, 12, 1559, 304, 272, 2263, 260, 340, 1228, 8, 1113, 12, 6114, 304, 272, 2263, 3777, 372, 359, 1113, 14, 3093, 12, 1559, 14, 14688, 61, 272, 2263, 260, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 1559, 9, 272, 2263, 272, 1306, 16864, 8, 18, 435, 413, 74, 12, 843, 29, 14500, 6679, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 19178, 6679, 1252, 2143, 8, 18, 435, 413, 74, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 769, 8, 14500, 6679, 1252, 27895, 8, 18, 435, 413, 74, 430, 272, 788, 59, 297, 283, 18, 14, 16, 297, 1656, 1656, 283, 17, 14, 16, 297, 24710, 418, 421, 199, 10369, 2022, 14, 3557, 687, 314, 5218, 370, 4107, 436, 199, 9118, 13, 1361, 447, 339, 2672, 11343, 17137, 1001, 5122, 1113, 3570, 7, 1204, 2366, 446, 77, 1001, 14, 3557, 272, 469, 267, 298, 1001, 582, 298, 1113, 2, 272, 789, 272, 2672, 11343, 5041, 413, 14, 18, 26, 19, 14, 20, 6834, 1204, 2366, 446, 77, 1001, 14, 3557, 272, 15100, 316, 3324, 536, 26, 1004, 413, 2763, 499, 334, 1560, 499, 9, 199, 199, 7443, 626, 314, 4840, 13584, 701, 642, 859, 1159, 849, 2202, 199, 374, 282, 10026, 402, 18916, 12, 880, 652, 1443, 506, 1202, 465, 282, 9146, 367, 626, 465, 5521, 14, 199, 199, 624, 199, 199, 363, 1023, 363, 275, 283, 17, 14, 25, 7, 199, 363, 452, 363, 275, 359, 272, 283, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 297, 272, 283, 6243, 8326, 297, 283, 23069, 297, 199, 61, 199, 199, 363, 2502, 363, 275, 283, 22593, 31045, 555, 317, 475, 665, 7913, 32, 264, 328, 433, 14, 957, 3524, 199, 199, 504, 1275, 8813, 492, 4840, 8326, 199, 504, 1275, 9347, 492, 4840, 6679, 199, 199, 63, 885, 63, 9347, 275, 4840, 6679, 8, 272, 3372, 1612, 29, 797, 12, 272, 4868, 63, 4371, 29, 549, 12, 272, 1104, 63, 23022, 29, 549, 12, 272, 2040, 63, 4304, 29, 549, 12, 272, 4363, 29, 403, 12, 272, 17658, 29, 403, 12, 272, 2644, 534, 1624, 13, 24, 297, 272, 849, 29, 403, 12, 199, 9, 199, 199, 318, 5461, 8 ]
[ 624, 33, 3486, 12, 7377, 12, 2178, 1164, 4840, 10295, 436, 10334, 199, 199, 6243, 334, 21986, 6935, 2832, 425, 9, 665, 1014, 921, 1001, 14, 1308, 30, 365, 282, 10026, 402, 199, 21986, 6302, 334, 4220, 2054, 13, 14820, 650, 6883, 325, 1671, 9, 1202, 465, 282, 10540, 3463, 666, 199, 1058, 1461, 1475, 14, 199, 199, 1001, 444, 10553, 376, 3261, 21450, 1638, 285, 370, 4440, 402, 314, 4465, 3555, 199, 18376, 436, 5927, 4621, 14, 199, 199, 7630, 5678, 2018, 909, 394, 7081, 1500, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 2941, 1421, 297, 791, 1700, 356, 661, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 6769, 566, 272, 283, 905, 1421, 401, 2420, 1700, 582, 2097, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 6616, 272, 1306, 870, 2022, 14, 4180, 480, 4451, 1421, 60, 1700, 531, 272, 30768, 1421, 60, 1700, 2, 272, 1306, 870, 2022, 14, 4180, 8, 85, 1154, 85, 4321, 358, 272, 1867, 85, 4321, 2, 272, 1306, 870, 2022, 14, 4180, 11671, 358, 272, 9926, 2, 272, 1306, 870, 2022, 14, 4180, 6333, 67, 582, 378, 12, 298, 66, 582, 378, 12, 298, 65, 582, 378, 1386, 4069, 63, 1612, 29, 549, 9, 272, 2420, 65, 582, 378, 12, 298, 66, 582, 378, 12, 298, 67, 582, 378, 93, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 342, 272, 1306, 2022, 14, 2724, 2941, 12076, 3261, 995, 5890, 9, 272, 1306, 5890, 14, 7150, 342, 272, 283, 905, 12076, 3261, 937, 7, 199, 199, 2404, 2442, 2644, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 4180, 779, 17, 12, 18, 12, 19, 12, 1445, 20, 356, 959, 12, 283, 22, 356, 1520, 22140, 17658, 2687, 23324, 356, 1333, 272, 6730, 17, 12, 18, 12, 19, 12, 6641, 20, 582, 21, 4589, 22, 582, 23, 93, 6616, 199, 199, 27153, 16116, 334, 4941, 4700, 342, 2952, 402, 1599, 26364, 1785, 8139, 315, 314, 1072, 304, 26, 339, 1306, 492, 2022, 272, 1306, 870, 4700, 8, 1001, 14, 4180, 3252, 20, 356, 959, 12, 283, 22, 356, 1520, 1386, 4069, 63, 1612, 29, 549, 12, 4363, 29, 20, 430, 272, 5041, 60, 78, 259, 298, 20, 582, 959, 12, 971, 78, 259, 298, 22, 582, 1520, 60, 78, 6834, 199, 199, 872, 1523, 4840, 447, 339, 1306, 492, 2022, 272, 1306, 2022, 14, 3640, 360, 905, 1421, 401, 2420, 1700, 582, 905, 6185, 401, 2973, 12, 413, 14, 16, 12, 499, 9420, 10374, 272, 359, 85, 7, 1421, 297, 469, 85, 7, 1700, 356, 359, 85, 7, 6185, 297, 488, 12, 413, 14, 16, 12, 499, 9420, 61, 272, 1306, 2022, 14, 3640, 14088, 15022, 1421, 1103, 1700, 9008, 272, 399, 4065, 1421, 60, 88, 2036, 285, 7, 272, 1306, 687, 5228, 492, 5228, 272, 1306, 5890, 275, 5228, 360, 905, 12076, 3261, 937, 358, 272, 1306, 2022, 14, 912, 8, 2308, 9, 272, 359, 85, 1159, 84, 1091, 316, 3261, 418, 199, 199, 12246, 9147, 4840, 909, 15952, 447, 339, 1306, 492, 2022, 272, 1306, 347, 465, 63, 5254, 8, 20660, 304, 272, 2263, 258, 340, 2560, 5254, 12217, 315, 16354, 26, 272, 2263, 260, 372, 6114, 8, 20660, 459, 3093, 995, 16354, 459, 14688, 1105, 272, 2263, 258, 372, 16354, 272, 2263, 272, 1306, 2022, 14, 3640, 360, 6641, 363, 5254, 5727, 2549, 12, 298, 3093, 582, 413, 12, 298, 14688, 582, 499, 7293, 272, 2263, 258, 909, 63, 3664, 29, 305, 63, 5254, 9, 272, 334, 17, 11, 18, 74, 9, 272, 1306, 492, 6107, 272, 1306, 2022, 14, 3640, 360, 17, 14, 17, 297, 2198, 63, 1609, 29, 6355, 14, 6745, 9, 272, 6345, 360, 17, 14, 17, 358, 199, 199, 4377, 1098, 4840, 6679, 447, 339, 1306, 492, 2022, 272, 1306, 1021, 19178, 6679, 8, 1001, 14, 23069, 304, 272, 2263, 258, 347, 849, 8, 277, 12, 1559, 304, 272, 2263, 260, 340, 1228, 8, 1113, 12, 6114, 304, 272, 2263, 3777, 372, 359, 1113, 14, 3093, 12, 1559, 14, 14688, 61, 272, 2263, 260, 372, 2022, 14, 23069, 14, 885, 8, 277, 12, 1559, 9, 272, 2263, 272, 1306, 16864, 8, 18, 435, 413, 74, 12, 843, 29, 14500, 6679, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 19178, 6679, 1252, 2143, 8, 18, 435, 413, 74, 9, 272, 6730, 18, 14, 16, 12, 413, 14, 16, 6616, 272, 1306, 769, 8, 14500, 6679, 1252, 27895, 8, 18, 435, 413, 74, 430, 272, 788, 59, 297, 283, 18, 14, 16, 297, 1656, 1656, 283, 17, 14, 16, 297, 24710, 418, 421, 199, 10369, 2022, 14, 3557, 687, 314, 5218, 370, 4107, 436, 199, 9118, 13, 1361, 447, 339, 2672, 11343, 17137, 1001, 5122, 1113, 3570, 7, 1204, 2366, 446, 77, 1001, 14, 3557, 272, 469, 267, 298, 1001, 582, 298, 1113, 2, 272, 789, 272, 2672, 11343, 5041, 413, 14, 18, 26, 19, 14, 20, 6834, 1204, 2366, 446, 77, 1001, 14, 3557, 272, 15100, 316, 3324, 536, 26, 1004, 413, 2763, 499, 334, 1560, 499, 9, 199, 199, 7443, 626, 314, 4840, 13584, 701, 642, 859, 1159, 849, 2202, 199, 374, 282, 10026, 402, 18916, 12, 880, 652, 1443, 506, 1202, 465, 282, 9146, 367, 626, 465, 5521, 14, 199, 199, 624, 199, 199, 363, 1023, 363, 275, 283, 17, 14, 25, 7, 199, 363, 452, 363, 275, 359, 272, 283, 2724, 297, 283, 4180, 297, 283, 912, 297, 283, 3640, 297, 272, 283, 6243, 8326, 297, 283, 23069, 297, 199, 61, 199, 199, 363, 2502, 363, 275, 283, 22593, 31045, 555, 317, 475, 665, 7913, 32, 264, 328, 433, 14, 957, 3524, 199, 199, 504, 1275, 8813, 492, 4840, 8326, 199, 504, 1275, 9347, 492, 4840, 6679, 199, 199, 63, 885, 63, 9347, 275, 4840, 6679, 8, 272, 3372, 1612, 29, 797, 12, 272, 4868, 63, 4371, 29, 549, 12, 272, 1104, 63, 23022, 29, 549, 12, 272, 2040, 63, 4304, 29, 549, 12, 272, 4363, 29, 403, 12, 272, 17658, 29, 403, 12, 272, 2644, 534, 1624, 13, 24, 297, 272, 849, 29, 403, 12, 199, 9, 199, 199, 318, 5461, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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STALL + "./") sys.path.append(PATH_INSTALL + "/core") sys.path.append(PATH_INSTALL + "/core/bytecodes") sys.path.append(PATH_INSTALL + "/core/analysis") from androguard import * import analysis TEST = "./geinimi/geinimi.apk" _a = AndroguardS( TEST ) _x = analysis.VMAnalysis( _a.get_vm() ) #print _a.get_strings() KEY = "\x01\x02\x03\x04\x05\x06\x07\x08" _des = pyDes.des( KEY ) #_x.tainted_packages.export_call_graph("toto.dot", "Lcom/swampy/sexpos/pos") tainted_string = _x.tainted_variables.get_string( "DES" ) if tainted_string != None: print "\t -->", tainted_string.get_info() for path in tainted_string.get_paths(): print "\t\t =>", path.get_access_flag(), path.get_method().get_class_name(), path.get_method().get_name(), path.get_method().get_descriptor(), path.get_bb().get_name(), "%x" % ( path.get_bb().start + path.get_idx() ) tainted_field = _x.tainted_variables.get_field( "Lcom/swampy/sexpos/pos/e/k;", "b", "[B" ) if tainted_field != None: print "\t -->", tainted_field.get_info() for path in tainted_field.get_paths(): print "\t\t =>", path.get_access_flag(), path.get_method().get_class_name(), path.get_method().get_name(), path.get_method().get_descriptor(), path.get_bb().get_name(), "%x" % (path.get_bb().start + path.get_idx() ) tainted_field = _x.tainted_variables.get_field( "Lcom/swampy/sexpos/pos/e/p;", "a", "[[B" ) if tainted_field != None: print "\t -->", tainted_field.get_info() for path in tainted_field.get_paths(): print "\t\t =>", path.get_access_flag(), path.get_method().get_class_name(), path.get_method().get_name(), path.get_method().get_descriptor(), path.get_bb().get_name(), "%x" % (path.get_bb().start + path.get_idx() ) if path.get_access_flag() == "W": b = "" for ins in path.get_method().get_code().get_bc().get(): if ins.get_name() == "FILL-ARRAY-DATA": b += ins.get_data() print repr( _des.decrypt( b ) ) tainted_field = _x.tainted_variables.get_field( "Lcom/swampy/sexpos/pos/a;", "g", "Ljava/lang/String;" ) if tainted_field != None: print "\t -->", tainted_field.get_info() for path in tainted_field.get_paths(): print "\t\t =>", path.get_access_flag(), path.get_method().get_class_name(), path.get_method().get_name(), path.get_method().get_descriptor(), path.get_bb().get_name(), "%x" % (path.get_bb().start + path.get_idx() ) tainted_method = _x.tainted_packages.get_method( "Lcom/swampy/sexpos/pos/e/q;", "a", "(Ljava/lang/String;)Ljava/lang/String;" ) for path in tainted_method: print path.get_access_flag(), path.get_method().get_class_name(), path.get_method().get_name(), path.get_method().get_descriptor(), path.get_bb().get_name(), "%x" % (path.get_bb().start + path.get_idx() )
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 8337, 199, 199, 646, 1134, 2586, 199, 199, 3243, 63, 16811, 275, 3680, 6687, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3680, 13589, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 531, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 15, 4414, 6021, 531, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 15, 10466, 531, 199, 199, 504, 436, 293, 15606, 492, 627, 199, 646, 11284, 199, 199, 2864, 275, 26069, 303, 262, 1017, 73, 15, 303, 262, 1017, 73, 14, 23582, 2, 199, 199, 63, 65, 275, 6061, 293, 15606, 51, 8, 7393, 776, 199, 63, 88, 275, 11284, 14, 54, 2054, 78, 2618, 2316, 8, 485, 65, 14, 362, 63, 2611, 342, 776, 199, 199, 3, 1361, 485, 65, 14, 362, 63, 5465, 342, 199, 199, 3078, 275, 1867, 88, 614, 60, 88, 996, 60, 88, 1644, 60, 88, 966, 60, 88, 1717, 60, 88, 1690, 60, 88, 1780, 60, 88, 2036, 2, 199, 63, 3424, 275, 1134, 2586, 14, 3424, 8, 9301, 776, 199, 199, 20930, 88, 14, 877, 471, 63, 5154, 14, 3790, 63, 1250, 63, 2180, 480, 84, 3459, 14, 3287, 401, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 531, 199, 199, 877, 471, 63, 875, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 875, 8, 298, 4448, 2, 776, 199, 692, 307, 1581, 471, 63, 875, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 875, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 875, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 931, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 199, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 75, 17259, 298, 66, 401, 7369, 34, 2, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 421, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 80, 17259, 298, 65, 401, 7369, 59, 34, 2, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 267, 340, 931, 14, 362, 63, 2732, 63, 4173, 342, 508, 298, 55, 582, 288, 330, 275, 3087, 288, 367, 5261, 315, 931, 14, 362, 63, 765, 1252, 362, 63, 600, 1252, 362, 63, 3776, 1252, 362, 837, 355, 340, 5261, 14, 362, 63, 354, 342, 508, 298, 5110, 44, 13, 12322, 13, 3998, 582, 490, 330, 847, 5261, 14, 362, 63, 576, 342, 953, 870, 4700, 8, 485, 3424, 14, 15682, 8, 330, 776, 776, 199, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 65, 17259, 298, 71, 401, 298, 24457, 15, 4159, 15, 1558, 9426, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 199, 199, 877, 471, 63, 765, 275, 485, 88, 14, 877, 471, 63, 5154, 14, 362, 63, 765, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 81, 17259, 298, 65, 401, 7340, 24457, 15, 4159, 15, 1558, 27, 9, 24457, 15, 4159, 15, 1558, 9426, 776, 199, 509, 931, 315, 307, 1581, 471, 63, 765, 26, 272, 870, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 646, 984, 199, 646, 8337, 199, 199, 646, 1134, 2586, 199, 199, 3243, 63, 16811, 275, 3680, 6687, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3680, 13589, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 531, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 15, 4414, 6021, 531, 199, 1274, 14, 515, 14, 740, 8, 3243, 63, 16811, 435, 3286, 1018, 15, 10466, 531, 199, 199, 504, 436, 293, 15606, 492, 627, 199, 646, 11284, 199, 199, 2864, 275, 26069, 303, 262, 1017, 73, 15, 303, 262, 1017, 73, 14, 23582, 2, 199, 199, 63, 65, 275, 6061, 293, 15606, 51, 8, 7393, 776, 199, 63, 88, 275, 11284, 14, 54, 2054, 78, 2618, 2316, 8, 485, 65, 14, 362, 63, 2611, 342, 776, 199, 199, 3, 1361, 485, 65, 14, 362, 63, 5465, 342, 199, 199, 3078, 275, 1867, 88, 614, 60, 88, 996, 60, 88, 1644, 60, 88, 966, 60, 88, 1717, 60, 88, 1690, 60, 88, 1780, 60, 88, 2036, 2, 199, 63, 3424, 275, 1134, 2586, 14, 3424, 8, 9301, 776, 199, 199, 20930, 88, 14, 877, 471, 63, 5154, 14, 3790, 63, 1250, 63, 2180, 480, 84, 3459, 14, 3287, 401, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 531, 199, 199, 877, 471, 63, 875, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 875, 8, 298, 4448, 2, 776, 199, 692, 307, 1581, 471, 63, 875, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 875, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 875, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 931, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 199, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 75, 17259, 298, 66, 401, 7369, 34, 2, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 421, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 80, 17259, 298, 65, 401, 7369, 59, 34, 2, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 267, 340, 931, 14, 362, 63, 2732, 63, 4173, 342, 508, 298, 55, 582, 288, 330, 275, 3087, 288, 367, 5261, 315, 931, 14, 362, 63, 765, 1252, 362, 63, 600, 1252, 362, 63, 3776, 1252, 362, 837, 355, 340, 5261, 14, 362, 63, 354, 342, 508, 298, 5110, 44, 13, 12322, 13, 3998, 582, 490, 330, 847, 5261, 14, 362, 63, 576, 342, 953, 870, 4700, 8, 485, 3424, 14, 15682, 8, 330, 776, 776, 199, 199, 877, 471, 63, 698, 275, 485, 88, 14, 877, 471, 63, 3669, 14, 362, 63, 698, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 65, 17259, 298, 71, 401, 298, 24457, 15, 4159, 15, 1558, 9426, 776, 199, 692, 307, 1581, 471, 63, 698, 1137, 488, 26, 272, 870, 1867, 84, 1553, 7166, 307, 1581, 471, 63, 698, 14, 362, 63, 815, 342, 272, 367, 931, 315, 307, 1581, 471, 63, 698, 14, 362, 63, 3771, 837, 267, 870, 1867, 84, 60, 84, 275, 7166, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 4120, 1062, 931, 14, 362, 63, 2501, 1252, 362, 63, 354, 1062, 2071, 88, 2, 450, 334, 515, 14, 362, 63, 2501, 1252, 928, 435, 931, 14, 362, 63, 2996, 342, 776, 199, 199, 877, 471, 63, 765, 275, 485, 88, 14, 877, 471, 63, 5154, 14, 362, 63, 765, 8, 298, 44, 957, 15, 24262, 5086, 15, 20160, 1712, 15, 1712, 15, 69, 15, 81, 17259, 298, 65, 401, 7340, 24457, 15, 4159, 15, 1558, 27, 9, 24457, 15, 4159, 15, 1558, 9426, 776, 199, 509, 931, 315, 307, 1581, 471, 63, 765, 26, 272, 870, 931, 14, 362, 63, 2732, 63, 4173, 1062, 931, 14, 362, 63, 765, 1252, 362, 63, 533, 63, 354, 1062, 931, 14, 362, 63, 765, 1252, 362, 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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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
fafaman/django
tests/annotations/models.py
238
2901
# coding: utf-8 from django.db import models from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() friends = models.ManyToManyField('self', blank=True) def __str__(self): return self.name @python_2_unicode_compatible class Publisher(models.Model): name = models.CharField(max_length=255) num_awards = models.IntegerField() def __str__(self): return self.name @python_2_unicode_compatible class Book(models.Model): isbn = models.CharField(max_length=9) name = models.CharField(max_length=255) pages = models.IntegerField() rating = models.FloatField() price = models.DecimalField(decimal_places=2, max_digits=6) authors = models.ManyToManyField(Author) contact = models.ForeignKey(Author, models.CASCADE, related_name='book_contact_set') publisher = models.ForeignKey(Publisher, models.CASCADE) pubdate = models.DateField() def __str__(self): return self.name @python_2_unicode_compatible class Store(models.Model): name = models.CharField(max_length=255) books = models.ManyToManyField(Book) original_opening = models.DateTimeField() friday_night_closing = models.TimeField() def __str__(self): return self.name @python_2_unicode_compatible class DepartmentStore(Store): chain = models.CharField(max_length=255) def __str__(self): return '%s - %s ' % (self.chain, self.name) @python_2_unicode_compatible class Employee(models.Model): # The order of these fields matter, do not change. Certain backends # rely on field ordering to perform database conversions, and this # model helps to test that. first_name = models.CharField(max_length=20) manager = models.BooleanField(default=False) last_name = models.CharField(max_length=20) store = models.ForeignKey(Store, models.CASCADE) age = models.IntegerField() salary = models.DecimalField(max_digits=8, decimal_places=2) def __str__(self): return '%s %s' % (self.first_name, self.last_name) @python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=200) motto = models.CharField(max_length=200, null=True, blank=True) ticker_name = models.CharField(max_length=10, null=True, blank=True) description = models.CharField(max_length=200, null=True, blank=True) def __str__(self): return ('Company(name=%s, motto=%s, ticker_name=%s, description=%s)' % (self.name, self.motto, self.ticker_name, self.description) ) @python_2_unicode_compatible class Ticket(models.Model): active_at = models.DateTimeField() duration = models.DurationField() def __str__(self): return '{} - {}'.format(self.active_at, self.duration)
bsd-3-clause
[ 3, 2803, 26, 2774, 13, 24, 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, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11437, 275, 1709, 14, 3901, 342, 272, 26157, 275, 1709, 14, 7624, 360, 277, 297, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 19952, 281, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 1967, 63, 31255, 275, 1709, 14, 3901, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 365, 10472, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 25, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 6497, 275, 1709, 14, 3901, 342, 272, 18360, 275, 1709, 14, 13019, 342, 272, 8033, 275, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 22, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 8966, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 4048, 63, 354, 534, 2706, 63, 7811, 63, 409, 358, 272, 19704, 275, 1709, 14, 3190, 8, 27341, 12, 1709, 14, 10855, 9, 272, 7974, 602, 275, 1709, 14, 14071, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 13874, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 19040, 275, 1709, 14, 7624, 8, 8696, 9, 272, 3379, 63, 21849, 275, 1709, 14, 4626, 342, 272, 289, 322, 2977, 63, 14873, 63, 11707, 275, 1709, 14, 27115, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 1487, 12493, 5502, 8, 5502, 304, 272, 6036, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 283, 450, 334, 277, 14, 4429, 12, 291, 14, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24089, 8, 992, 14, 1685, 304, 272, 327, 710, 1865, 402, 3520, 1504, 17247, 12, 886, 440, 1570, 14, 11002, 877, 14745, 272, 327, 19687, 641, 901, 7794, 370, 5147, 3050, 24796, 12, 436, 642, 272, 327, 1402, 22577, 370, 511, 626, 14, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 5256, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 3877, 275, 1709, 14, 3190, 8, 5502, 12, 1709, 14, 10855, 9, 272, 11437, 275, 1709, 14, 3901, 342, 272, 18641, 695, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 24, 12, 6107, 63, 10696, 29, 18, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 450, 83, 7, 450, 334, 277, 14, 2246, 63, 354, 12, 291, 14, 2019, 63, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 15878, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 333, 357, 475, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 32721, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 16063, 8, 354, 2458, 83, 12, 333, 357, 475, 2458, 83, 12, 32721, 63, 354, 2458, 83, 12, 1369, 2458, 83, 3171, 288, 450, 334, 277, 14, 354, 12, 291, 14, 30034, 475, 12, 291, 14, 28572, 63, 354, 12, 291, 14, 1802, 9, 267, 776, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 21932, 8, 992, 14, 1685, 304, 272, 4702, 63, 292, 275, 1709, 14, 4626, 342, 272, 7373, 275, 1709, 14, 13283, 792, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 9005, 446, 9499, 908, 8, 277, 14, 2682, 63, 292, 12, 291, 14, 5553, 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 ]
[ 2803, 26, 2774, 13, 24, 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, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1960, 9, 272, 11437, 275, 1709, 14, 3901, 342, 272, 26157, 275, 1709, 14, 7624, 360, 277, 297, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 19952, 281, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 1967, 63, 31255, 275, 1709, 14, 3901, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 365, 10472, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 25, 9, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 6497, 275, 1709, 14, 3901, 342, 272, 18360, 275, 1709, 14, 13019, 342, 272, 8033, 275, 1709, 14, 15975, 8, 6355, 63, 10696, 29, 18, 12, 1390, 63, 7022, 29, 22, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 9, 272, 8966, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 4048, 63, 354, 534, 2706, 63, 7811, 63, 409, 358, 272, 19704, 275, 1709, 14, 3190, 8, 27341, 12, 1709, 14, 10855, 9, 272, 7974, 602, 275, 1709, 14, 14071, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 13874, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 19040, 275, 1709, 14, 7624, 8, 8696, 9, 272, 3379, 63, 21849, 275, 1709, 14, 4626, 342, 272, 289, 322, 2977, 63, 14873, 63, 11707, 275, 1709, 14, 27115, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 1487, 12493, 5502, 8, 5502, 304, 272, 6036, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 446, 450, 83, 283, 450, 334, 277, 14, 4429, 12, 291, 14, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 24089, 8, 992, 14, 1685, 304, 272, 327, 710, 1865, 402, 3520, 1504, 17247, 12, 886, 440, 1570, 14, 11002, 877, 14745, 272, 327, 19687, 641, 901, 7794, 370, 5147, 3050, 24796, 12, 436, 642, 272, 327, 1402, 22577, 370, 511, 626, 14, 272, 1642, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 5256, 275, 1709, 14, 5036, 8, 885, 29, 797, 9, 272, 2061, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1165, 9, 272, 3877, 275, 1709, 14, 3190, 8, 5502, 12, 1709, 14, 10855, 9, 272, 11437, 275, 1709, 14, 3901, 342, 272, 18641, 695, 275, 1709, 14, 15975, 8, 988, 63, 7022, 29, 24, 12, 6107, 63, 10696, 29, 18, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 1543, 83, 450, 83, 7, 450, 334, 277, 14, 2246, 63, 354, 12, 291, 14, 2019, 63, 354, 9, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 15878, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 9, 272, 333, 357, 475, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 32721, 63, 354, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 272, 1369, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1840, 12, 2973, 29, 549, 12, 4596, 29, 549, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 661, 16063, 8, 354, 2458, 83, 12, 333, 357, 475, 2458, 83, 12, 32721, 63, 354, 2458, 83, 12, 1369, 2458, 83, 3171, 288, 450, 334, 277, 14, 354, 12, 291, 14, 30034, 475, 12, 291, 14, 28572, 63, 354, 12, 291, 14, 1802, 9, 267, 776, 421, 199, 32, 1548, 63, 18, 63, 2975, 63, 6490, 199, 533, 21932, 8, 992, 14, 1685, 304, 272, 4702, 63, 292, 275, 1709, 14, 4626, 342, 272, 7373, 275, 1709, 14, 13283, 792, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 9005, 446, 9499, 908, 8, 277, 14, 2682, 63, 292, 12, 291, 14, 5553, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
scroiset/cmsplugin-filer
cmsplugin_filer_link/migrations/0001_initial.py
28
14201
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): depends_on = ( ("filer", "0008_polymorphic__del_field_file__file_type_plugin_name"), ) def forwards(self, orm): # Adding model 'FilerLinkPlugin' db.create_table('cmsplugin_filerlinkplugin', ( ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)), ('name', self.gf('django.db.models.fields.CharField')(max_length=255)), ('url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), ('page_link', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['cms.Page'], null=True, blank=True)), ('mailto', self.gf('django.db.models.fields.EmailField')(max_length=75, null=True, blank=True)), ('link_style', self.gf('django.db.models.fields.CharField')(default=' ', max_length=255)), ('new_window', self.gf('django.db.models.fields.BooleanField')(default=False)), ('file', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['filer.File'])), )) db.send_create_signal('cmsplugin_filer_link', ['FilerLinkPlugin']) def backwards(self, orm): # Deleting model 'FilerLinkPlugin' db.delete_table('cmsplugin_filerlinkplugin') models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) }, 'auth.permission': { 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) }, 'auth.user': { 'Meta': {'object_name': 'User'}, 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) }, 'cms.cmsplugin': { 'Meta': {'object_name': 'CMSPlugin'}, 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}), 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}), 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}), 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}), 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) }, 'cms.page': { 'Meta': {'ordering': "('site', 'tree_id', 'lft')", 'object_name': 'Page'}, 'changed_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}), 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'created_by': ('django.db.models.fields.CharField', [], {'max_length': '70'}), 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'in_navigation': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'limit_visibility_in_menu': ('django.db.models.fields.SmallIntegerField', [], {'default': 'None', 'null': 'True', 'db_index': 'True', 'blank': 'True'}), 'login_required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'moderator_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '1', 'blank': 'True'}), 'navigation_extenders': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '80', 'null': 'True', 'blank': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['cms.Page']"}), 'placeholders': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['cms.Placeholder']", 'symmetrical': 'False'}), 'publication_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'publication_end_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'publisher_is_draft': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'publisher_public': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'publisher_draft'", 'unique': 'True', 'null': 'True', 'to': "orm['cms.Page']"}), 'publisher_state': ('django.db.models.fields.SmallIntegerField', [], {'default': '0', 'db_index': 'True'}), 'reverse_id': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '40', 'null': 'True', 'blank': 'True'}), 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'site': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['sites.Site']"}), 'soft_root': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'template': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}) }, 'cms.placeholder': { 'Meta': {'object_name': 'Placeholder'}, 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) }, 'cmsplugin_filer_link.filerlinkplugin': { 'Meta': {'object_name': 'FilerLinkPlugin', 'db_table': "'cmsplugin_filerlinkplugin'", '_ormbases': ['cms.CMSPlugin']}, 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}), 'file': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['filer.File']"}), 'link_style': ('django.db.models.fields.CharField', [], {'default': "' '", 'max_length': '255'}), 'mailto': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'new_window': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'page_link': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Page']", 'null': 'True', 'blank': 'True'}), 'url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}) }, 'contenttypes.contenttype': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) }, 'filer.file': { 'Meta': {'object_name': 'File'}, '_file_size': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), '_file_type_plugin_name': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'folder': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'all_files'", 'null': 'True', 'to': "orm['filer.Folder']"}), 'has_all_mandatory_data': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'is_public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'original_filename': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'owned_files'", 'null': 'True', 'to': "orm['auth.User']"}), 'sha1': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '40', 'blank': 'True'}), 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) }, 'filer.folder': { 'Meta': {'ordering': "('name',)", 'unique_together': "(('parent', 'name'),)", 'object_name': 'Folder'}, 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'modified_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'owner': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'filer_owned_folders'", 'null': 'True', 'to': "orm['auth.User']"}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['filer.Folder']"}), 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}), 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) }, 'sites.site': { 'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"}, 'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) } } complete_apps = ['cmsplugin_filer_link']
bsd-3-clause
[ 3, 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 8350, 63, 265, 275, 334, 267, 1689, 29292, 401, 298, 19141, 63, 16653, 363, 2264, 63, 698, 63, 493, 363, 493, 63, 466, 63, 2718, 63, 354, 1288, 267, 776, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 1402, 283, 1173, 82, 3834, 5061, 7, 267, 1592, 14, 981, 63, 1224, 360, 4400, 30873, 63, 29292, 1073, 2718, 297, 334, 288, 661, 4400, 30873, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 10781, 14, 17834, 5061, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 1826, 288, 661, 633, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1606, 63, 1073, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 10781, 14, 3276, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 26206, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 7533, 988, 63, 1267, 29, 2194, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1073, 63, 2487, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 1656, 1390, 63, 1267, 29, 2299, 1826, 288, 661, 1222, 63, 3806, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 493, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 29292, 14, 1173, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 4400, 30873, 63, 29292, 63, 1073, 297, 788, 1173, 82, 3834, 5061, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 1402, 283, 1173, 82, 3834, 5061, 7, 267, 1592, 14, 1807, 63, 1224, 360, 4400, 30873, 63, 29292, 1073, 2718, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14 ]
[ 2644, 26, 2774, 13, 24, 199, 646, 2197, 199, 504, 12919, 14, 697, 492, 1592, 199, 504, 12919, 14, 86, 18, 492, 24765, 199, 504, 1639, 14, 697, 492, 1709, 199, 199, 533, 12090, 8, 24822, 304, 339, 8350, 63, 265, 275, 334, 267, 1689, 29292, 401, 298, 19141, 63, 16653, 363, 2264, 63, 698, 63, 493, 363, 493, 63, 466, 63, 2718, 63, 354, 1288, 267, 776, 339, 347, 17465, 8, 277, 12, 9813, 304, 2728, 327, 12934, 1402, 283, 1173, 82, 3834, 5061, 7, 267, 1592, 14, 981, 63, 1224, 360, 4400, 30873, 63, 29292, 1073, 2718, 297, 334, 288, 661, 4400, 30873, 63, 4695, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 14298, 7533, 475, 29, 1025, 459, 10781, 14, 17834, 5061, 995, 3747, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 288, 661, 354, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 1826, 288, 661, 633, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 988, 63, 1267, 29, 2299, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1606, 63, 1073, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 10781, 14, 3276, 995, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 26206, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 7533, 988, 63, 1267, 29, 2194, 12, 2973, 29, 549, 12, 4596, 29, 549, 1826, 288, 661, 1073, 63, 2487, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 7533, 885, 534, 1656, 1390, 63, 1267, 29, 2299, 1826, 288, 661, 1222, 63, 3806, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 7533, 885, 29, 797, 1826, 288, 661, 493, 297, 291, 14, 7102, 360, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 7533, 475, 29, 1025, 459, 29292, 14, 1173, 16607, 267, 5082, 267, 1592, 14, 2254, 63, 981, 63, 4653, 360, 4400, 30873, 63, 29292, 63, 1073, 297, 788, 1173, 82, 3834, 5061, 1105, 2378, 347, 8552, 8, 277, 12, 9813, 304, 2728, 327, 15920, 1402, 283, 1173, 82, 3834, 5061, 7, 267, 1592, 14, 1807, 63, 1224, 360, 4400, 30873, 63, 29292, 1073, 2718, 358, 2378, 1709, 275, 469, 267, 283, 1178, 14, 923, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 2448, 2267, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 3235, 356, 283, 549, 297, 283, 988, 63, 1267, 356, 283, 1257, 1604, 288, 283, 6060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 7980, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 3071, 267, 1660, 267, 283, 1178, 14, 5693, 356, 469, 288, 283, 3396, 356, 791, 7128, 356, 16111, 1317, 63, 466, 363, 571, 63, 1302, 297, 283, 1317, 63, 466, 363, 1238, 297, 283, 11879, 18106, 283, 3235, 63, 6314, 356, 9510, 1317, 63, 466, 297, 283, 11879, 9878, 283, 785, 63, 354, 356, 283, 7980, 2267, 288, 283, 11879, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1960, 1604, 288, 283, 1317, 63, 466, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 3190, 297, 990, 791, 475, 356, 298, 1025, 459, 10778, 14, 11282, 6097, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1400, 3071, 267, 1660, 267, 283, 1178, 14, 751, 356, 469, 288, 283, 3396, 356, 791, 785, 63, 354, 356, 283, 1899, 2267, 288, 283, 602, 63, 11806, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2123, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 16577, 297, 990, 791, 988, 63, 1267, 356, 283, 2194, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2246, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2634, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2407, 14, 7624, 297, 990, 791, 475, 356, 298, 1025, 459, 1178, 14, 2448, 6256, 283, 10247, 356, 283, 797, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 344, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4378, 297, 990, 791, 3327, 63, 498, 356, 283, 549, 1604, 288, 283, 374, 63, 2682, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 549, 1604, 288, 283, 374, 63, 7018, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 374, 63, 11434, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 5036, 297, 990, 791, 885, 356, 283, 797, 1604, 288, 283, 2019, 63, 2886, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 4626, 297, 990, 791, 885, 356, 283, 2083, 14, 2083, 14, 2131, 1604, 288, 283, 2019, 63, 354, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 1216, 297, 283, 2500, 356, 283, 549, 1604, 288, 283, 2060, 356, 661, 1176, 14, 697, 14, 992, 14, 955, 14, 2183, 297, 990, 791, 988, 63, 1267, 356, 283, 3933, 1604, 288, 283, 751, 63, 6060, 356, 661, 1176, 14, 697, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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. """Fixer for callable(). This converts callable(obj) into isinstance(obj, collections.Callable), adding a collections import if needed.""" # Local imports from lib2to3 import fixer_base from lib2to3.fixer_util import Call, Name, String, Attr, touch_import class FixCallable(fixer_base.BaseFix): BM_compatible = True order = "pre" # Ignore callable(*args) or use of keywords. # Either could be a hint that the builtin callable() is not being used. PATTERN = """ power< 'callable' trailer< lpar='(' ( not(arglist | argument<any '=' any>) func=any | func=arglist<(not argument<any '=' any>) any ','> ) rpar=')' > after=any* > """ def transform(self, node, results): func = results['func'] touch_import(None, 'collections', node=node) args = [func.clone(), String(', ')] args.extend(Attr(Name('collections'), Name('Callable'))) return Call(Name('isinstance'), args, prefix=node.prefix)
apache-2.0
[ 3, 1898, 10219, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 11985, 281, 367, 4550, 1252, 199, 199, 2765, 15373, 4550, 8, 1113, 9, 1901, 1228, 8, 1113, 12, 5055, 14, 16410, 395, 7791, 282, 199, 7882, 492, 340, 4346, 1041, 199, 199, 3, 10111, 8925, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 6523, 12, 2812, 12, 2624, 12, 20516, 12, 12943, 63, 646, 199, 199, 533, 14811, 16410, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 699, 45, 63, 6490, 275, 715, 339, 1865, 275, 298, 657, 2, 339, 327, 14092, 4550, 2031, 589, 9, 503, 675, 402, 7681, 14, 272, 327, 13083, 4293, 506, 282, 8328, 626, 314, 6762, 4550, 342, 365, 440, 3769, 1202, 14, 272, 31467, 7689, 275, 408, 272, 7074, 28, 283, 8296, 7, 1779, 17357, 28, 634, 462, 534, 360, 490, 334, 440, 8, 26995, 1204, 1423, 28, 1629, 14051, 1263, 18956, 2562, 29, 1629, 1993, 1204, 2562, 29, 26995, 28, 8, 1397, 1423, 28, 1629, 14051, 1263, 18956, 1263, 1656, 8423, 776, 490, 519, 462, 14619, 7, 690, 1779, 2410, 29, 1629, 10, 272, 690, 272, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 2562, 275, 2058, 459, 1532, 418, 398, 12943, 63, 646, 8, 403, 12, 283, 7882, 297, 1031, 29, 932, 9, 398, 1249, 275, 359, 1532, 14, 6311, 1062, 2624, 5102, 283, 1874, 267, 1249, 14, 2880, 8, 7144, 8, 985, 360, 7882, 659, 2812, 360, 16410, 7058, 267, 372, 6523, 8, 985, 360, 6074, 659, 1249, 12, 2403, 29, 932, 14, 1861, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 10219, 4475, 12, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 3909, 370, 29770, 1334, 282, 17636, 28629, 14, 199, 199, 624, 11985, 281, 367, 4550, 1252, 199, 199, 2765, 15373, 4550, 8, 1113, 9, 1901, 1228, 8, 1113, 12, 5055, 14, 16410, 395, 7791, 282, 199, 7882, 492, 340, 4346, 1041, 199, 199, 3, 10111, 8925, 199, 504, 1973, 18, 475, 19, 492, 24739, 63, 1095, 199, 504, 1973, 18, 475, 19, 14, 25973, 63, 1974, 492, 6523, 12, 2812, 12, 2624, 12, 20516, 12, 12943, 63, 646, 199, 199, 533, 14811, 16410, 8, 25973, 63, 1095, 14, 1563, 11985, 304, 272, 699, 45, 63, 6490, 275, 715, 339, 1865, 275, 298, 657, 2, 339, 327, 14092, 4550, 2031, 589, 9, 503, 675, 402, 7681, 14, 272, 327, 13083, 4293, 506, 282, 8328, 626, 314, 6762, 4550, 342, 365, 440, 3769, 1202, 14, 272, 31467, 7689, 275, 408, 272, 7074, 28, 283, 8296, 7, 1779, 17357, 28, 634, 462, 534, 360, 490, 334, 440, 8, 26995, 1204, 1423, 28, 1629, 14051, 1263, 18956, 2562, 29, 1629, 1993, 1204, 2562, 29, 26995, 28, 8, 1397, 1423, 28, 1629, 14051, 1263, 18956, 1263, 1656, 8423, 776, 490, 519, 462, 14619, 7, 690, 1779, 2410, 29, 1629, 10, 272, 690, 272, 408, 339, 347, 5793, 8, 277, 12, 1031, 12, 2058, 304, 267, 2562, 275, 2058, 459, 1532, 418, 398, 12943, 63, 646, 8, 403, 12, 283, 7882, 297, 1031, 29, 932, 9, 398, 1249, 275, 359, 1532, 14, 6311, 1062, 2624, 5102, 283, 1874, 267, 1249, 14, 2880, 8, 7144, 8, 985, 360, 7882, 659, 2812, 360, 16410, 7058, 267, 372, 6523, 8, 985, 360, 6074, 659, 1249, 12, 2403, 29, 932, 14, 1861, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jiachenning/odoo
openerp/loglevels.py
380
3930
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import sys LOG_NOTSET = 'notset' LOG_DEBUG = 'debug' LOG_INFO = 'info' LOG_WARNING = 'warn' LOG_ERROR = 'error' LOG_CRITICAL = 'critical' # TODO get_encodings, ustr and exception_to_unicode were originally from tools.misc. # There are here until we refactor tools so that this module doesn't depends on tools. def get_encodings(hint_encoding='utf-8'): fallbacks = { 'latin1': 'latin9', 'iso-8859-1': 'iso8859-15', 'cp1252': '1252', } if hint_encoding: yield hint_encoding if hint_encoding.lower() in fallbacks: yield fallbacks[hint_encoding.lower()] # some defaults (also taking care of pure ASCII) for charset in ['utf8','latin1']: if not hint_encoding or (charset.lower() != hint_encoding.lower()): yield charset from locale import getpreferredencoding prefenc = getpreferredencoding() if prefenc and prefenc.lower() != 'utf-8': yield prefenc prefenc = fallbacks.get(prefenc.lower()) if prefenc: yield prefenc def ustr(value, hint_encoding='utf-8', errors='strict'): """This method is similar to the builtin `unicode`, except that it may try multiple encodings to find one that works for decoding `value`, and defaults to 'utf-8' first. :param: value: the value to convert :param: hint_encoding: an optional encoding that was detecte upstream and should be tried first to decode ``value``. :param str errors: optional `errors` flag to pass to the unicode built-in to indicate how illegal character values should be treated when converting a string: 'strict', 'ignore' or 'replace' (see ``unicode()`` constructor). Passing anything other than 'strict' means that the first encoding tried will be used, even if it's not the correct one to use, so be careful! Ignored if value is not a string/unicode. :raise: UnicodeError if value cannot be coerced to unicode :return: unicode string representing the given value """ if isinstance(value, Exception): return exception_to_unicode(value) if isinstance(value, unicode): return value if not isinstance(value, basestring): try: return unicode(value) except Exception: raise UnicodeError('unable to convert %r' % (value,)) for ln in get_encodings(hint_encoding): try: return unicode(value, ln, errors=errors) except Exception: pass raise UnicodeError('unable to convert %r' % (value,)) def exception_to_unicode(e): if (sys.version_info[:2] < (2,6)) and hasattr(e, 'message'): return ustr(e.message) if hasattr(e, 'args'): return "\n".join((ustr(a) for a in e.args)) try: return unicode(e) except Exception: return u"Unknown message" # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 984, 199, 199, 4947, 63, 4609, 3597, 275, 283, 1397, 409, 7, 199, 4947, 63, 5287, 275, 283, 1757, 7, 199, 4947, 63, 4531, 275, 283, 815, 7, 199, 4947, 63, 9171, 275, 283, 4050, 7, 199, 4947, 63, 3170, 275, 283, 705, 7, 199, 4947, 63, 21539, 275, 283, 13138, 7, 199, 199, 3, 3254, 664, 63, 21138, 12, 399, 495, 436, 1919, 63, 475, 63, 2975, 4898, 20657, 687, 7249, 14, 9923, 14, 199, 3, 6006, 787, 2348, 5133, 781, 24200, 7249, 880, 626, 642, 859, 3181, 1133, 8350, 641, 7249, 14, 199, 199, 318, 664, 63, 21138, 8, 6479, 63, 2991, 534, 1624, 13, 24, 735, 272, 9567, 83, 275, 469, 267, 283, 10378, 17, 356, 283, 10378, 25, 297, 267, 283, 4595, 13, 4830, 13, 17, 356, 283, 4595, 4830, 13, 1046, 297, 267, 283, 1850, 19364, 356, 283, 19364, 297, 272, 789, 272, 340, 8328, 63, 2991, 26, 267, 1995, 8328, 63, 2991, 267, 340, 8328, 63, 2991, 14, 2325, 342, 315, 9567, 83, 26, 288, 1995, 9567, 83, 59, 6479, 63, 2991, 14, 2325, 5106, 339, 327, 2005, 4243, 334, 12344, 16466, 10296, 402, 15111, 10485, 9, 272, 367, 5960, 315, 788, 1624, 24, 1673, 10378, 17, 2565, 267, 340, 440, 8328, 63, 2991, 503, 334, 6043, 14, 2325, 342, 1137, 8328, 63, 2991, 14, 2325, 5109, 288, 1995, 5960, 339, 687, 5867, 492, 664, 24283, 264, 848, 1523, 272, 20491, 10945, 275, 664, 24283, 264, 848, 1523, 342, 272, 340, 20491, 10945, 436, 20491, 10945, 14, 2325, 342, 1137, 283, 1624, 13, 24, 356, 267, 1995, 20491, 10945, 267, 20491, 10945, 275, 9567, 83, 14, 362, 8, 13829, 10945, 14, 2325, 1012, 267, 340, 20491, 10945, 26, 288, 1995, 20491, 10945, 199, 199, 318, 399, 495, 8, 585, 12, 8328, 63, 2991, 534, 1624, 13, 24, 297, 2552, 534, 4768, 735, 272, 408, 2765, 1083, 365, 8545, 370, 314, 6762, 658, 2975, 3559, 871, 272, 626, 652, 1443, 862, 3663, 14134, 370, 2342, 1373, 626, 5419, 272, 367, 15952, 658, 585, 3559, 436, 4243, 370, 283, 1624, 13, 24, 7, 1642, 14, 339, 520, 635, 26, 574, 26, 314, 574, 370, 3957, 272, 520, 635, 26, 8328, 63, 2991, 26, 376, 2716, 2644, 626, 1990, 477, 266, 67, 266, 267, 18932, 436, 1077, 506, 16416, 1642, 370, 4849, 1124, 585, 4345, 272, 520, 635, 620, 2552, 26, 2716, 658, 2550, 64, 3305, 370, 986, 370, 314, 2649, 267, 6137, 13, 262, 370, 6623, 4212, 20282, 4528, 1338, 1077, 506, 267, 10184, 1380, 13806, 282, 1059, 26, 283, 4768, 297, 283, 4247, 7, 503, 283, 1814, 7, 267, 334, 3239, 1124, 2975, 8497, 3787, 680, 267, 31755, 7003, 1163, 2419, 283, 4768, 7, 4910, 626, 314, 1642, 267, 2644, 16416, 911, 506, 1202, 12, 2755, 340, 652, 1159, 440, 314, 3211, 267, 1373, 370, 675, 12, 880, 506, 25082, 1, 27662, 340, 574, 365, 440, 282, 1059, 15, 2975, 14, 272, 520, 3730, 26, 20872, 340, 574, 3913, 506, 20650, 6867, 370, 2649, 272, 520, 1107, 26, 2649, 1059, 6144, 314, 1627, 574, 272, 408, 272, 340, 1228, 8, 585, 12, 2186, 304, 267, 372, 1919, 63, 475, 63, 2975, 8, 585, 9, 339, 340, 1228, 8, 585, 12, 2649, 304, 267, 372, 574, 339, 340, 440, 1228, 8, 585, 12, 7116, 304, 267, 862, 26, 288, 372, 2649, 8, 585, 9, 267, 871, 2186, 26, 288, 746, 20872, 360, 17200, 370, 3957, 450, 82, 7, 450, 334, 585, 4641, 339, 367, 10359, 315, 664, 63, 21138, 8, 6479, 63, 2991, 304, 267, 862, 26, 288, 372, 2649, 8, 585, 12, 10359, 12, 2552, 29, 2550, 9, 267, 871, 2186, 26, 288, 986, 272, 746, 20872, 360, 17200, 370, 3957, 450, 82, 7, 450, 334, 585, 4641, 421, 199, 318, 1919, 63, 475, 63, 2975, 8, 69, 304, 272, 340, 334, 1274, 14, 1023, 63, 815, 1491, 18, 61, 665, 334, 18, 12, 22, 430, 436, 2688, 8, 69, 12, 283, 1188, 735, 267, 372, 399, 495, 8, 69, 14, 1188, 9, 272, 340, 2688, 8, 69, 12, 283, 589, 735, 267, 372, 1867, 78, 1674, 904, 1332, 11409, 8, 65, 9, 367, 282, 315, 325, 14, 589, 430, 272, 862, 26, 267, 372, 2649, 8, 69, 9, 272, 871, 2186, 26, 267, 372, 399, 2, 5912, 1245, 2, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 984, 199, 199, 4947, 63, 4609, 3597, 275, 283, 1397, 409, 7, 199, 4947, 63, 5287, 275, 283, 1757, 7, 199, 4947, 63, 4531, 275, 283, 815, 7, 199, 4947, 63, 9171, 275, 283, 4050, 7, 199, 4947, 63, 3170, 275, 283, 705, 7, 199, 4947, 63, 21539, 275, 283, 13138, 7, 199, 199, 3, 3254, 664, 63, 21138, 12, 399, 495, 436, 1919, 63, 475, 63, 2975, 4898, 20657, 687, 7249, 14, 9923, 14, 199, 3, 6006, 787, 2348, 5133, 781, 24200, 7249, 880, 626, 642, 859, 3181, 1133, 8350, 641, 7249, 14, 199, 199, 318, 664, 63, 21138, 8, 6479, 63, 2991, 534, 1624, 13, 24, 735, 272, 9567, 83, 275, 469, 267, 283, 10378, 17, 356, 283, 10378, 25, 297, 267, 283, 4595, 13, 4830, 13, 17, 356, 283, 4595, 4830, 13, 1046, 297, 267, 283, 1850, 19364, 356, 283, 19364, 297, 272, 789, 272, 340, 8328, 63, 2991, 26, 267, 1995, 8328, 63, 2991, 267, 340, 8328, 63, 2991, 14, 2325, 342, 315, 9567, 83, 26, 288, 1995, 9567, 83, 59, 6479, 63, 2991, 14, 2325, 5106, 339, 327, 2005, 4243, 334, 12344, 16466, 10296, 402, 15111, 10485, 9, 272, 367, 5960, 315, 788, 1624, 24, 1673, 10378, 17, 2565, 267, 340, 440, 8328, 63, 2991, 503, 334, 6043, 14, 2325, 342, 1137, 8328, 63, 2991, 14, 2325, 5109, 288, 1995, 5960, 339, 687, 5867, 492, 664, 24283, 264, 848, 1523, 272, 20491, 10945, 275, 664, 24283, 264, 848, 1523, 342, 272, 340, 20491, 10945, 436, 20491, 10945, 14, 2325, 342, 1137, 283, 1624, 13, 24, 356, 267, 1995, 20491, 10945, 267, 20491, 10945, 275, 9567, 83, 14, 362, 8, 13829, 10945, 14, 2325, 1012, 267, 340, 20491, 10945, 26, 288, 1995, 20491, 10945, 199, 199, 318, 399, 495, 8, 585, 12, 8328, 63, 2991, 534, 1624, 13, 24, 297, 2552, 534, 4768, 735, 272, 408, 2765, 1083, 365, 8545, 370, 314, 6762, 658, 2975, 3559, 871, 272, 626, 652, 1443, 862, 3663, 14134, 370, 2342, 1373, 626, 5419, 272, 367, 15952, 658, 585, 3559, 436, 4243, 370, 283, 1624, 13, 24, 7, 1642, 14, 339, 520, 635, 26, 574, 26, 314, 574, 370, 3957, 272, 520, 635, 26, 8328, 63, 2991, 26, 376, 2716, 2644, 626, 1990, 477, 266, 67, 266, 267, 18932, 436, 1077, 506, 16416, 1642, 370, 4849, 1124, 585, 4345, 272, 520, 635, 620, 2552, 26, 2716, 658, 2550, 64, 3305, 370, 986, 370, 314, 2649, 267, 6137, 13, 262, 370, 6623, 4212, 20282, 4528, 1338, 1077, 506, 267, 10184, 1380, 13806, 282, 1059, 26, 283, 4768, 297, 283, 4247, 7, 503, 283, 1814, 7, 267, 334, 3239, 1124, 2975, 8497, 3787, 680, 267, 31755, 7003, 1163, 2419, 283, 4768, 7, 4910, 626, 314, 1642, 267, 2644, 16416, 911, 506, 1202, 12, 2755, 340, 652, 1159, 440, 314, 3211, 267, 1373, 370, 675, 12, 880, 506, 25082, 1, 27662, 340, 574, 365, 440, 282, 1059, 15, 2975, 14, 272, 520, 3730, 26, 20872, 340, 574, 3913, 506, 20650, 6867, 370, 2649, 272, 520, 1107, 26, 2649, 1059, 6144, 314, 1627, 574, 272, 408, 272, 340, 1228, 8, 585, 12, 2186, 304, 267, 372, 1919, 63, 475, 63, 2975, 8, 585, 9, 339, 340, 1228, 8, 585, 12, 2649, 304, 267, 372, 574, 339, 340, 440, 1228, 8, 585, 12, 7116, 304, 267, 862, 26, 288, 372, 2649, 8, 585, 9, 267, 871, 2186, 26, 288, 746, 20872, 360, 17200, 370, 3957, 450, 82, 7, 450, 334, 585, 4641, 339, 367, 10359, 315, 664, 63, 21138, 8, 6479, 63, 2991, 304, 267, 862, 26, 288, 372, 2649, 8, 585, 12, 10359, 12, 2552, 29, 2550, 9, 267, 871, 2186, 26, 288, 986, 272, 746, 20872, 360, 17200, 370, 3957, 450, 82, 7, 450, 334, 585, 4641, 421, 199, 318, 1919, 63, 475, 63, 2975, 8, 69, 304, 272, 340, 334, 1274, 14, 1023, 63, 815, 1491, 18, 61, 665, 334, 18, 12, 22, 430, 436, 2688, 8, 69, 12, 283, 1188, 735, 267, 372, 399, 495, 8, 69, 14, 1188, 9, 272, 340, 2688, 8, 69, 12, 283, 589, 735, 267, 372, 1867, 78, 1674, 904, 1332, 11409, 8, 65, 9, 367, 282, 315, 325, 14, 589, 430, 272, 862, 26, 267, 372, 2649, 8, 69, 9, 272, 871, 2186, 26, 267, 372, 399, 2, 5912, 1245, 2, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hbrunn/OCB
addons/portal_project_issue/tests/__init__.py
260
1086
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Business Applications # Copyright (c) 2013-TODAY OpenERP S.A. <http://openerp.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from . import test_access_rights # 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, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 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, 199, 199, 504, 1275, 492, 511, 63, 2732, 63, 17307, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 67, 9, 6171, 13, 2566, 11655, 7653, 428, 14, 33, 14, 665, 1014, 921, 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, 199, 199, 504, 1275, 492, 511, 63, 2732, 63, 17307, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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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 ]
dalejung/naginpy
naginpy/special_eval/tests/test_manifest.py
1
15685
import ast from unittest import TestCase from textwrap import dedent import pandas as pd import numpy as np from numpy.testing import assert_almost_equal import nose.tools as nt from asttools import ( ast_equal ) from ..manifest import ( Expression, Manifest, _manifest ) from ..exec_context import ( ContextObject, SourceObject, ExecutionContext, get_source_key ) from .common import ArangeSource def grab_expression_from_assign(code): node = code.body[0].value expr = ast.Expression(lineno=0, col_offset=0, body=node) return expr class TestExpression(TestCase): def test_expression(self): source = """ arr = np.arange(20) res = np.sum(arr) """ source = dedent(source) lines = source.strip().split('\n') load_names = [['np'], ['np', 'arr']] for i, line in enumerate(lines): code = ast.parse(line, '<>', 'exec') # expression must be evaluable, assignments are not with nt.assert_raises(Exception): Expression(code.body[0]) extracted_expr = grab_expression_from_assign(code) # skip the assign base_expr = ast.parse(line.split('=')[1].strip(), mode='eval') exp1 = Expression(extracted_expr) exp2 = Expression(base_expr) nt.assert_equal(exp1, exp2) nt.assert_is_not(exp1, exp2) nt.assert_count_equal(exp1.load_names(), load_names[i]) def test_single_line(self): """ Expressoins can only be single line """ source = """ np.arange(20) np.sum(arr) """ source = dedent(source) code = ast.parse(source) # expression must be single line with nt.assert_raises(Exception): Expression(code) # single line still works Expression(code.body[0]) Expression(code.body[1]) def test_expression_conversion(self): """ So I'm not 100% sure on converting all code into ast.Expressions. Right now it is what I'm doing, so might as well explicitly test? """ source = """ np.arange(20) np.sum(arr) """ source = dedent(source) code = ast.parse(source) expr1 = Expression(code.body[0]) nt.assert_is_instance(expr1.code, ast.Expression) expr2 = Expression(code.body[1]) nt.assert_is_instance(expr2.code, ast.Expression) expr3 = Expression("np.arange(15)") nt.assert_is_instance(expr3.code, ast.Expression) def test_key(self): """ stable hash key """ source = """ np.arange(20) np.sum(arr) """ source = dedent(source) code = ast.parse(source) expr1 = Expression(code.body[0]) expr2 = Expression(code.body[1]) import binascii # changed key to return str, same hash just different rep correct1 = b'}\xff\x1c\x0er\xe8k3\x84\x96R\x98\x9a\xa4\xe0i' correct1 = binascii.b2a_hex(correct1).decode('utf-8') correct2 = b'\xd6\x88\x08\xa2\xd0\x01\xa4\xc6\xabb\x1aTj\xce\x98\x18' correct2 = binascii.b2a_hex(correct2).decode('utf-8') # keys are stable and should not change between lifecycles nt.assert_equal(expr1.key, correct1) nt.assert_equal(expr2.key, correct2) # key also works for equals nt.assert_equal(expr1, correct1) nt.assert_equal(expr2, correct2) def test_copy(self): """ test copy """ source = """ np.arange(20) """ source = dedent(source) code = ast.parse(source) expr1 = Expression(code.body[0]) expr2 = expr1.copy() # equivalent value nt.assert_true(ast_equal(expr1.code, expr2.code)) # but not the same nt.assert_is_not(expr1.code, expr2.code) nt.assert_is_not(expr1.code.body, expr2.code.body) # mutability nt.assert_false(expr2.mutable) expr3 = expr1.copy(mutable=True) nt.assert_true(expr3.mutable) def test_mutability(self): """ test immutability """ source = """ np.arange(20) """ source = dedent(source) code = ast.parse(source) new_num = ast.Num(n=3) expr1 = Expression(code.body[0]) with nt.assert_raises_regexp(Exception, "This expression is not mutable"): expr1.replace(new_num, expr1.code.body, 'args', 0) expr2 = expr1.copy(mutable=True) old_key = expr2.key expr2.replace(new_num, expr2.code.body, 'args', 0) nt.assert_not_equal(expr2.key, old_key) # expr2 was changed nt.assert_false(ast_equal(expr1.code, expr2.code)) nt.assert_equal(expr2.get_source(), 'np.arange(3)') class TestManifest(TestCase): def test_eval(self): source = "d * string_test" context = { 'd': 13, 'string_test': 'string_test' } expr = Expression(source) exec_context = ExecutionContext(context) manifest = Manifest(expr, exec_context) nt.assert_equal(manifest.eval(), 'string_test' * 13) def test_equals(self): source = "d * string_test" context = { 'd': 13, 'string_test': 'string_test' } expr = Expression(source) exec_context = ExecutionContext(context) manifest = Manifest(expr, exec_context) manifest2 = Manifest(expr, exec_context) nt.assert_equal(manifest, manifest2) # change expression expr3 = Expression("d * string_test * 2") manifest3 = Manifest(expr3, exec_context) nt.assert_not_equal(manifest, manifest3) # change context context4 = { 'd': 11, 'string_test': 'string_test' } exec_context4 = ExecutionContext(context4) manifest4 = Manifest(expr, exec_context4) nt.assert_not_equal(manifest, manifest4) def test_nested_eval(self): """ d * (1 + arr + arr2[10:]) which is really two manifests arr_manifest = (1 + arr + arr2[10:]) manfiest = (d * (arr_manifest)) """ arr_source = "1 + arr + arr2[10:]" aranger = ArangeSource() arr_context = { 'arr': SourceObject(aranger, 10), 'arr2': SourceObject(aranger, 20), } arr_expr = Expression(arr_source) arr_exec_context = ExecutionContext.from_ns(arr_context) arr_manifest = Manifest(arr_expr, arr_exec_context) source = "d * arr" context = { 'd': 13, 'arr': arr_manifest } expr = Expression(source) exec_context = ExecutionContext.from_ns(context) manifest = Manifest(expr, exec_context) correct = 13 * (1 + np.arange(10) + np.arange(20)[10:]) # up till this point, everything is lazy nt.assert_equal(len(aranger.cache), 0) assert_almost_equal(correct, manifest.eval()) nt.assert_equal(len(aranger.cache), 2) def test_hashable(self): source = "d * string_test" context = { 'd': 13, 'string_test': 'string_test' } expr = Expression(source) exec_context = ExecutionContext(context) manifest = Manifest(expr, exec_context) d = {} d[manifest] = manifest #hashable key = tuple([manifest.expression, manifest.context]) # test key nt.assert_in(key, d) # a feature is being able to check expression.key for cases # where we don't have the source and just the stable key stable_key = tuple([expr.key, manifest.context]) nt.assert_in(stable_key, d) def test_stateless(self): """ stateless-ness of Manifest depends on context """ source = "d * string_test" context = { 'd': 13, 'string_test': 'string_test' } expr = Expression(source) exec_context = ExecutionContext(context) manifest = Manifest(expr, exec_context) nt.assert_equal(manifest.stateless, True) context = { 'd': 13, 'string_test': object(), } expr = Expression(source) exec_context = ExecutionContext.from_ns(context) manifest = Manifest(expr, exec_context) nt.assert_equal(manifest.stateless, False) def test_fragment(): """ This is a failing test atm. What I want is the ability to take two manifest and see whether one is within the other. A couple of notes. They sub-expression itself would obviously need to match. With each sub expression, you can have a subset of execution contexts. it is that subset that needs to match. Manifest 1: Expression: arr1 + np.log(arr2) ExecutionContext: arr1 = np.random(10) arr2 = np.arange(10) Manifest 2: Expression: np.log(arr1) ExecutionContext: arr1 = np.arange(10) Here manifest 2 should be considered subset of Manfiest 1, provided that np.arange is wrapped to be stateless. Now, currently our hash is done via the string repr. Since `arr2` in Manifest 1 is `arr1` in Manfiest 2, we currently wouldn't match. So we'd need to match the load name by value and not by name. I suppose one could have a modified ast_source that replaced load names with pos IDs. """ c = 1 df = pd.DataFrame(np.random.randn(30, 3), columns=['a', 'bob', 'c']) source = """pd.core.window.Rolling(np.log(df + 10), 5, min_periods=c).sum()""" ns = locals() ns.update({k:v for k, v in globals().items() if k not in ns}) manifest = _manifest(source, ns) sub_mf = _manifest("np.log(df+10)", ns.copy()) nt.assert_in(sub_mf, manifest) # new dataframe, does effect contains ns['df'] = pd.DataFrame(np.random.randn(30, 3), columns=['a', 'bob', 'c']) sub_mf = _manifest("np.log(df+10)", ns.copy()) nt.assert_not_in(sub_mf, manifest) # c is changed but not part of fragment, so doesn't effect contains ns['c'] = 3 manifest = _manifest(source, ns) sub_mf = _manifest("np.log(df+10)", ns.copy()) nt.assert_in(sub_mf, manifest) def test_fragment_var_name(): """ This should match even though the variable names are different. """ c = 1 df = pd.DataFrame(np.random.randn(30, 3), columns=['a', 'bob', 'c']) source = """pd.core.window.Rolling(np.log(df + 10), 5, min_periods=c).sum()""" ns = locals() ns.update({k:v for k, v in globals().items() if k not in ns}) manifest = _manifest(source, ns) # use blah instead of df. same code. ns['blah'] = ns['df'] sub_mf = _manifest("np.log(blah+10)", ns) nt.assert_in(sub_mf, manifest) # now change blah to be a differnt value ns['blah'] = 1 sub_mf = _manifest("np.log(blah+10)", ns) nt.assert_not_in(sub_mf, manifest) def test_fragment_order_of_ops(): """ So, in a pure math sense, you should be able to do this replacement: E1 = a + b + a + (a + b) S = b + a + (a + b) E3 = a + S E1 == E3 But since in python, the order of operations matters, you can't just treat that as a subset.(a + b) is not always the same as (b + a) Dumb example: class Bob: def __add__(self, other): return other a = Bob() b = Bob() nt.assert_not_equal(a + b, b + a) """ # TODO, is there a way to subset when dealing with types where operations # are commutative? ns = {'a': 1, 'b': 2} manifest = _manifest("a + b + a + (a + b)", ns) manifest2 = _manifest("b + a + (a + b)", ns) nt.assert_not_in(manifest2, manifest) def test_manifest_partial(): """ Mechanism where the take a Manifest and supply a partial value via another Manifest. """ ns = {'a': 1, 'b': 2, 'c': 3, 'd': 4} parent = _manifest("a + (c + d)", ns) sub = _manifest("(x + y)", {'x': 3, 'y': 4}) # note we are purposely giving wrong answer items = {sub: 3} test = parent.eval_with(items, ignore_var_names=True) nt.assert_equal(test, 4) # parent unaffected nt.assert_equal(parent.eval(), 8) # sub also un affected nt.assert_equal(sub.eval(), 7) def test_manifest_partial_multi(): ns = {'a': 1, 'b': 2, 'c': 3, 'd': 4} parent = _manifest("a + (c + d) + (a + b)", ns) # we are expecting these to match by execution context sub = _manifest("(x + y)", {'x': 3, 'y': 4}) sub2 = _manifest("(x + y)", {'x': 1, 'y': 2}) items = {sub: sub.eval(), sub2: sub2.eval()} # this errors since we don't multi match on the ast_contains test = parent.eval_with(items, ignore_var_names=True) nt.assert_equal(test, 11) items = {sub: sub, sub2: sub2} test = parent.eval_with(items, ignore_var_names=True) nt.assert_equal(test, 11) # pass in only manifest test = parent.eval_with([sub, sub2], ignore_var_names=True) nt.assert_equal(test, 11) def test_eval_with_execution_count(): class Value: """ value that keeps track of when it is used in ops """ def __init__(self, value): self.value = value self.op_count = 0 def get_obj(self): return self.value def __add__(self, other): self.op_count += 1 return self.value + other def __radd__(self, other): self.op_count += 1 return self.value + other ns = { 'a': Value(1), 'b': Value(2), 'c': Value(3), 'd': Value(4), 'e': Value(5) } parent = _manifest("e + (c + d) + (a + b)", ns) # we are expecting these to match by execution context sub = _manifest("(a + b)", ns) sub2 = _manifest("(c + d)", ns) items = {sub: sub.eval(), sub2: sub2.eval()} # a through d should have been used nt.assert_equal(ns['a'].op_count, 1) nt.assert_equal(ns['b'].op_count, 1) nt.assert_equal(ns['c'].op_count, 1) nt.assert_equal(ns['d'].op_count, 1) nt.assert_equal(ns['e'].op_count, 0) res = parent.eval_with(items) nt.assert_equal(res, 1+2+3+4+5) # make sure we did not use the Value again nt.assert_equal(ns['a'].op_count, 1) nt.assert_equal(ns['b'].op_count, 1) nt.assert_equal(ns['c'].op_count, 1) nt.assert_equal(ns['d'].op_count, 1) nt.assert_equal(ns['e'].op_count, 1) # gets used # normal non partial eval res = parent.eval() nt.assert_equal(res, 1+2+3+4+5) # since we did a full eval, everything got run again nt.assert_equal(ns['a'].op_count, 2) nt.assert_equal(ns['b'].op_count, 2) nt.assert_equal(ns['c'].op_count, 2) nt.assert_equal(ns['d'].op_count, 2) nt.assert_equal(ns['e'].op_count, 2) # gets used def test_expanded_multi_nested_partial(): # we are expecting these to match by execution context ns = {'test1':0, 'test2': 1} leaf = _manifest("(test1 + test2)", ns) ns = {'x':1, 'y': leaf} xy = _manifest("(x + y)", ns) ns = {'a': 1, 'b': xy} sub = _manifest("(a + b)", ns) parent_ns = {'e': 3, 'a': sub} parent = _manifest("e + a", parent_ns) expanded = parent.expand() nt.assert_count_equal(expanded.context.keys(), ['a', 'e', 'x', 'test1', 'test2']) nt.assert_equal(expanded.expression.get_source(), "(e + (a + (x + (test1 + test2))))") nt.assert_equal(expanded.eval(), 6)
mit
[ 646, 6073, 199, 504, 2882, 492, 7640, 199, 504, 13390, 492, 22622, 199, 199, 646, 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 646, 11354, 14, 2537, 465, 13377, 199, 199, 504, 6073, 2537, 492, 334, 272, 6073, 63, 1452, 199, 9, 199, 199, 504, 2508, 6418, 492, 334, 272, 22013, 12, 272, 4688, 3944, 12, 272, 485, 6418, 199, 9, 199, 199, 504, 2508, 1628, 63, 1100, 492, 334, 272, 9470, 1692, 12, 272, 5800, 1692, 12, 272, 28573, 2998, 12, 272, 664, 63, 1365, 63, 498, 199, 9, 199, 199, 504, 1275, 2330, 492, 437, 1842, 2980, 199, 199, 318, 18200, 63, 5599, 63, 504, 63, 5038, 8, 600, 304, 272, 1031, 275, 1233, 14, 2030, 59, 16, 1055, 585, 272, 5348, 275, 6073, 14, 9093, 8, 3469, 29, 16, 12, 1048, 63, 2743, 29, 16, 12, 2396, 29, 932, 9, 272, 372, 5348, 199, 199, 533, 1379, 9093, 8, 1746, 304, 272, 347, 511, 63, 5599, 8, 277, 304, 267, 1350, 275, 408, 267, 7953, 275, 980, 14, 5605, 8, 1165, 9, 267, 522, 275, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 2385, 275, 1350, 14, 1913, 1252, 1294, 2258, 78, 358, 267, 2248, 63, 1247, 275, 11194, 1590, 995, 788, 1590, 297, 283, 5250, 6538, 267, 367, 284, 12, 1004, 315, 3874, 8, 1278, 304, 288, 1233, 275, 6073, 14, 1122, 8, 604, 12, 2650, 4206, 283, 1628, 358, 953, 327, 3965, 1471, 506, 8031, 461, 12, 18121, 787, 440, 288, 543, 13377, 14, 479, 63, 3536, 8, 1726, 304, 355, 22013, 8, 600, 14, 2030, 59, 16, 566, 953, 12509, 63, 3684, 275, 18200, 63, 5599, 63, 504, 63, 5038, 8, 600, 9, 288, 327, 3372, 314, 5090, 288, 1300, 63, 3684, 275, 6073, 14, 1122, 8, 604, 14, 1294, 26800, 5832, 17, 1055, 1913, 1062, 818, 534, 2579, 358, 288, 1437, 17, 275, 22013, 8, 29939, 63, 3684, 9, 288, 1437, 18, 275, 22013, 8, 1095, 63, 3684, 9, 288, 13377, 14, 479, 63, 1452, 8, 1474, 17, 12, 1437, 18, 9, 288, 13377, 14, 479, 63, 374, 63, 1397, 8, 1474, 17, 12, 1437, 18, 9, 288, 13377, 14, 479, 63, 835, 63, 1452, 8, 1474, 17, 14, 912, 63, 1247, 1062, 2248, 63, 1247, 59, 73, 566, 2378, 347, 511, 63, 4780, 63, 604, 8, 277, 304, 267, 408, 1316, 2915, 79, 3617, 883, 1454, 506, 2849, 1004, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 327, 3965, 1471, 506, 2849, 1004, 267, 543, 13377, 14, 479, 63, 3536, 8, 1726, 304, 288, 22013, 8, 600, 9, 398, 327, 2849, 1004, 5139, 5419, 267, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 22013, 8, 600, 14, 2030, 59, 17, 566, 339, 347, 511, 63, 5599, 63, 15083, 8, 277, 304, 267, 408, 267, 2002, 473, 6704, 440, 2948, 5, 3238, 641, 13806, 1006, 1233, 1901, 6073, 14, 4527, 6274, 14, 267, 20854, 3063, 652, 365, 4052, 473, 6704, 9689, 12, 880, 5594, 465, 5521, 7662, 511, 31, 267, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 17, 14, 600, 12, 6073, 14, 9093, 9, 267, 5348, 18, 275, 22013, 8, 600, 14, 2030, 59, 17, 566, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 18, 14, 600, 12, 6073, 14, 9093, 9, 398, 5348, 19, 275, 22013, 480, 1590, 14, 5605, 8, 1046, 6320, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 19, 14, 600, 12, 6073, 14, 9093, 9, 339, 347, 511, 63, 498, 8, 277, 304, 267, 408, 17830, 2631, 790, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 5348, 18, 275, 22013, 8, 600, 14, 2030, 59, 17, 566, 398, 492, 14755, 267, 327, 2896, 790, 370, 372, 620, 12, 2011, 2631, 2951, 3365, 1833, 267, 3211, 17, 275, 330, 936, 60, 3581, 60, 88, 17, 67, 60, 88, 16, 281, 60, 1845, 24, 75, 19, 60, 88, 1349, 60, 88, 2534, 50, 60, 88, 2905, 60, 88, 25, 65, 60, 1800, 20, 60, 1845, 16, 73, 7, 267, 3211, 17, 275, 14755, 14, 66, 18, 65, 63, 4097, 8, 4525, 17, 680, 2708, 360, 1624, 13, 24, 358, 267, 3211, 18, 275, 330, 1154, 2207, 22, 60, 88, 1299, 60, 88, 2036, 60, 1800, 18, 60, 2207, 16, 60, 88, 614, 60, 1800, 20, 60, 1812, 22, 60, 10097, 66, 60, 88, 17, 65, 52, 74, 60, 10489, 60, 88, 2905, 60, 88, 1085, 7, 267, 3211, 18, 275, 14755, 14, 66, 18, 65, 63, 4097, 8, 4525, 18, 680, 2708, 360, 1624, 13, 24, 358, 267, 327, 2883, 787, 17830, 436, 1077, 440, 1570, 3382, 15451, 23356, 267, 13377, 14, 479, 63, 1452, 8, 3684, 17, 14, 498, 12, 3211, 17, 9, 267, 13377, 14, 479, 63, 1452, 8, 3684, 18, 14, 498, 12, 3211, 18, 9, 398, 327, 790, 2597, 5419, 367, 18527, 267, 13377, 14, 479, 63, 1452, 8, 3684, 17, 12, 3211, 17, 9, 267, 13377, 14, 479, 63, 1452, 8, 3684, 18, 12, 3211, 18, 9, 339, 347, 511, 63, 1574, 8, 277, 304, 267, 408, 267, 511, 1331, 267, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 14 ]
[ 6073, 199, 504, 2882, 492, 7640, 199, 504, 13390, 492, 22622, 199, 199, 646, 10634, 465, 6454, 199, 646, 2680, 465, 980, 199, 504, 2680, 14, 4776, 492, 702, 63, 4398, 63, 1452, 199, 646, 11354, 14, 2537, 465, 13377, 199, 199, 504, 6073, 2537, 492, 334, 272, 6073, 63, 1452, 199, 9, 199, 199, 504, 2508, 6418, 492, 334, 272, 22013, 12, 272, 4688, 3944, 12, 272, 485, 6418, 199, 9, 199, 199, 504, 2508, 1628, 63, 1100, 492, 334, 272, 9470, 1692, 12, 272, 5800, 1692, 12, 272, 28573, 2998, 12, 272, 664, 63, 1365, 63, 498, 199, 9, 199, 199, 504, 1275, 2330, 492, 437, 1842, 2980, 199, 199, 318, 18200, 63, 5599, 63, 504, 63, 5038, 8, 600, 304, 272, 1031, 275, 1233, 14, 2030, 59, 16, 1055, 585, 272, 5348, 275, 6073, 14, 9093, 8, 3469, 29, 16, 12, 1048, 63, 2743, 29, 16, 12, 2396, 29, 932, 9, 272, 372, 5348, 199, 199, 533, 1379, 9093, 8, 1746, 304, 272, 347, 511, 63, 5599, 8, 277, 304, 267, 1350, 275, 408, 267, 7953, 275, 980, 14, 5605, 8, 1165, 9, 267, 522, 275, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 2385, 275, 1350, 14, 1913, 1252, 1294, 2258, 78, 358, 267, 2248, 63, 1247, 275, 11194, 1590, 995, 788, 1590, 297, 283, 5250, 6538, 267, 367, 284, 12, 1004, 315, 3874, 8, 1278, 304, 288, 1233, 275, 6073, 14, 1122, 8, 604, 12, 2650, 4206, 283, 1628, 358, 953, 327, 3965, 1471, 506, 8031, 461, 12, 18121, 787, 440, 288, 543, 13377, 14, 479, 63, 3536, 8, 1726, 304, 355, 22013, 8, 600, 14, 2030, 59, 16, 566, 953, 12509, 63, 3684, 275, 18200, 63, 5599, 63, 504, 63, 5038, 8, 600, 9, 288, 327, 3372, 314, 5090, 288, 1300, 63, 3684, 275, 6073, 14, 1122, 8, 604, 14, 1294, 26800, 5832, 17, 1055, 1913, 1062, 818, 534, 2579, 358, 288, 1437, 17, 275, 22013, 8, 29939, 63, 3684, 9, 288, 1437, 18, 275, 22013, 8, 1095, 63, 3684, 9, 288, 13377, 14, 479, 63, 1452, 8, 1474, 17, 12, 1437, 18, 9, 288, 13377, 14, 479, 63, 374, 63, 1397, 8, 1474, 17, 12, 1437, 18, 9, 288, 13377, 14, 479, 63, 835, 63, 1452, 8, 1474, 17, 14, 912, 63, 1247, 1062, 2248, 63, 1247, 59, 73, 566, 2378, 347, 511, 63, 4780, 63, 604, 8, 277, 304, 267, 408, 1316, 2915, 79, 3617, 883, 1454, 506, 2849, 1004, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 327, 3965, 1471, 506, 2849, 1004, 267, 543, 13377, 14, 479, 63, 3536, 8, 1726, 304, 288, 22013, 8, 600, 9, 398, 327, 2849, 1004, 5139, 5419, 267, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 22013, 8, 600, 14, 2030, 59, 17, 566, 339, 347, 511, 63, 5599, 63, 15083, 8, 277, 304, 267, 408, 267, 2002, 473, 6704, 440, 2948, 5, 3238, 641, 13806, 1006, 1233, 1901, 6073, 14, 4527, 6274, 14, 267, 20854, 3063, 652, 365, 4052, 473, 6704, 9689, 12, 880, 5594, 465, 5521, 7662, 511, 31, 267, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 17, 14, 600, 12, 6073, 14, 9093, 9, 267, 5348, 18, 275, 22013, 8, 600, 14, 2030, 59, 17, 566, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 18, 14, 600, 12, 6073, 14, 9093, 9, 398, 5348, 19, 275, 22013, 480, 1590, 14, 5605, 8, 1046, 6320, 267, 13377, 14, 479, 63, 374, 63, 842, 8, 3684, 19, 14, 600, 12, 6073, 14, 9093, 9, 339, 347, 511, 63, 498, 8, 277, 304, 267, 408, 17830, 2631, 790, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 980, 14, 1838, 8, 5250, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 14, 2030, 59, 16, 566, 267, 5348, 18, 275, 22013, 8, 600, 14, 2030, 59, 17, 566, 398, 492, 14755, 267, 327, 2896, 790, 370, 372, 620, 12, 2011, 2631, 2951, 3365, 1833, 267, 3211, 17, 275, 330, 936, 60, 3581, 60, 88, 17, 67, 60, 88, 16, 281, 60, 1845, 24, 75, 19, 60, 88, 1349, 60, 88, 2534, 50, 60, 88, 2905, 60, 88, 25, 65, 60, 1800, 20, 60, 1845, 16, 73, 7, 267, 3211, 17, 275, 14755, 14, 66, 18, 65, 63, 4097, 8, 4525, 17, 680, 2708, 360, 1624, 13, 24, 358, 267, 3211, 18, 275, 330, 1154, 2207, 22, 60, 88, 1299, 60, 88, 2036, 60, 1800, 18, 60, 2207, 16, 60, 88, 614, 60, 1800, 20, 60, 1812, 22, 60, 10097, 66, 60, 88, 17, 65, 52, 74, 60, 10489, 60, 88, 2905, 60, 88, 1085, 7, 267, 3211, 18, 275, 14755, 14, 66, 18, 65, 63, 4097, 8, 4525, 18, 680, 2708, 360, 1624, 13, 24, 358, 267, 327, 2883, 787, 17830, 436, 1077, 440, 1570, 3382, 15451, 23356, 267, 13377, 14, 479, 63, 1452, 8, 3684, 17, 14, 498, 12, 3211, 17, 9, 267, 13377, 14, 479, 63, 1452, 8, 3684, 18, 14, 498, 12, 3211, 18, 9, 398, 327, 790, 2597, 5419, 367, 18527, 267, 13377, 14, 479, 63, 1452, 8, 3684, 17, 12, 3211, 17, 9, 267, 13377, 14, 479, 63, 1452, 8, 3684, 18, 12, 3211, 18, 9, 339, 347, 511, 63, 1574, 8, 277, 304, 267, 408, 267, 511, 1331, 267, 408, 267, 1350, 275, 408, 267, 980, 14, 5605, 8, 1165, 9, 267, 408, 267, 1350, 275, 22622, 8, 1365, 9, 267, 1233, 275, 6073, 14, 1122, 8, 1365, 9, 398, 5348, 17, 275, 22013, 8, 600, 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, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
KrullBorg/MINGW-packages
mingw-w64-openvr/cxx_header_generator.py
20
3300
#! python3 import argparse import shlex import sys import os import re import io parser = argparse.ArgumentParser( prog='cxx_header_generator', description="Generate C++ header for openvr", epilog='Run cxx_header_generator.py --help for more information', allow_abbrev=False) parser.add_argument("--header-dir", "-d", dest="headdir", help="directory to openvr headers", required=True) args = parser.parse_args() input_path = args.headdir if not os.path.isdir(input_path): print('The path specified does not exist') sys.exit() cHeader = os.path.join(input_path, 'openvr.h') cppHeader = os.path.join(input_path, 'openvr_mingw.hpp') header = open(cHeader, newline='\n').read() annoyingMacroPattern = re.compile(r'#define\s+(\w+).*VR_CLANG_ATTR.*') fullClassPattern = re.compile(r'^([^\S\n]*)class\s+(\w+).*?\{.*?\};', re.MULTILINE | re.DOTALL) virtualPattern = re.compile(r'([^\S\n]*)virtual\s(.*?)(\w+)(\((.+?\s*(sizeof\s*\(\s*.*?\s*\)\s*)?,\s*)*.*?\s*(sizeof\s*\(\s*.*?\s*\)\s*)?\))\s*=\s*0\s*;[^\S\n]*', re.MULTILINE) optionalParamPattern = re.compile(r'\s*=\s*(sizeof\s*\(\s*.*?\s*\)\s*)?[^,)]+') versionPattern = re.compile(r'\s*static\s*const\s*char\s*\*\s*const\s*IVR\w+\s*=\s*\"IVR\w+\";') annoyingMacros = [match.group(1) for match in annoyingMacroPattern.finditer(header)] newHeader = header for match in versionPattern.finditer(newHeader): newHeader = newHeader.replace(match.group(0), match.group(0).replace('"IVR', '"FnTable:IVR')) for match in fullClassPattern.finditer(header): if match.group(0).find('virtual') == -1: continue fullClass = match.group(0) indent = match.group(1) className = match.group(2) newClass = fullClass declarations = [] for function in virtualPattern.finditer(fullClass): returnType = function.group(2) functionName = function.group(3) params = function.group(4) paramsNoDefault = re.sub(optionalParamPattern, '', params) for macro in annoyingMacros: paramsNoDefault = re.sub(macro + r'\(.*?\)', '', paramsNoDefault) args = [] paramTokens = list(shlex.shlex(io.StringIO(paramsNoDefault))) for i, token in enumerate(paramTokens): if token == ',' or (token == ')' and paramTokens[i - 1] not in ['(', 'void']): args.append(paramTokens[i - 1]) declaration = indent + '\t{}(__stdcall *{}){};'.format(returnType, functionName, paramsNoDefault) definition = indent + '\t' + returnType + functionName + params + ' { ' if returnType.strip() != 'void': definition = definition + 'return ' definition = definition + '_table.' + functionName + '(' + ', '.join(args) + '); }' declarations.append(declaration) newClass = newClass.replace(function.group(0), definition) tableName = 'VR_{}_FnTable'.format(className) table = indent + 'struct ' + tableName + '\n' + indent + '{\n' + '\n'.join(declarations) + '\n' + indent + '};\n\n' newClass = newClass.replace('public:', '\t{} _table;\n{}public:'.format(tableName, indent)) newHeader = newHeader.replace(fullClass, table + newClass) open(cppHeader, 'w', newline='\n').write(newHeader)
bsd-3-clause
[ 3168, 2366, 19, 199, 199, 646, 7534, 199, 646, 16701, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 646, 5890, 199, 199, 2087, 275, 7534, 14, 10730, 8, 355, 13205, 534, 9634, 63, 1291, 63, 4679, 297, 1369, 628, 6864, 445, 4176, 1406, 367, 1551, 10922, 401, 355, 29850, 534, 2540, 17327, 63, 1291, 63, 4679, 14, 647, 1553, 3437, 367, 1655, 2556, 297, 355, 2040, 63, 31349, 29, 797, 9, 199, 199, 2087, 14, 525, 63, 2094, 6739, 1291, 13, 694, 401, 3905, 68, 401, 2053, 628, 2993, 694, 401, 1720, 628, 3619, 370, 1551, 10922, 2323, 401, 1415, 29, 549, 9, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 1210, 63, 515, 275, 1249, 14, 2993, 694, 199, 199, 692, 440, 747, 14, 515, 14, 6027, 8, 1210, 63, 515, 304, 272, 870, 360, 1918, 931, 2013, 1630, 440, 2187, 358, 272, 984, 14, 2224, 342, 199, 199, 67, 2567, 275, 747, 14, 515, 14, 904, 8, 1210, 63, 515, 12, 283, 1490, 10922, 14, 72, 358, 199, 5910, 2567, 275, 747, 14, 515, 14, 904, 8, 1210, 63, 515, 12, 283, 1490, 10922, 63, 14566, 87, 14, 72, 802, 358, 199, 1291, 275, 1551, 8, 67, 2567, 12, 8057, 17115, 78, 1959, 739, 342, 199, 199, 25264, 22440, 24673, 9959, 275, 295, 14, 2014, 8, 82, 11525, 4640, 60, 83, 20900, 87, 11, 680, 10, 20271, 63, 1981, 3986, 63, 5280, 24915, 199, 2861, 2543, 9959, 275, 295, 14, 2014, 8, 82, 4289, 21690, 51, 60, 78, 23849, 533, 60, 83, 20900, 87, 11, 680, 10, 8995, 91, 21040, 93, 10805, 295, 14, 16661, 1204, 295, 14, 16504, 9, 199, 2065, 9959, 275, 295, 14, 2014, 8, 82, 7, 21690, 51, 60, 78, 23849, 2065, 60, 83, 17140, 10127, 87, 27860, 1332, 6977, 8995, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 4202, 83, 10, 3342, 21040, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 60, 25105, 83, 23440, 83, 10, 16, 60, 83, 10, 27, 16045, 51, 60, 78, 22952, 295, 14, 16661, 9, 199, 4144, 4098, 9959, 275, 295, 14, 2014, 8, 82, 1154, 83, 23440, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 4735, 12, 1874, 13854, 199, 1023, 9959, 275, 295, 14, 2014, 8, 82, 1154, 83, 10, 1986, 60, 83, 10, 1297, 60, 83, 10, 1560, 60, 83, 7590, 7590, 83, 10, 1297, 60, 83, 10, 6882, 50, 60, 87, 7896, 83, 23440, 83, 10, 4451, 6882, 50, 60, 87, 11, 4451, 10784, 199, 199, 25264, 22440, 25402, 275, 359, 1431, 14, 923, 8, 17, 9, 367, 1336, 315, 22984, 22440, 24673, 9959, 14, 19373, 8, 1291, 1874, 199, 199, 1222, 2567, 275, 1406, 199, 509, 1336, 315, 1015, 9959, 14, 19373, 8, 1222, 2567, 304, 272, 892, 2567, 275, 892, 2567, 14, 1814, 8, 1431, 14, 923, 8, 16, 395, 1336, 14, 923, 8, 16, 680, 1814, 14088, 6882, 50, 297, 5522, 9656, 3186, 26, 6882, 50, 1333, 199, 199, 509, 1336, 315, 2615, 2543, 9959, 14, 19373, 8, 1291, 304, 272, 340, 1336, 14, 923, 8, 16, 680, 1623, 360, 2065, 358, 508, 446, 17, 26, 267, 1980, 272, 2615, 2543, 275, 1336, 14, 923, 8, 16, 9, 272, 4363, 275, 1336, 14, 923, 8, 17, 9, 272, 1021, 985, 275, 1336, 14, 923, 8, 18, 9, 2286, 892, 2543, 275, 2615, 2543, 2286, 18707, 275, 942, 272, 367, 805, 315, 5791, 9959, 14, 19373, 8, 2861, 2543, 304, 267, 372, 804, 275, 805, 14, 923, 8, 18, 9, 267, 805, 985, 275, 805, 14, 923, 8, 19, 9, 267, 1862, 275, 805, 14, 923, 8, 20, 9, 267, 1862, 1944, 2698, 275, 295, 14, 954, 8, 4144, 4098, 9959, 12, 3260, 1862, 9, 267, 367, 9559, 315, 22984, 22440, 25402, 26, 288, 1862, 1944, 2698, 275, 295, 14, 954, 8, 11300, 435, 519, 1154, 17140, 60, 3196, 3260, 1862, 1944, 2698, 9, 2728, 1249, 275, 942, 267, 1215, 16419, 275, 769, 8, 32507, 14, 32507, 8, 2308, 14, 6424, 8, 1162, 1944, 2698, 1724, 267, 367, 284, 12, 1526, 315, 3874, 8, 635, 16419, 304, 288, 340, 1526, 508, 13647, 503, 334, 1418, 508, 16107, 436, 1215, 16419, 59, 73, 446, 413, 61, 440, 315, 788, 5102, 283, 1647, 9090, 355, 1249, 14, 740, 8, 635, 16419, 59, 73, 446, 413, 566, 2728, 12560, 275, 4363, 435, 1557, 84, 2440, 3460, 1516, 1250, 627, 91, 1552, 2440, 27, 1370, 908, 8, 1107, 804, 12, 805, 985, 12, 1862, 1944, 2698, 9, 267, 5492, 275, 4363, 435, 1557, 84, 7, 435, 372, 804, 435, 805, 985, 435, 1862, 435, 283, 469, 283, 267, 340, 372, 804, 14, 1913, 342, 1137, 283, 1647, 356, 288, 5492, 275, 5492, 435, 283, 1107, 283, 267, 5492, 275, 5492, 435, 2513, 1224, 3530, 435, 805, 985, 435, 16746, 435, 1656, 1987, 904, 8, 589, 9, 435, 283, 2736, 789, 7, 2728, 18707, 14, 740, 8, 15477, 9, 267, 892, 2543, 275, 892, 2543, 14, 1814, 8, 1593, 14, 923, 8, 16, 395, 5492, 9, 5493, 32652, 275, 283, 20271, 24306, 63, 9656, 3186, 1370, 908, 8, 533, 985, 9, 272, 1817, 275, 4363, 435, 283, 1820, 283, 435, 32652, 435, 1557, 78, 7, 435, 4363, 435, 5041, 60, 78, 7, 435, 1557, 78, 1370, 904, 8, 21200, 9, 435, 1557, 78, 7, 435, 4363, 435, 283, 16055, 78, 60, 78, 7, 2286, 892, 2543, 275, 892, 2543, 14, 1814, 360, 3455, 6536, 1557, 84, 2440, 485, 1224, 3779, 78, 2440, 3455, 26, 1370, 908, 8, 1224, 985, 12, 4363, 430, 2286, 892, 2567, 275, 892, 2567, 14, 1814, 8, 2861, 2543, 12, 1817, 435, 892, 2543, 9, 199, 199, 1490, 8, 5910, 2567, 12, 283, 87, 297, 8057, 17115, 78, 1959, 952, 8, 1222, 2567, 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 ]
[ 2366, 19, 199, 199, 646, 7534, 199, 646, 16701, 199, 646, 984, 199, 646, 747, 199, 646, 295, 199, 646, 5890, 199, 199, 2087, 275, 7534, 14, 10730, 8, 355, 13205, 534, 9634, 63, 1291, 63, 4679, 297, 1369, 628, 6864, 445, 4176, 1406, 367, 1551, 10922, 401, 355, 29850, 534, 2540, 17327, 63, 1291, 63, 4679, 14, 647, 1553, 3437, 367, 1655, 2556, 297, 355, 2040, 63, 31349, 29, 797, 9, 199, 199, 2087, 14, 525, 63, 2094, 6739, 1291, 13, 694, 401, 3905, 68, 401, 2053, 628, 2993, 694, 401, 1720, 628, 3619, 370, 1551, 10922, 2323, 401, 1415, 29, 549, 9, 199, 589, 275, 1798, 14, 1122, 63, 589, 342, 199, 199, 1210, 63, 515, 275, 1249, 14, 2993, 694, 199, 199, 692, 440, 747, 14, 515, 14, 6027, 8, 1210, 63, 515, 304, 272, 870, 360, 1918, 931, 2013, 1630, 440, 2187, 358, 272, 984, 14, 2224, 342, 199, 199, 67, 2567, 275, 747, 14, 515, 14, 904, 8, 1210, 63, 515, 12, 283, 1490, 10922, 14, 72, 358, 199, 5910, 2567, 275, 747, 14, 515, 14, 904, 8, 1210, 63, 515, 12, 283, 1490, 10922, 63, 14566, 87, 14, 72, 802, 358, 199, 1291, 275, 1551, 8, 67, 2567, 12, 8057, 17115, 78, 1959, 739, 342, 199, 199, 25264, 22440, 24673, 9959, 275, 295, 14, 2014, 8, 82, 11525, 4640, 60, 83, 20900, 87, 11, 680, 10, 20271, 63, 1981, 3986, 63, 5280, 24915, 199, 2861, 2543, 9959, 275, 295, 14, 2014, 8, 82, 4289, 21690, 51, 60, 78, 23849, 533, 60, 83, 20900, 87, 11, 680, 10, 8995, 91, 21040, 93, 10805, 295, 14, 16661, 1204, 295, 14, 16504, 9, 199, 2065, 9959, 275, 295, 14, 2014, 8, 82, 7, 21690, 51, 60, 78, 23849, 2065, 60, 83, 17140, 10127, 87, 27860, 1332, 6977, 8995, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 4202, 83, 10, 3342, 21040, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 60, 25105, 83, 23440, 83, 10, 16, 60, 83, 10, 27, 16045, 51, 60, 78, 22952, 295, 14, 16661, 9, 199, 4144, 4098, 9959, 275, 295, 14, 2014, 8, 82, 1154, 83, 23440, 83, 5830, 12590, 60, 83, 7590, 2961, 83, 10, 21040, 83, 7590, 2862, 83, 10, 5547, 4735, 12, 1874, 13854, 199, 1023, 9959, 275, 295, 14, 2014, 8, 82, 1154, 83, 10, 1986, 60, 83, 10, 1297, 60, 83, 10, 1560, 60, 83, 7590, 7590, 83, 10, 1297, 60, 83, 10, 6882, 50, 60, 87, 7896, 83, 23440, 83, 10, 4451, 6882, 50, 60, 87, 11, 4451, 10784, 199, 199, 25264, 22440, 25402, 275, 359, 1431, 14, 923, 8, 17, 9, 367, 1336, 315, 22984, 22440, 24673, 9959, 14, 19373, 8, 1291, 1874, 199, 199, 1222, 2567, 275, 1406, 199, 509, 1336, 315, 1015, 9959, 14, 19373, 8, 1222, 2567, 304, 272, 892, 2567, 275, 892, 2567, 14, 1814, 8, 1431, 14, 923, 8, 16, 395, 1336, 14, 923, 8, 16, 680, 1814, 14088, 6882, 50, 297, 5522, 9656, 3186, 26, 6882, 50, 1333, 199, 199, 509, 1336, 315, 2615, 2543, 9959, 14, 19373, 8, 1291, 304, 272, 340, 1336, 14, 923, 8, 16, 680, 1623, 360, 2065, 358, 508, 446, 17, 26, 267, 1980, 272, 2615, 2543, 275, 1336, 14, 923, 8, 16, 9, 272, 4363, 275, 1336, 14, 923, 8, 17, 9, 272, 1021, 985, 275, 1336, 14, 923, 8, 18, 9, 2286, 892, 2543, 275, 2615, 2543, 2286, 18707, 275, 942, 272, 367, 805, 315, 5791, 9959, 14, 19373, 8, 2861, 2543, 304, 267, 372, 804, 275, 805, 14, 923, 8, 18, 9, 267, 805, 985, 275, 805, 14, 923, 8, 19, 9, 267, 1862, 275, 805, 14, 923, 8, 20, 9, 267, 1862, 1944, 2698, 275, 295, 14, 954, 8, 4144, 4098, 9959, 12, 3260, 1862, 9, 267, 367, 9559, 315, 22984, 22440, 25402, 26, 288, 1862, 1944, 2698, 275, 295, 14, 954, 8, 11300, 435, 519, 1154, 17140, 60, 3196, 3260, 1862, 1944, 2698, 9, 2728, 1249, 275, 942, 267, 1215, 16419, 275, 769, 8, 32507, 14, 32507, 8, 2308, 14, 6424, 8, 1162, 1944, 2698, 1724, 267, 367, 284, 12, 1526, 315, 3874, 8, 635, 16419, 304, 288, 340, 1526, 508, 13647, 503, 334, 1418, 508, 16107, 436, 1215, 16419, 59, 73, 446, 413, 61, 440, 315, 788, 5102, 283, 1647, 9090, 355, 1249, 14, 740, 8, 635, 16419, 59, 73, 446, 413, 566, 2728, 12560, 275, 4363, 435, 1557, 84, 2440, 3460, 1516, 1250, 627, 91, 1552, 2440, 27, 1370, 908, 8, 1107, 804, 12, 805, 985, 12, 1862, 1944, 2698, 9, 267, 5492, 275, 4363, 435, 1557, 84, 7, 435, 372, 804, 435, 805, 985, 435, 1862, 435, 283, 469, 283, 267, 340, 372, 804, 14, 1913, 342, 1137, 283, 1647, 356, 288, 5492, 275, 5492, 435, 283, 1107, 283, 267, 5492, 275, 5492, 435, 2513, 1224, 3530, 435, 805, 985, 435, 16746, 435, 1656, 1987, 904, 8, 589, 9, 435, 283, 2736, 789, 7, 2728, 18707, 14, 740, 8, 15477, 9, 267, 892, 2543, 275, 892, 2543, 14, 1814, 8, 1593, 14, 923, 8, 16, 395, 5492, 9, 5493, 32652, 275, 283, 20271, 24306, 63, 9656, 3186, 1370, 908, 8, 533, 985, 9, 272, 1817, 275, 4363, 435, 283, 1820, 283, 435, 32652, 435, 1557, 78, 7, 435, 4363, 435, 5041, 60, 78, 7, 435, 1557, 78, 1370, 904, 8, 21200, 9, 435, 1557, 78, 7, 435, 4363, 435, 283, 16055, 78, 60, 78, 7, 2286, 892, 2543, 275, 892, 2543, 14, 1814, 360, 3455, 6536, 1557, 84, 2440, 485, 1224, 3779, 78, 2440, 3455, 26, 1370, 908, 8, 1224, 985, 12, 4363, 430, 2286, 892, 2567, 275, 892, 2567, 14, 1814, 8, 2861, 2543, 12, 1817, 435, 892, 2543, 9, 199, 199, 1490, 8, 5910, 2567, 12, 283, 87, 297, 8057, 17115, 78, 1959, 952, 8, 1222, 2567, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
hazzl/chirpy
sqlistmodel.py
1
2229
from PyQt5.QtCore import QAbstractListModel, Qt, QModelIndex import sqlite3 class sqlistmodel(QAbstractListModel): def __init__(self, conn): super().__init__() self._conn = conn self._data = [(0, '')] self._rolesindex = { Qt.DisplayRole: 1, Qt.UserRole: 0} def printData(self): print(self._data) def updateData(self, query): q = self._conn.cursor() q.execute(query) self.beginResetModel() self._data = q.fetchall() self.endResetModel() def rowCount(self, parent=QModelIndex()): return len(self._data) def data(self, index, role): if not index.isValid(): return None if index.row() >= len(self._data): return None if role in self._rolesindex.keys(): return self._data[index.row()][self._rolesindex[role]] else: return None def roleNames(self): return {Qt.DisplayRole: b"name", Qt.UserRole: b"uid"} class albumlistmodel(sqlistmodel): def __init__(self, conn): QAbstractListModel.__init__(self) self._conn = conn self._data = [(0, '', '')] self._rolesindex = { Qt.DisplayRole: 1, Qt.UserRole: 0, Qt.UserRole+1: 2} def roleNames(self): return {Qt.DisplayRole: b"name", Qt.UserRole: b"uid", Qt.UserRole+1: b"category"} class playlistmodel(sqlistmodel): def __init__(self, conn): QAbstractListModel.__init__(self) self._conn = conn self._data = [('', '', 0)] self._rolesindex = { Qt.DisplayRole: 0, Qt.UserRole: 1, Qt.UserRole+1: 2} def roleNames(self): return {Qt.DisplayRole: b"name", Qt.UserRole: b"url", Qt.UserRole+1: b"uid"} def recordPlayed(self, uid): q = self._conn.cursor() q.execute('SELECT timesplayed,album FROM songs WHERE id=?', (uid,)) times,album = q.fetchone() if times is None: times = 0 q.execute("""UPDATE songs SET lastplayed=strftime('%s','now'), timesplayed=? WHERE id=?""",(times+1,uid)) q.execute("""UPDATE albums SET lastplayed=strftime('%s','now') WHERE id=?""",(album,)) self._conn.commit() def recordSkipped(self, uid): q = self._conn.cursor() q.execute('SELECT timesskipped FROM songs WHERE id=?', (uid,)) times = q.fetchone()[0] if times is None: times = 0 q.execute("UPDATE songs SET timesskipped=? WHERE id=?",(times+1,uid)) self._conn.commit()
gpl-3.0
[ 504, 14084, 21, 14, 10901, 492, 1413, 8458, 1296, 1685, 12, 3959, 12, 1413, 1685, 2681, 199, 646, 11723, 19, 199, 199, 533, 5295, 513, 1238, 8, 49, 8458, 1296, 1685, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 4792, 11027, 826, 4533, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 3842, 16, 12, 4074, 61, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 413, 12, 20866, 198, 4238, 14, 1899, 7422, 26, 378, 93, 199, 198, 318, 870, 1451, 8, 277, 304, 507, 198, 1361, 8, 277, 423, 576, 9, 199, 198, 318, 1678, 1451, 8, 277, 12, 1827, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 8, 1131, 9, 507, 198, 277, 14, 5037, 9637, 1685, 342, 507, 198, 277, 423, 576, 275, 1894, 14, 10174, 342, 507, 198, 277, 14, 500, 9637, 1685, 342, 199, 198, 318, 1962, 2353, 8, 277, 12, 1676, 29, 49, 1685, 2681, 5109, 507, 198, 1107, 822, 8, 277, 423, 576, 9, 199, 198, 318, 666, 8, 277, 12, 1478, 12, 4719, 304, 507, 198, 692, 440, 1478, 14, 18728, 837, 686, 198, 1107, 488, 507, 198, 692, 1478, 14, 1143, 342, 2356, 822, 8, 277, 423, 576, 304, 686, 198, 1107, 488, 507, 198, 692, 4719, 315, 291, 423, 8050, 1080, 14, 1612, 837, 686, 198, 1107, 291, 423, 576, 59, 1080, 14, 1143, 342, 1527, 277, 423, 8050, 1080, 59, 3756, 2677, 507, 198, 2836, 26, 686, 198, 1107, 488, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 1535, 3570, 199, 533, 16379, 513, 1238, 8, 3526, 513, 1238, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 49, 8458, 1296, 1685, 855, 826, 721, 277, 9, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 3842, 16, 12, 3260, 4074, 61, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 413, 12, 686, 198, 4238, 14, 1899, 7422, 26, 378, 12, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 499, 93, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 1535, 401, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 330, 2, 3710, 3570, 199, 533, 13210, 1238, 8, 3526, 513, 1238, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 49, 8458, 1296, 1685, 855, 826, 721, 277, 9, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 4274, 297, 3260, 378, 1874, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 378, 12, 20866, 198, 4238, 14, 1899, 7422, 26, 413, 12, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 499, 93, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 633, 401, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 330, 2, 1535, 3570, 199, 198, 318, 2777, 9651, 379, 8, 277, 12, 1747, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 360, 4859, 900, 1836, 379, 12, 12110, 4442, 308, 12358, 6038, 1305, 29, 7044, 334, 1535, 4641, 507, 198, 4508, 12, 12110, 275, 1894, 14, 11591, 342, 507, 198, 692, 5431, 365, 488, 26, 686, 198, 4508, 275, 378, 507, 198, 81, 14, 2526, 4852, 10383, 308, 12358, 11543, 2061, 2802, 379, 29, 6205, 3508, 83, 1673, 2131, 659, 686, 198, 521, 1836, 379, 18048, 6038, 1305, 18048, 7208, 8, 4508, 11, 17, 12, 1535, 430, 507, 198, 81, 14, 2526, 4852, 10383, 16379, 83, 11543, 2061, 2802, 379, 29, 6205, 3508, 83, 1673, 2131, 358, 686, 198, 17688, 1305, 18048, 7208, 8, 12110, 4641, 507, 198, 277, 423, 1631, 14, 3543, 342, 199, 198, 318, 2777, 30472, 8, 277, 12, 1747, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 360, 4859, 900, 385, 5194, 1915, 4442, 308, 12358, 6038, 1305, 29, 7044, 334, 1535, 4641, 507, 198, 4508, 275, 1894, 14, 11591, 3430, 16, 61, 507, 198, 692, 5431, 365, 488, 26, 686, 198, 4508, 275, 378, 507, 198, 81, 14, 2526, 480, 10383, 308, 12358, 11543, 900, 385, 5194, 1915, 18048, 6038, 1305, 29, 15583, 8, 4508, 11, 17, 12, 1535, 430, 507, 198, 277, 423, 1631, 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 ]
[ 14084, 21, 14, 10901, 492, 1413, 8458, 1296, 1685, 12, 3959, 12, 1413, 1685, 2681, 199, 646, 11723, 19, 199, 199, 533, 5295, 513, 1238, 8, 49, 8458, 1296, 1685, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 4792, 11027, 826, 4533, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 3842, 16, 12, 4074, 61, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 413, 12, 20866, 198, 4238, 14, 1899, 7422, 26, 378, 93, 199, 198, 318, 870, 1451, 8, 277, 304, 507, 198, 1361, 8, 277, 423, 576, 9, 199, 198, 318, 1678, 1451, 8, 277, 12, 1827, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 8, 1131, 9, 507, 198, 277, 14, 5037, 9637, 1685, 342, 507, 198, 277, 423, 576, 275, 1894, 14, 10174, 342, 507, 198, 277, 14, 500, 9637, 1685, 342, 199, 198, 318, 1962, 2353, 8, 277, 12, 1676, 29, 49, 1685, 2681, 5109, 507, 198, 1107, 822, 8, 277, 423, 576, 9, 199, 198, 318, 666, 8, 277, 12, 1478, 12, 4719, 304, 507, 198, 692, 440, 1478, 14, 18728, 837, 686, 198, 1107, 488, 507, 198, 692, 1478, 14, 1143, 342, 2356, 822, 8, 277, 423, 576, 304, 686, 198, 1107, 488, 507, 198, 692, 4719, 315, 291, 423, 8050, 1080, 14, 1612, 837, 686, 198, 1107, 291, 423, 576, 59, 1080, 14, 1143, 342, 1527, 277, 423, 8050, 1080, 59, 3756, 2677, 507, 198, 2836, 26, 686, 198, 1107, 488, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 1535, 3570, 199, 533, 16379, 513, 1238, 8, 3526, 513, 1238, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 49, 8458, 1296, 1685, 855, 826, 721, 277, 9, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 3842, 16, 12, 3260, 4074, 61, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 413, 12, 686, 198, 4238, 14, 1899, 7422, 26, 378, 12, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 499, 93, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 1535, 401, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 330, 2, 3710, 3570, 199, 533, 13210, 1238, 8, 3526, 513, 1238, 304, 199, 198, 318, 636, 826, 721, 277, 12, 2557, 304, 507, 198, 49, 8458, 1296, 1685, 855, 826, 721, 277, 9, 507, 198, 277, 423, 1631, 275, 2557, 507, 198, 277, 423, 576, 275, 4274, 297, 3260, 378, 1874, 507, 198, 277, 423, 8050, 1080, 275, 469, 686, 198, 4238, 14, 7687, 7422, 26, 378, 12, 20866, 198, 4238, 14, 1899, 7422, 26, 413, 12, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 499, 93, 199, 198, 318, 4719, 5866, 8, 277, 304, 507, 198, 1107, 469, 4238, 14, 7687, 7422, 26, 330, 2, 354, 401, 686, 198, 4238, 14, 1899, 7422, 26, 330, 2, 633, 401, 686, 198, 4238, 14, 1899, 7422, 11, 17, 26, 330, 2, 1535, 3570, 199, 198, 318, 2777, 9651, 379, 8, 277, 12, 1747, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 360, 4859, 900, 1836, 379, 12, 12110, 4442, 308, 12358, 6038, 1305, 29, 7044, 334, 1535, 4641, 507, 198, 4508, 12, 12110, 275, 1894, 14, 11591, 342, 507, 198, 692, 5431, 365, 488, 26, 686, 198, 4508, 275, 378, 507, 198, 81, 14, 2526, 4852, 10383, 308, 12358, 11543, 2061, 2802, 379, 29, 6205, 3508, 83, 1673, 2131, 659, 686, 198, 521, 1836, 379, 18048, 6038, 1305, 18048, 7208, 8, 4508, 11, 17, 12, 1535, 430, 507, 198, 81, 14, 2526, 4852, 10383, 16379, 83, 11543, 2061, 2802, 379, 29, 6205, 3508, 83, 1673, 2131, 358, 686, 198, 17688, 1305, 18048, 7208, 8, 12110, 4641, 507, 198, 277, 423, 1631, 14, 3543, 342, 199, 198, 318, 2777, 30472, 8, 277, 12, 1747, 304, 507, 198, 81, 275, 291, 423, 1631, 14, 3937, 342, 507, 198, 81, 14, 2526, 360, 4859, 900, 385, 5194, 1915, 4442, 308, 12358, 6038, 1305, 29, 7044, 334, 1535, 4641, 507, 198, 4508, 275, 1894, 14, 11591, 3430, 16, 61, 507, 198, 692, 5431, 365, 488, 26, 686, 198, 4508, 275, 378, 507, 198, 81, 14, 2526, 480, 10383, 308, 12358, 11543, 900, 385, 5194, 1915, 18048, 6038, 1305, 29, 15583, 8, 4508, 11, 17, 12, 1535, 430, 507, 198, 277, 423, 1631, 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, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
linuxipho/mycroft-core
test/unittests/util/test_parse_sv.py
1
5775
# -*- coding: utf-8 -*- # # Copyright 2017 Mycroft AI 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. # import unittest from datetime import datetime, time from mycroft.util.parse import extract_datetime from mycroft.util.parse import extract_number from mycroft.util.parse import normalize class TestNormalize(unittest.TestCase): def test_extractnumber_sv(self): self.assertEqual(extract_number("1 och en halv deciliter", lang='sv-se'), 1.5) self.assertEqual(extract_number("det här är det första testet", lang='sv-se'), 1) self.assertEqual(extract_number("det här är test nummer 2", lang='sv-se'), 2) self.assertEqual(extract_number("det här är det andra testet", lang='sv-se'), 2) self.assertEqual(extract_number("det här är tredje testet", lang='sv-se'), 3) self.assertEqual(extract_number("det här är test nummer 4", lang='sv-se'), 4) self.assertEqual(extract_number("en tredjedels dl", lang='sv-se'), 1.0 / 3.0) self.assertEqual(extract_number("tre deciliter", lang='sv-se'), 3) self.assertEqual(extract_number("1/3 deciliter", lang='sv-se'), 1.0 / 3.0) self.assertEqual(extract_number("en kvarts dl", lang='sv-se'), 0.25) self.assertEqual(extract_number("1/4 dl", lang='sv-se'), 0.25) self.assertEqual(extract_number("en kvarts dl", lang='sv-se'), 0.25) self.assertEqual(extract_number("2/3 dl", lang='sv-se'), 2.0 / 3.0) self.assertEqual(extract_number("3/4 dl", lang='sv-se'), 3.0 / 4.0) self.assertEqual(extract_number("1 och 3/4 dl", lang='sv-se'), 1.75) self.assertEqual(extract_number("tre fjärdedels dl", lang='sv-se'), 3.0 / 4.0) self.assertEqual(extract_number("trekvarts kopp", lang='sv-se'), 3.0 / 4.0) def test_extractdatetime_sv(self): def extractWithFormat(text): date = datetime(2017, 6, 27, 0, 0) [extractedDate, leftover] = extract_datetime(text, date, lang='sv-se') extractedDate = extractedDate.strftime("%Y-%m-%d %H:%M:%S") return [extractedDate, leftover] def testExtract(text, expected_date, expected_leftover): res = extractWithFormat(text) self.assertEqual(res[0], expected_date) self.assertEqual(res[1], expected_leftover) testExtract("Planera bakhållet 5 dagar från nu", "2017-07-02 00:00:00", "planera bakhållet") testExtract("Vad blir vädret i övermorgon?", "2017-06-29 00:00:00", "vad blir vädret") testExtract("Påminn mig klockan 10:45", "2017-06-27 10:45:00", "påminn mig klockan") testExtract("vad blir vädret på fredag morgon", "2017-06-30 08:00:00", "vad blir vädret") testExtract("vad blir morgondagens väder", "2017-06-28 00:00:00", "vad blir väder") testExtract("påminn mig att ringa mamma om 8 veckor och 2 dagar", "2017-08-24 00:00:00", "påminn mig att ringa mamma om och") testExtract("Spela Kurt Olssons musik 2 dagar från Fredag", "2017-07-02 00:00:00", "spela kurt olssons musik") testExtract("vi möts 20:00", "2017-06-27 20:00:00", "vi möts") def test_extractdatetime_default_sv(self): default = time(9, 0, 0) anchor = datetime(2017, 6, 27, 0, 0) res = extract_datetime('påminn mig att klippa mig på fredag', anchor, lang='sv-se', default_time=default) self.assertEqual(default, res[0].time()) def test_numbers(self): self.assertEqual(normalize("det här är ett ett två tre test", lang='sv-se'), "det här är 1 1 2 3 test") self.assertEqual(normalize(" det är fyra fem sex test", lang='sv-se'), "det är 4 5 6 test") self.assertEqual(normalize("det är sju åtta nio test", lang='sv-se'), "det är 7 8 9 test") self.assertEqual(normalize("det är tio elva tolv test", lang='sv-se'), "det är 10 11 12 test") self.assertEqual(normalize("det är arton nitton tjugo test", lang='sv-se'), "det är 18 19 20 test") if __name__ == "__main__": unittest.main()
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 9708, 4932, 67, 293, 856, 437, 41, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 2882, 199, 504, 2197, 492, 2197, 12, 900, 199, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 5536, 63, 2083, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 5536, 63, 1955, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 7666, 421, 199, 533, 1379, 22580, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 5005, 1955, 63, 2772, 8, 277, 304, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 312, 335, 655, 22939, 86, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 21, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 20894, 289, 14614, 82, 1207, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 511, 1967, 2626, 499, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 20894, 436, 345, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 307, 581, 6532, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 511, 1967, 2626, 841, 401, 3147, 6339, 534, 2772, 13, 261, 659, 841, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 307, 581, 6532, 271, 478, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 15, 19, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 16616, 32611, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 16616, 32611, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18, 15, 19, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 19, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 312, 335, 650, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 2194, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 289, 74, 13733, 82, 271, 271, 478, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 11475, 32611, 1022, 26740, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 339, 347, 511, 63, 5005, 2083, 63, 2772, 8, 277, 304, 267, 347, 5536, 3007, 3484, 8, 505, 304, 288, 1434, 275, 2197, 8, 10680, 12, 1227, 12, 8087, 12, 378, 12, 378, 9, 288, 359, 29939, 2506, 12, 32196, 61, 275, 5536, 63, 2083, 8, 505, 12, 1434, 12, 12740, 6339, 534, 2772, 13, 261, 358, 288, 12509, 2506, 275, 12509, 2506, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 288, 372, 359, 29939, 2506, 12, 32196, 61, 398, 347, 511, 12147, 8, 505, 12, 1420, 63, 602, 12, 1420, 63, 21491, 25084, 304, 288, 522, 275, 5536, 3007, 3484, 8, 505, 9, 288, 291, 14, 629, 8, 470, 59, 16, 467, 1420, 63, 602, 9, 288, 291, 14, 629, 8, 470, 59, 17, 467, 1420, 63, 21491, 25084, 9, 398, 511, 12147, 480, 13375, 32311, 330, 1151, 72, 30234, 76, 2723, 959, 10158, 285, 9513, 30234, 78, 15699, 401, 490, 298, 10680, 13, 1780, 13, 996, 8733, 26, 383, 26, 383, 401, 298, 5140, 32311, 330, 1151, 72, 30234, 76, 2723, 531, 267, 511, 12147, 480, 54, 350, 330, 317, 82, 373, 13733, 68, 3292, 284, 13333, 115, 422, 77, 1308, 265, 15583, 490, 298, 10680, 13, 1690, 13, 1398, 8733, 26, 383, 26, 383, 401, 298, 86, 350, 330, 317, 82, 373, 13733, 68, 3292, 531, 267, 511, 12147, 480, 48, 30234, 827, 78, 3952, 1022, 831, 290, 1616, 26, 2322, 401, 490, 298, 10680, 13, 1690, 13, 1465, 1616, 26, 2322, 26, 383, 401, 298, 80, 30234, 827, 78, 3952, 1022, 831, 290, 531, 267, 511, 12147, 480, 86, 350, 330, 317, 82, 373, 13733, 68, 3292, 299, 30234, 289, 581, 643, 333, 1308, 265, 401, 490, 298, 10680, 13, 1690, 13, 1216, 19363, 26, 383, 26, 383, 401, 298 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 9708, 4932, 67, 293, 856, 437, 41, 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, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 646, 2882, 199, 504, 2197, 492, 2197, 12, 900, 199, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 5536, 63, 2083, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 5536, 63, 1955, 199, 504, 3002, 67, 293, 856, 14, 1974, 14, 1122, 492, 7666, 421, 199, 533, 1379, 22580, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 5005, 1955, 63, 2772, 8, 277, 304, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 312, 335, 655, 22939, 86, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 21, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 20894, 289, 14614, 82, 1207, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 511, 1967, 2626, 499, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 20894, 436, 345, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 307, 581, 6532, 221, 744, 10288, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 9886, 394, 13733, 82, 13333, 98, 82, 511, 1967, 2626, 841, 401, 3147, 6339, 534, 2772, 13, 261, 659, 841, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 307, 581, 6532, 271, 478, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 15, 19, 12985, 4544, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 16616, 32611, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 287, 16616, 32611, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 378, 14, 821, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18, 15, 19, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 499, 14, 16, 1182, 650, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 19, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 17, 312, 335, 650, 15, 20, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 413, 14, 2194, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 289, 74, 13733, 82, 271, 271, 478, 15396, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 267, 291, 14, 629, 8, 5005, 63, 1955, 480, 18468, 11475, 32611, 1022, 26740, 401, 3147, 6339, 534, 2772, 13, 261, 659, 650, 14, 16, 1182, 841, 14, 16, 9, 339, 347, 511, 63, 5005, 2083, 63, 2772, 8, 277, 304, 267, 347, 5536, 3007, 3484, 8, 505, 304, 288, 1434, 275, 2197, 8, 10680, 12, 1227, 12, 8087, 12, 378, 12, 378, 9, 288, 359, 29939, 2506, 12, 32196, 61, 275, 5536, 63, 2083, 8, 505, 12, 1434, 12, 12740, 6339, 534, 2772, 13, 261, 358, 288, 12509, 2506, 275, 12509, 2506, 14, 6205, 3647, 57, 3295, 77, 3295, 68, 450, 40, 2689, 45, 2689, 51, 531, 288, 372, 359, 29939, 2506, 12, 32196, 61, 398, 347, 511, 12147, 8, 505, 12, 1420, 63, 602, 12, 1420, 63, 21491, 25084, 304, 288, 522, 275, 5536, 3007, 3484, 8, 505, 9, 288, 291, 14, 629, 8, 470, 59, 16, 467, 1420, 63, 602, 9, 288, 291, 14, 629, 8, 470, 59, 17, 467, 1420, 63, 21491, 25084, 9, 398, 511, 12147, 480, 13375, 32311, 330, 1151, 72, 30234, 76, 2723, 959, 10158, 285, 9513, 30234, 78, 15699, 401, 490, 298, 10680, 13, 1780, 13, 996, 8733, 26, 383, 26, 383, 401, 298, 5140, 32311, 330, 1151, 72, 30234, 76, 2723, 531, 267, 511, 12147, 480, 54, 350, 330, 317, 82, 373, 13733, 68, 3292, 284, 13333, 115, 422, 77, 1308, 265, 15583, 490, 298, 10680, 13, 1690, 13, 1398, 8733, 26, 383, 26, 383, 401, 298, 86, 350, 330, 317, 82, 373, 13733, 68, 3292, 531, 267, 511, 12147, 480, 48, 30234, 827, 78, 3952, 1022, 831, 290, 1616, 26, 2322, 401, 490, 298, 10680, 13, 1690, 13, 1465, 1616, 26, 2322, 26, 383, 401, 298, 80, 30234, 827, 78, 3952, 1022, 831, 290, 531, 267, 511, 12147, 480, 86, 350, 330, 317, 82, 373, 13733, 68, 3292, 299, 30234, 289, 581, 643, 333, 1308, 265, 401, 490, 298, 10680, 13, 1690, 13, 1216, 19363, 26, 383, 26, 383, 401, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
michalliu/OpenWrt-Firefly-Libraries
staging_dir/host/lib/python2.7/Cookie.py
19
26492
#### # Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu> # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that both that copyright notice and this permission # notice appear in supporting documentation, and that the name of # Timothy O'Malley not be used in advertising or publicity # pertaining to distribution of the software without specific, written # prior permission. # # Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS # SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY # AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR # ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # #### # # Id: Cookie.py,v 2.29 2000/08/23 05:28:49 timo Exp # by Timothy O'Malley <timo@alum.mit.edu> # # Cookie.py is a Python module for the handling of HTTP # cookies as a Python dictionary. See RFC 2109 for more # information on cookies. # # The original idea to treat Cookies as a dictionary came from # Dave Mitchell (davem@magnet.com) in 1995, when he released the # first version of nscookie.py. # #### r""" Here's a sample session to show how to use this module. At the moment, this is the only documentation. The Basics ---------- Importing is easy.. >>> import Cookie Most of the time you start by creating a cookie. Cookies come in three flavors, each with slightly different encoding semantics, but more on that later. >>> C = Cookie.SimpleCookie() >>> C = Cookie.SerialCookie() >>> C = Cookie.SmartCookie() [Note: Long-time users of Cookie.py will remember using Cookie.Cookie() to create a Cookie object. Although deprecated, it is still supported by the code. See the Backward Compatibility notes for more information.] Once you've created your Cookie, you can add values just as if it were a dictionary. >>> C = Cookie.SmartCookie() >>> C["fig"] = "newton" >>> C["sugar"] = "wafer" >>> C.output() 'Set-Cookie: fig=newton\r\nSet-Cookie: sugar=wafer' Notice that the printable representation of a Cookie is the appropriate format for a Set-Cookie: header. This is the default behavior. You can change the header and printed attributes by using the .output() function >>> C = Cookie.SmartCookie() >>> C["rocky"] = "road" >>> C["rocky"]["path"] = "/cookie" >>> print C.output(header="Cookie:") Cookie: rocky=road; Path=/cookie >>> print C.output(attrs=[], header="Cookie:") Cookie: rocky=road The load() method of a Cookie extracts cookies from a string. In a CGI script, you would use this method to extract the cookies from the HTTP_COOKIE environment variable. >>> C = Cookie.SmartCookie() >>> C.load("chips=ahoy; vienna=finger") >>> C.output() 'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger' The load() method is darn-tootin smart about identifying cookies within a string. Escaped quotation marks, nested semicolons, and other such trickeries do not confuse it. >>> C = Cookie.SmartCookie() >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";') >>> print C Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;" Each element of the Cookie also supports all of the RFC 2109 Cookie attributes. Here's an example which sets the Path attribute. >>> C = Cookie.SmartCookie() >>> C["oreo"] = "doublestuff" >>> C["oreo"]["path"] = "/" >>> print C Set-Cookie: oreo=doublestuff; Path=/ Each dictionary element has a 'value' attribute, which gives you back the value associated with the key. >>> C = Cookie.SmartCookie() >>> C["twix"] = "none for you" >>> C["twix"].value 'none for you' A Bit More Advanced ------------------- As mentioned before, there are three different flavors of Cookie objects, each with different encoding/decoding semantics. This section briefly discusses the differences. SimpleCookie The SimpleCookie expects that all values should be standard strings. Just to be sure, SimpleCookie invokes the str() builtin to convert the value to a string, when the values are set dictionary-style. >>> C = Cookie.SimpleCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value '7' >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number=7\r\nSet-Cookie: string=seven' SerialCookie The SerialCookie expects that all values should be serialized using cPickle (or pickle, if cPickle isn't available). As a result of serializing, SerialCookie can save almost any Python object to a value, and recover the exact same object when the cookie has been returned. (SerialCookie can yield some strange-looking cookie values, however.) >>> C = Cookie.SerialCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value 7 >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."' Be warned, however, if SerialCookie cannot de-serialize a value (because it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION. SmartCookie The SmartCookie combines aspects of each of the other two flavors. When setting a value in a dictionary-fashion, the SmartCookie will serialize (ala cPickle) the value *if and only if* it isn't a Python string. String objects are *not* serialized. Similarly, when the load() method parses out values, it attempts to de-serialize the value. If it fails, then it fallsback to treating the value as a string. >>> C = Cookie.SmartCookie() >>> C["number"] = 7 >>> C["string"] = "seven" >>> C["number"].value 7 >>> C["string"].value 'seven' >>> C.output() 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven' Backwards Compatibility ----------------------- In order to keep compatibilty with earlier versions of Cookie.py, it is still possible to use Cookie.Cookie() to create a Cookie. In fact, this simply returns a SmartCookie. >>> C = Cookie.Cookie() >>> print C.__class__.__name__ SmartCookie Finis. """ #" # ^ # |----helps out font-lock # # Import our required modules # import string try: from cPickle import dumps, loads except ImportError: from pickle import dumps, loads import re, warnings __all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie", "SmartCookie","Cookie"] _nulljoin = ''.join _semispacejoin = '; '.join _spacejoin = ' '.join # # Define an exception visible to External modules # class CookieError(Exception): pass # These quoting routines conform to the RFC2109 specification, which in # turn references the character definitions from RFC2068. They provide # a two-way quoting algorithm. Any non-text character is translated # into a 4 character sequence: a forward-slash followed by the # three-digit octal equivalent of the character. Any '\' or '"' is # quoted with a preceding '\' slash. # # These are taken from RFC2068 and RFC2109. # _LegalChars is the list of chars which don't require "'s # _Translator hash-table for fast quoting # _LegalChars = string.ascii_letters + string.digits + "!#$%&'*+-.^_`|~" _Translator = { '\000' : '\\000', '\001' : '\\001', '\002' : '\\002', '\003' : '\\003', '\004' : '\\004', '\005' : '\\005', '\006' : '\\006', '\007' : '\\007', '\010' : '\\010', '\011' : '\\011', '\012' : '\\012', '\013' : '\\013', '\014' : '\\014', '\015' : '\\015', '\016' : '\\016', '\017' : '\\017', '\020' : '\\020', '\021' : '\\021', '\022' : '\\022', '\023' : '\\023', '\024' : '\\024', '\025' : '\\025', '\026' : '\\026', '\027' : '\\027', '\030' : '\\030', '\031' : '\\031', '\032' : '\\032', '\033' : '\\033', '\034' : '\\034', '\035' : '\\035', '\036' : '\\036', '\037' : '\\037', # Because of the way browsers really handle cookies (as opposed # to what the RFC says) we also encode , and ; ',' : '\\054', ';' : '\\073', '"' : '\\"', '\\' : '\\\\', '\177' : '\\177', '\200' : '\\200', '\201' : '\\201', '\202' : '\\202', '\203' : '\\203', '\204' : '\\204', '\205' : '\\205', '\206' : '\\206', '\207' : '\\207', '\210' : '\\210', '\211' : '\\211', '\212' : '\\212', '\213' : '\\213', '\214' : '\\214', '\215' : '\\215', '\216' : '\\216', '\217' : '\\217', '\220' : '\\220', '\221' : '\\221', '\222' : '\\222', '\223' : '\\223', '\224' : '\\224', '\225' : '\\225', '\226' : '\\226', '\227' : '\\227', '\230' : '\\230', '\231' : '\\231', '\232' : '\\232', '\233' : '\\233', '\234' : '\\234', '\235' : '\\235', '\236' : '\\236', '\237' : '\\237', '\240' : '\\240', '\241' : '\\241', '\242' : '\\242', '\243' : '\\243', '\244' : '\\244', '\245' : '\\245', '\246' : '\\246', '\247' : '\\247', '\250' : '\\250', '\251' : '\\251', '\252' : '\\252', '\253' : '\\253', '\254' : '\\254', '\255' : '\\255', '\256' : '\\256', '\257' : '\\257', '\260' : '\\260', '\261' : '\\261', '\262' : '\\262', '\263' : '\\263', '\264' : '\\264', '\265' : '\\265', '\266' : '\\266', '\267' : '\\267', '\270' : '\\270', '\271' : '\\271', '\272' : '\\272', '\273' : '\\273', '\274' : '\\274', '\275' : '\\275', '\276' : '\\276', '\277' : '\\277', '\300' : '\\300', '\301' : '\\301', '\302' : '\\302', '\303' : '\\303', '\304' : '\\304', '\305' : '\\305', '\306' : '\\306', '\307' : '\\307', '\310' : '\\310', '\311' : '\\311', '\312' : '\\312', '\313' : '\\313', '\314' : '\\314', '\315' : '\\315', '\316' : '\\316', '\317' : '\\317', '\320' : '\\320', '\321' : '\\321', '\322' : '\\322', '\323' : '\\323', '\324' : '\\324', '\325' : '\\325', '\326' : '\\326', '\327' : '\\327', '\330' : '\\330', '\331' : '\\331', '\332' : '\\332', '\333' : '\\333', '\334' : '\\334', '\335' : '\\335', '\336' : '\\336', '\337' : '\\337', '\340' : '\\340', '\341' : '\\341', '\342' : '\\342', '\343' : '\\343', '\344' : '\\344', '\345' : '\\345', '\346' : '\\346', '\347' : '\\347', '\350' : '\\350', '\351' : '\\351', '\352' : '\\352', '\353' : '\\353', '\354' : '\\354', '\355' : '\\355', '\356' : '\\356', '\357' : '\\357', '\360' : '\\360', '\361' : '\\361', '\362' : '\\362', '\363' : '\\363', '\364' : '\\364', '\365' : '\\365', '\366' : '\\366', '\367' : '\\367', '\370' : '\\370', '\371' : '\\371', '\372' : '\\372', '\373' : '\\373', '\374' : '\\374', '\375' : '\\375', '\376' : '\\376', '\377' : '\\377' } _idmap = ''.join(chr(x) for x in xrange(256)) def _quote(str, LegalChars=_LegalChars, idmap=_idmap, translate=string.translate): # # If the string does not need to be double-quoted, # then just return the string. Otherwise, surround # the string in doublequotes and precede quote (with a \) # special characters. # if "" == translate(str, idmap, LegalChars): return str else: return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"' # end _quote _OctalPatt = re.compile(r"\\[0-3][0-7][0-7]") _QuotePatt = re.compile(r"[\\].") def _unquote(str): # If there aren't any doublequotes, # then there can't be any special characters. See RFC 2109. if len(str) < 2: return str if str[0] != '"' or str[-1] != '"': return str # We have to assume that we must decode this string. # Down to work. # Remove the "s str = str[1:-1] # Check for special sequences. Examples: # \012 --> \n # \" --> " # i = 0 n = len(str) res = [] while 0 <= i < n: Omatch = _OctalPatt.search(str, i) Qmatch = _QuotePatt.search(str, i) if not Omatch and not Qmatch: # Neither matched res.append(str[i:]) break # else: j = k = -1 if Omatch: j = Omatch.start(0) if Qmatch: k = Qmatch.start(0) if Qmatch and ( not Omatch or k < j ): # QuotePatt matched res.append(str[i:k]) res.append(str[k+1]) i = k+2 else: # OctalPatt matched res.append(str[i:j]) res.append( chr( int(str[j+1:j+4], 8) ) ) i = j+4 return _nulljoin(res) # end _unquote # The _getdate() routine is used to set the expiration time in # the cookie's HTTP header. By default, _getdate() returns the # current time in the appropriate "expires" format for a # Set-Cookie header. The one optional argument is an offset from # now, in seconds. For example, an offset of -3600 means "one hour ago". # The offset may be a floating point number. # _weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] _monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname): from time import gmtime, time now = time() year, month, day, hh, mm, ss, wd, y, z = gmtime(now + future) return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % \ (weekdayname[wd], day, monthname[month], year, hh, mm, ss) # # A class to hold ONE key,value pair. # In a cookie, each such pair may have several attributes. # so this class is used to keep the attributes associated # with the appropriate key,value pair. # This class also includes a coded_value attribute, which # is used to hold the network representation of the # value. This is most useful when Python objects are # pickled for network transit. # class Morsel(dict): # RFC 2109 lists these attributes as reserved: # path comment domain # max-age secure version # # For historical reasons, these attributes are also reserved: # expires # # This is an extension from Microsoft: # httponly # # This dictionary provides a mapping from the lowercase # variant on the left to the appropriate traditional # formatting on the right. _reserved = { "expires" : "expires", "path" : "Path", "comment" : "Comment", "domain" : "Domain", "max-age" : "Max-Age", "secure" : "secure", "httponly" : "httponly", "version" : "Version", } _flags = {'secure', 'httponly'} def __init__(self): # Set defaults self.key = self.value = self.coded_value = None # Set default attributes for K in self._reserved: dict.__setitem__(self, K, "") # end __init__ def __setitem__(self, K, V): K = K.lower() if not K in self._reserved: raise CookieError("Invalid Attribute %s" % K) dict.__setitem__(self, K, V) # end __setitem__ def isReservedKey(self, K): return K.lower() in self._reserved # end isReservedKey def set(self, key, val, coded_val, LegalChars=_LegalChars, idmap=_idmap, translate=string.translate): # First we verify that the key isn't a reserved word # Second we make sure it only contains legal characters if key.lower() in self._reserved: raise CookieError("Attempt to set a reserved key: %s" % key) if "" != translate(key, idmap, LegalChars): raise CookieError("Illegal key value: %s" % key) # It's a good key, so save it. self.key = key self.value = val self.coded_value = coded_val # end set def output(self, attrs=None, header = "Set-Cookie:"): return "%s %s" % ( header, self.OutputString(attrs) ) __str__ = output def __repr__(self): return '<%s: %s=%s>' % (self.__class__.__name__, self.key, repr(self.value) ) def js_output(self, attrs=None): # Print javascript return """ <script type="text/javascript"> <!-- begin hiding document.cookie = \"%s\"; // end hiding --> </script> """ % ( self.OutputString(attrs).replace('"',r'\"'), ) # end js_output() def OutputString(self, attrs=None): # Build up our result # result = [] RA = result.append # First, the key=value pair RA("%s=%s" % (self.key, self.coded_value)) # Now add any defined attributes if attrs is None: attrs = self._reserved items = self.items() items.sort() for K,V in items: if V == "": continue if K not in attrs: continue if K == "expires" and type(V) == type(1): RA("%s=%s" % (self._reserved[K], _getdate(V))) elif K == "max-age" and type(V) == type(1): RA("%s=%d" % (self._reserved[K], V)) elif K == "secure": RA(str(self._reserved[K])) elif K == "httponly": RA(str(self._reserved[K])) else: RA("%s=%s" % (self._reserved[K], V)) # Return the result return _semispacejoin(result) # end OutputString # end Morsel class # # Pattern for finding cookie # # This used to be strict parsing based on the RFC2109 and RFC2068 # specifications. I have since discovered that MSIE 3.0x doesn't # follow the character rules outlined in those specs. As a # result, the parsing rules here are less strict. # _LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]" _CookiePattern = re.compile( r"(?x)" # This is a Verbose pattern r"\s*" # Optional whitespace at start of cookie r"(?P<key>" # Start of group 'key' ""+ _LegalCharsPatt +"+?" # Any word of at least one letter, nongreedy r")" # End of group 'key' r"(" # Optional group: there may not be a value. r"\s*=\s*" # Equal Sign r"(?P<val>" # Start of group 'val' r'"(?:[^\\"]|\\.)*"' # Any doublequoted string r"|" # or r"\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT" # Special case for "expires" attr r"|" # or ""+ _LegalCharsPatt +"*" # Any word or empty string r")" # End of group 'val' r")?" # End of optional value group r"\s*" # Any number of spaces. r"(\s+|;|$)" # Ending either at space, semicolon, or EOS. ) # At long last, here is the cookie class. # Using this class is almost just like using a dictionary. # See this module's docstring for example usage. # class BaseCookie(dict): # A container class for a set of Morsels # def value_decode(self, val): """real_value, coded_value = value_decode(STRING) Called prior to setting a cookie's value from the network representation. The VALUE is the value read from HTTP header. Override this function to modify the behavior of cookies. """ return val, val # end value_encode def value_encode(self, val): """real_value, coded_value = value_encode(VALUE) Called prior to setting a cookie's value from the dictionary representation. The VALUE is the value being assigned. Override this function to modify the behavior of cookies. """ strval = str(val) return strval, strval # end value_encode def __init__(self, input=None): if input: self.load(input) # end __init__ def __set(self, key, real_value, coded_value): """Private method for setting a cookie's value""" M = self.get(key, Morsel()) M.set(key, real_value, coded_value) dict.__setitem__(self, key, M) # end __set def __setitem__(self, key, value): """Dictionary style assignment.""" if isinstance(value, Morsel): # allow assignment of constructed Morsels (e.g. for pickling) dict.__setitem__(self, key, value) else: rval, cval = self.value_encode(value) self.__set(key, rval, cval) # end __setitem__ def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"): """Return a string suitable for HTTP.""" result = [] items = self.items() items.sort() for K,V in items: result.append( V.output(attrs, header) ) return sep.join(result) # end output __str__ = output def __repr__(self): L = [] items = self.items() items.sort() for K,V in items: L.append( '%s=%s' % (K,repr(V.value) ) ) return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L)) def js_output(self, attrs=None): """Return a string suitable for JavaScript.""" result = [] items = self.items() items.sort() for K,V in items: result.append( V.js_output(attrs) ) return _nulljoin(result) # end js_output def load(self, rawdata): """Load cookies from a string (presumably HTTP_COOKIE) or from a dictionary. Loading cookies from a dictionary 'd' is equivalent to calling: map(Cookie.__setitem__, d.keys(), d.values()) """ if type(rawdata) == type(""): self.__ParseString(rawdata) else: # self.update() wouldn't call our custom __setitem__ for k, v in rawdata.items(): self[k] = v return # end load() def __ParseString(self, str, patt=_CookiePattern): i = 0 # Our starting point n = len(str) # Length of string M = None # current morsel while 0 <= i < n: # Start looking for a cookie match = patt.match(str, i) if not match: break # No more cookies K,V = match.group("key"), match.group("val") i = match.end(0) # Parse the key, value in case it's metainfo if K[0] == "$": # We ignore attributes which pertain to the cookie # mechanism as a whole. See RFC 2109. # (Does anyone care?) if M: M[ K[1:] ] = V elif K.lower() in Morsel._reserved: if M: if V is None: if K.lower() in Morsel._flags: M[K] = True else: M[K] = _unquote(V) elif V is not None: rval, cval = self.value_decode(V) self.__set(K, rval, cval) M = self[K] # end __ParseString # end BaseCookie class class SimpleCookie(BaseCookie): """SimpleCookie SimpleCookie supports strings as cookie values. When setting the value using the dictionary assignment notation, SimpleCookie calls the builtin str() to convert the value to a string. Values received from HTTP are kept as strings. """ def value_decode(self, val): return _unquote( val ), val def value_encode(self, val): strval = str(val) return strval, _quote( strval ) # end SimpleCookie class SerialCookie(BaseCookie): """SerialCookie SerialCookie supports arbitrary objects as cookie values. All values are serialized (using cPickle) before being sent to the client. All incoming values are assumed to be valid Pickle representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE FORMAT, THEN AN EXCEPTION WILL BE RAISED. Note: Large cookie values add overhead because they must be retransmitted on every HTTP transaction. Note: HTTP has a 2k limit on the size of a cookie. This class does not check for this limit, so be careful!!! """ def __init__(self, input=None): warnings.warn("SerialCookie class is insecure; do not use it", DeprecationWarning) BaseCookie.__init__(self, input) # end __init__ def value_decode(self, val): # This could raise an exception! return loads( _unquote(val) ), val def value_encode(self, val): return val, _quote( dumps(val) ) # end SerialCookie class SmartCookie(BaseCookie): """SmartCookie SmartCookie supports arbitrary objects as cookie values. If the object is a string, then it is quoted. If the object is not a string, however, then SmartCookie will use cPickle to serialize the object into a string representation. Note: Large cookie values add overhead because they must be retransmitted on every HTTP transaction. Note: HTTP has a 2k limit on the size of a cookie. This class does not check for this limit, so be careful!!! """ def __init__(self, input=None): warnings.warn("Cookie/SmartCookie class is insecure; do not use it", DeprecationWarning) BaseCookie.__init__(self, input) # end __init__ def value_decode(self, val): strval = _unquote(val) try: return loads(strval), val except: return strval, val def value_encode(self, val): if type(val) == type(""): return val, _quote(val) else: return val, _quote( dumps(val) ) # end SmartCookie ########################################################### # Backwards Compatibility: Don't break any existing code! # We provide Cookie() as an alias for SmartCookie() Cookie = SmartCookie # ########################################################### def _test(): import doctest, Cookie return doctest.testmod(Cookie) if __name__ == "__main__": _test() #Local Variables: #tab-width: 4 #end:
gpl-2.0
[ 381, 199, 3, 1898, 12293, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 4483, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 199, 3, 436, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 221, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 199, 3, 2401, 3092, 12, 1621, 4825, 6461, 7000, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 199, 3, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 381, 199, 3, 199, 3, 15418, 26, 14798, 14, 647, 12, 86, 499, 14, 1398, 12293, 15, 2036, 15, 1789, 22528, 26, 1651, 26, 1887, 3367, 573, 7910, 199, 3, 257, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 221, 14798, 14, 647, 365, 282, 2018, 859, 367, 314, 7252, 402, 3101, 199, 3, 221, 10049, 465, 282, 2018, 2600, 14, 221, 1666, 7329, 499, 6996, 367, 1655, 199, 3, 221, 2556, 641, 10049, 14, 199, 3, 199, 3, 221, 710, 3379, 16819, 370, 14312, 1849, 5635, 465, 282, 2600, 20382, 687, 199, 3, 221, 577, 811, 603, 9414, 1697, 334, 68, 811, 77, 32, 19902, 386, 14, 957, 9, 315, 9013, 21, 12, 1380, 946, 14286, 314, 199, 3, 221, 1642, 1015, 402, 700, 5306, 14, 647, 14, 199, 3, 199, 381, 199, 199, 82, 624, 199, 21741, 1159, 282, 2690, 2351, 370, 2498, 4212, 370, 675, 642, 859, 14, 199, 1271, 314, 12427, 12, 642, 365, 314, 1454, 3794, 14, 199, 199, 1918, 10082, 83, 199, 9460, 199, 199, 6295, 316, 365, 8837, 703, 8410, 1306, 492, 14798, 199, 199, 24625, 402, 314, 900, 1265, 1343, 701, 6425, 282, 5494, 14, 221, 1849, 5635, 11492, 315, 199, 10480, 23547, 12, 1924, 543, 18023, 3365, 2644, 19002, 12, 1325, 199, 6878, 641, 626, 2945, 14, 8410, 1306, 445, 275, 14798, 14, 3184, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 3571, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 199, 199, 59, 7443, 26, 19944, 13, 521, 4390, 402, 14798, 14, 647, 911, 21027, 1808, 199, 7810, 14, 7810, 342, 370, 1218, 282, 14798, 909, 14, 221, 4580, 15401, 5906, 12, 652, 199, 374, 5139, 3748, 701, 314, 1233, 14, 221, 1666, 314, 10257, 3079, 3599, 5880, 12681, 199, 509, 1655, 2556, 19784, 199, 199, 25690, 1265, 9064, 2737, 2195, 14798, 12, 1265, 883, 1050, 1338, 2951, 465, 340, 652, 4898, 199, 65, 2600, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 592, 937, 275, 298, 1222, 1860, 2, 2043, 1306, 445, 905, 83, 21922, 937, 275, 298, 758, 2412, 2, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 6085, 29, 1222, 1860, 60, 82, 60, 78, 1084, 13, 7810, 26, 308, 21922, 29, 758, 2412, 7, 199, 199, 1944, 3548, 626, 314, 21834, 6025, 402, 282, 14798, 365, 314, 199, 11227, 5655, 1475, 367, 282, 2494, 13, 7810, 26, 1406, 14, 221, 961, 365, 314, 199, 885, 5953, 14, 221, 2047, 883, 1570, 314, 1406, 436, 12487, 199, 2987, 701, 1808, 314, 1275, 1199, 342, 805, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 24892, 89, 937, 275, 298, 5063, 2, 2043, 1306, 445, 905, 24892, 89, 6611, 515, 937, 275, 3286, 5306, 2, 2043, 1306, 870, 445, 14, 1199, 8, 1291, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 27, 6912, 13043, 5306, 2043, 1306, 870, 445, 14, 1199, 8, 3288, 6034, 1406, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 199, 199, 1918, 2248, 342, 1083, 402, 282, 14798, 5536, 83, 10049, 687, 282, 1059, 14, 221, 1010, 282, 199, 21337, 2884, 12, 1265, 3955, 675, 642, 1083, 370, 5536, 314, 10049, 687, 314, 199, 2856, 63, 13665, 3734, 1750, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 480, 335, 6142, 29, 65, 526, 89, 27, 1321, 287, 3540, 29, 70, 7886, 531, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 682, 6142, 29, 65, 526, 89, 60, 82, 60, 78, 1084, 13, 7810, 26, 1321, 287, 3540, 29, 70, 7886, 7, 199, 199, 1918, 2248, 342, 1083, 365, 366, 1060, 13, 475, 357, 262, 11179, 3595, 21119, 10049, 199, 12541, 282, 1059, 14, 221, 21067, 68, 25101, 17370, 12, 6032, 18734, 761, 4654, 12, 436, 1163, 199, 10180, 20907, 5460, 886, 440, 3743, 1180, 652, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 360, 415, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 29, 15022, 2041, 2310, 1103, 11436, 289, 16603, 29, 1103, 11533, 9426, 10784, 2043, 1306, 870, 445, 2043, 2494, 13, 7810, 26, 10074, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 8178, 2041, 2310, 4451, 27, 289, 16603, 9529, 11533, 9426, 199, 199, 22321, 1819, 402, 314, 14798, 2597, 5171, 1006, 402, 314, 7329, 499, 6996, 199, 7810 ]
[ 199, 3, 1898, 12293, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 4483, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 370, 675, 12, 1331, 12, 2811, 12, 436, 11207, 642, 2032, 199, 3, 436, 2399, 3794, 367, 1263, 12016, 436, 1928, 14751, 365, 11882, 199, 3, 10009, 12, 2741, 626, 314, 3432, 4248, 4245, 7468, 315, 1006, 199, 3, 6866, 436, 626, 3865, 626, 4248, 4245, 436, 642, 4983, 199, 3, 4245, 7468, 315, 21038, 3794, 12, 436, 626, 314, 536, 402, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 221, 440, 506, 1202, 315, 19613, 1044, 503, 7974, 20976, 199, 3, 1126, 24522, 370, 4084, 402, 314, 2032, 1928, 2488, 12, 5313, 199, 3, 6791, 4983, 14, 199, 3, 199, 3, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 8990, 51, 11727, 2990, 1663, 14142, 7816, 2296, 5749, 199, 3, 4141, 12, 6931, 11727, 5292, 2990, 1634, 3169, 199, 3, 2401, 3092, 12, 1621, 4825, 6461, 7000, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 6262, 7024, 2381, 199, 3, 1821, 8820, 12, 9168, 1549, 9110, 6736, 1549, 1821, 6736, 199, 3, 28752, 4118, 27362, 20668, 1206, 4442, 9102, 1634, 4815, 12, 7126, 1549, 9206, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 9254, 1549, 5010, 7056, 25657, 199, 3, 9612, 12, 7043, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4815, 1549, 199, 3, 13873, 30340, 1634, 5749, 4141, 14, 199, 3, 199, 381, 199, 3, 199, 3, 15418, 26, 14798, 14, 647, 12, 86, 499, 14, 1398, 12293, 15, 2036, 15, 1789, 22528, 26, 1651, 26, 1887, 3367, 573, 7910, 199, 3, 257, 701, 377, 73, 573, 273, 89, 593, 7, 45, 4598, 89, 665, 280, 573, 32, 279, 453, 14, 1147, 14, 8654, 30, 199, 3, 199, 3, 221, 14798, 14, 647, 365, 282, 2018, 859, 367, 314, 7252, 402, 3101, 199, 3, 221, 10049, 465, 282, 2018, 2600, 14, 221, 1666, 7329, 499, 6996, 367, 1655, 199, 3, 221, 2556, 641, 10049, 14, 199, 3, 199, 3, 221, 710, 3379, 16819, 370, 14312, 1849, 5635, 465, 282, 2600, 20382, 687, 199, 3, 221, 577, 811, 603, 9414, 1697, 334, 68, 811, 77, 32, 19902, 386, 14, 957, 9, 315, 9013, 21, 12, 1380, 946, 14286, 314, 199, 3, 221, 1642, 1015, 402, 700, 5306, 14, 647, 14, 199, 3, 199, 381, 199, 199, 82, 624, 199, 21741, 1159, 282, 2690, 2351, 370, 2498, 4212, 370, 675, 642, 859, 14, 199, 1271, 314, 12427, 12, 642, 365, 314, 1454, 3794, 14, 199, 199, 1918, 10082, 83, 199, 9460, 199, 199, 6295, 316, 365, 8837, 703, 8410, 1306, 492, 14798, 199, 199, 24625, 402, 314, 900, 1265, 1343, 701, 6425, 282, 5494, 14, 221, 1849, 5635, 11492, 315, 199, 10480, 23547, 12, 1924, 543, 18023, 3365, 2644, 19002, 12, 1325, 199, 6878, 641, 626, 2945, 14, 8410, 1306, 445, 275, 14798, 14, 3184, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 3571, 7810, 342, 2043, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 199, 199, 59, 7443, 26, 19944, 13, 521, 4390, 402, 14798, 14, 647, 911, 21027, 1808, 199, 7810, 14, 7810, 342, 370, 1218, 282, 14798, 909, 14, 221, 4580, 15401, 5906, 12, 652, 199, 374, 5139, 3748, 701, 314, 1233, 14, 221, 1666, 314, 10257, 3079, 3599, 5880, 12681, 199, 509, 1655, 2556, 19784, 199, 199, 25690, 1265, 9064, 2737, 2195, 14798, 12, 1265, 883, 1050, 1338, 2951, 465, 340, 652, 4898, 199, 65, 2600, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 592, 937, 275, 298, 1222, 1860, 2, 2043, 1306, 445, 905, 83, 21922, 937, 275, 298, 758, 2412, 2, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 6085, 29, 1222, 1860, 60, 82, 60, 78, 1084, 13, 7810, 26, 308, 21922, 29, 758, 2412, 7, 199, 199, 1944, 3548, 626, 314, 21834, 6025, 402, 282, 14798, 365, 314, 199, 11227, 5655, 1475, 367, 282, 2494, 13, 7810, 26, 1406, 14, 221, 961, 365, 314, 199, 885, 5953, 14, 221, 2047, 883, 1570, 314, 1406, 436, 12487, 199, 2987, 701, 1808, 314, 1275, 1199, 342, 805, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 905, 24892, 89, 937, 275, 298, 5063, 2, 2043, 1306, 445, 905, 24892, 89, 6611, 515, 937, 275, 3286, 5306, 2, 2043, 1306, 870, 445, 14, 1199, 8, 1291, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 27, 6912, 13043, 5306, 2043, 1306, 870, 445, 14, 1199, 8, 3288, 6034, 1406, 628, 7810, 9107, 2043, 14798, 26, 882, 346, 89, 29, 5063, 199, 199, 1918, 2248, 342, 1083, 402, 282, 14798, 5536, 83, 10049, 687, 282, 1059, 14, 221, 1010, 282, 199, 21337, 2884, 12, 1265, 3955, 675, 642, 1083, 370, 5536, 314, 10049, 687, 314, 199, 2856, 63, 13665, 3734, 1750, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 480, 335, 6142, 29, 65, 526, 89, 27, 1321, 287, 3540, 29, 70, 7886, 531, 2043, 1306, 445, 14, 1199, 342, 2043, 283, 1084, 13, 7810, 26, 682, 6142, 29, 65, 526, 89, 60, 82, 60, 78, 1084, 13, 7810, 26, 1321, 287, 3540, 29, 70, 7886, 7, 199, 199, 1918, 2248, 342, 1083, 365, 366, 1060, 13, 475, 357, 262, 11179, 3595, 21119, 10049, 199, 12541, 282, 1059, 14, 221, 21067, 68, 25101, 17370, 12, 6032, 18734, 761, 4654, 12, 436, 1163, 199, 10180, 20907, 5460, 886, 440, 3743, 1180, 652, 14, 8410, 1306, 445, 275, 14798, 14, 29111, 7810, 342, 2043, 1306, 445, 14, 912, 360, 415, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 29, 15022, 2041, 2310, 1103, 11436, 289, 16603, 29, 1103, 11533, 9426, 10784, 2043, 1306, 870, 445, 2043, 2494, 13, 7810, 26, 10074, 69, 830, 82, 628, 37, 29, 14287, 2030, 27, 491, 8178, 2041, 2310, 4451, 27, 289, 16603, 9529, 11533, 9426, 199, 199, 22321, 1819, 402, 314, 14798, 2597, 5171, 1006, 402, 314, 7329, 499, 6996, 199, 7810, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
sayan801/indivo_server
utils/pha_setup.py
4
3833
import sys import hashlib import string from indivo.models import PHA from indivo.models import Account from indivo.models import Record from indivo.models import DocumentSchema #Order on the arguments: pha_name, contact_email, pha_start_url_template, pha_callback_url class PHA_Creation: def __init__(self, pha_name, pha_start_url_template, pha_callback_url): self.pha_name = pha_name.capitalize() self.pha_key = pha_name.lower() self.pha_secret = self.generate_secret(pha_name) self.pha_description = 'default description' self.pha_start_url_template = pha_start_url_template self.pha_callback_url = pha_callback_url self.pha_email = pha_name + '@apps.indivo.org' self.pha_frameable = True self.pha_has_ui = True self.pha_document_schema = pha_name.capitalize() def generate_secret(self, name): return hashlib.sha1(name + 'indivo_test:abcdefg123').hexdigest()[0:12] def create_pha(self): try: #try: # pha_document_schema = DocumentSchema.objects.get(type=self.pha_document_schema) #except DocumentSchema.DoesNotExist: # DocumentSchema.objects.create(type=self.pha_document_schema) try: pha = PHA.objects.get(consumer_key=self.pha_key) except PHA.DoesNotExist: pha = PHA.objects.create( consumer_key=self.pha_key, secret=self.pha_secret, name=self.pha_name, description=self.pha_description, start_url_template=self.pha_start_url_template, callback_url=self.pha_callback_url, email=self.pha_email, frameable=self.pha_frameable, has_ui=self.pha_has_ui, schema=None) return pha except: return False def get_argv(index): if len(sys.argv) > index: return sys.argv[index] return '' def create_accounts_and_records(pha_create_obj, pha_name, contact_email): domain = '@x-staging.indivo.org' user_list = ['user_1', 'user_2', 'user_3'] for user in user_list: username = pha_name + '_' + user password = pha_create_obj.generate_secret(pha_name + user) account = Account.objects.create( email=username + domain, full_name=pha_name, contact_email=contact_email) account.set_username_and_password(username=username, password=password) record = Record.objects.create(owner=account, label=username) print "\n" print "Account: " + username + domain print "Password: " + password print "Record: " + record.id print "="*50 if __name__ == '__main__': pha_name = '' pha_callback_url = '' pha_start_url_template = '' pha_name, contact_email, pha_start_url_template, pha_callback_url = get_argv(1), get_argv(2), get_argv(3), get_argv(4) if pha_name and contact_email: pha_create_obj = PHA_Creation(pha_name, pha_start_url_template, pha_callback_url) pha = pha_create_obj.create_pha() if pha: print 'pha creation successful' print "Consumer Key: " + pha.consumer_key print "Consumer Secret: " + pha.secret print "PHA Name: " + pha.name print "PHA Description: " + pha.description print "PHA Start URL Template: " + pha.start_url_template print "PHA Callback URL: " + pha.callback_url print "PHA Email: " + pha.email print "PHA Frameable: " + str(pha.frameable) print "PHA HasUI: " + str(pha.has_ui) print "PHA Document Schema: None" create_accounts_and_records(pha_create_obj, pha_name, contact_email) else: print "A PHA by this name already exists"
gpl-3.0
[ 646, 984, 199, 646, 8337, 199, 646, 1059, 199, 504, 2539, 2392, 14, 992, 492, 510, 6294, 199, 504, 2539, 2392, 14, 992, 492, 9973, 199, 504, 2539, 2392, 14, 992, 492, 12651, 199, 504, 2539, 2392, 14, 992, 492, 7543, 6700, 199, 199, 3, 4738, 641, 314, 2368, 26, 299, 2411, 63, 354, 12, 8966, 63, 2123, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 421, 199, 533, 510, 6294, 63, 13921, 26, 819, 347, 636, 826, 721, 277, 12, 299, 2411, 63, 354, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 304, 272, 291, 14, 2914, 63, 354, 275, 299, 2411, 63, 354, 14, 18351, 342, 272, 291, 14, 2914, 63, 498, 275, 299, 2411, 63, 354, 14, 2325, 342, 272, 291, 14, 2914, 63, 4731, 275, 291, 14, 4208, 63, 4731, 8, 2914, 63, 354, 9, 272, 291, 14, 2914, 63, 1802, 275, 283, 885, 1369, 7, 272, 291, 14, 2914, 63, 928, 63, 633, 63, 1160, 275, 299, 2411, 63, 928, 63, 633, 63, 1160, 272, 291, 14, 2914, 63, 3058, 63, 633, 275, 299, 2411, 63, 3058, 63, 633, 272, 291, 14, 2914, 63, 2123, 275, 299, 2411, 63, 354, 435, 10267, 5181, 14, 3558, 2392, 14, 1308, 7, 272, 291, 14, 2914, 63, 1943, 461, 275, 715, 272, 291, 14, 2914, 63, 1989, 63, 1907, 275, 715, 272, 291, 14, 2914, 63, 3554, 63, 3629, 275, 299, 2411, 63, 354, 14, 18351, 342, 819, 347, 3550, 63, 4731, 8, 277, 12, 536, 304, 272, 372, 8337, 14, 4835, 17, 8, 354, 435, 283, 3558, 2392, 63, 396, 26, 10678, 71, 4288, 1959, 11453, 3430, 16, 26, 713, 61, 819, 347, 1218, 63, 2914, 8, 277, 304, 5591, 862, 26, 489, 327, 893, 26, 489, 327, 221, 299, 2411, 63, 3554, 63, 3629, 275, 7543, 6700, 14, 1462, 14, 362, 8, 466, 29, 277, 14, 2914, 63, 3554, 63, 3629, 9, 489, 327, 2590, 7543, 6700, 14, 7400, 26, 489, 327, 221, 7543, 6700, 14, 1462, 14, 981, 8, 466, 29, 277, 14, 2914, 63, 3554, 63, 3629, 9, 2541, 862, 26, 267, 299, 2411, 275, 510, 6294, 14, 1462, 14, 362, 8, 8542, 63, 498, 29, 277, 14, 2914, 63, 498, 9, 489, 871, 510, 6294, 14, 7400, 26, 267, 299, 2411, 275, 510, 6294, 14, 1462, 14, 981, 8, 9790, 63, 498, 29, 277, 14, 2914, 63, 498, 12, 221, 3303, 7565, 29, 277, 14, 2914, 63, 4731, 12, 221, 3303, 536, 29, 277, 14, 2914, 63, 354, 12, 3303, 1369, 29, 277, 14, 2914, 63, 1802, 12, 3303, 1343, 63, 633, 63, 1160, 29, 277, 14, 2914, 63, 928, 63, 633, 63, 1160, 12, 3303, 3233, 63, 633, 29, 277, 14, 2914, 63, 3058, 63, 633, 12, 3303, 3031, 29, 277, 14, 2914, 63, 2123, 12, 3303, 2787, 461, 29, 277, 14, 2914, 63, 1943, 461, 12, 3303, 965, 63, 1907, 29, 277, 14, 2914, 63, 1989, 63, 1907, 12, 3303, 4177, 29, 403, 9, 267, 372, 299, 2411, 272, 871, 26, 489, 372, 756, 199, 199, 318, 664, 63, 3020, 8, 1080, 304, 523, 340, 822, 8, 1274, 14, 3020, 9, 690, 1478, 26, 272, 372, 984, 14, 3020, 59, 1080, 61, 523, 372, 2125, 199, 199, 318, 1218, 63, 8370, 63, 460, 63, 6502, 8, 2914, 63, 981, 63, 1113, 12, 299, 2411, 63, 354, 12, 8966, 63, 2123, 304, 523, 2881, 275, 10267, 88, 13, 26840, 14, 3558, 2392, 14, 1308, 7, 523, 922, 63, 513, 275, 788, 751, 63, 17, 297, 283, 751, 63, 18, 297, 283, 751, 63, 19, 418, 523, 367, 922, 315, 922, 63, 513, 26, 272, 3434, 275, 299, 2411, 63, 354, 435, 14135, 435, 922, 272, 2505, 275, 299, 2411, 63, 981, 63, 1113, 14, 4208, 63, 4731, 8, 2914, 63, 354, 435, 922, 9, 272, 2933, 275, 9973, 14, 1462, 14, 981, 8, 3031, 29, 2473, 435, 2881, 12, 221, 4228, 2615, 63, 354, 29, 2914, 63, 354, 12, 221, 4228, 8966, 63, 2123, 29, 7811, 63, 2123, 9, 272, 2933, 14, 409, 63, 2473, 63, 460, 63, 2060, 8, 2473, 29, 2473, 12, 2505, 29, 2060, 9, 272, 2777, 275, 12651, 14, 1462, 14, 981, 8, 4597, 29, 2048, 12, 1768, 29, 2473, 9, 272, 870, 1867, 78, 2, 272, 870, 298, 6009, 26, 298, 435, 3434, 435, 2881, 272, 870, 298, 6139, 26, 298, 435, 2505, 272, 870, 298, 5433, 26, 298, 435, 2777, 14, 344, 272, 870, 22250, 10, 1400, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 299, 2411, 63, 354, 4483, 275, 2125, 523, 299, 2411, 63, 3058, 63, 633, 263, 275, 2125, 523, 299, 2411, 63, 928, 63, 633, 63, 1160, 221, 275, 2125, 523, 299, 2411, 63, 354, 12, 8966, 63, 2123, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 275, 664, 63, 3020, 8, 17, 395, 664, 63, 3020, 8, 18, 395, 664, 63, 3020, 8, 19, 395, 664, 63, 3020, 8, 20, 9, 523, 340, 299, 2411, 63, 354, 436, 8966, 63, 2123, 26, 272, 299, 2411, 63, 981, 63, 1113, 275, 510, 6294, 63, 13921, 8, 2914, 63, 354, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 9, 272, 299, 2411, 275, 299, 2411, 63, 981, 63, 1113, 14, 981, 63, 2914, 342, 272, 340, 299, 2411, 26, 489, 870, 283, 2914, 7143, 9512, 7, 489, 870, 298, 18186, 2606, 26, 298, 435, 299, 2411, 14, 8542, 63, 498, 489, 870, 298, 18186, 23580, 26, 298, 435, 299, 2411, 14, 4731, 489, 870, 298, 16520, 2812, 26, 298, 435, 299, 2411, 14, 354, 489, 870, 298, 16520, 11994, 26, 298, 435, 299, 2411, 14, 1802, 489, 870, 298, 16520, 7707, 2851, 5458, 26, 298, 435, 299, 2411, 14, 928, 63, 633, 63, 1160, 489, 870, 298, 16520, 17555, 2851, 26, 298, 435, 299, 2411, 14, 3058, 63, 633, 489, 870, 298, 16520, 11426, 26, 298, 435, 299, 2411, 14, 2123, 489, 870, 298, 16520, 11726, 461, 26, 298, 435, 620, 8 ]
[ 984, 199, 646, 8337, 199, 646, 1059, 199, 504, 2539, 2392, 14, 992, 492, 510, 6294, 199, 504, 2539, 2392, 14, 992, 492, 9973, 199, 504, 2539, 2392, 14, 992, 492, 12651, 199, 504, 2539, 2392, 14, 992, 492, 7543, 6700, 199, 199, 3, 4738, 641, 314, 2368, 26, 299, 2411, 63, 354, 12, 8966, 63, 2123, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 421, 199, 533, 510, 6294, 63, 13921, 26, 819, 347, 636, 826, 721, 277, 12, 299, 2411, 63, 354, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 304, 272, 291, 14, 2914, 63, 354, 275, 299, 2411, 63, 354, 14, 18351, 342, 272, 291, 14, 2914, 63, 498, 275, 299, 2411, 63, 354, 14, 2325, 342, 272, 291, 14, 2914, 63, 4731, 275, 291, 14, 4208, 63, 4731, 8, 2914, 63, 354, 9, 272, 291, 14, 2914, 63, 1802, 275, 283, 885, 1369, 7, 272, 291, 14, 2914, 63, 928, 63, 633, 63, 1160, 275, 299, 2411, 63, 928, 63, 633, 63, 1160, 272, 291, 14, 2914, 63, 3058, 63, 633, 275, 299, 2411, 63, 3058, 63, 633, 272, 291, 14, 2914, 63, 2123, 275, 299, 2411, 63, 354, 435, 10267, 5181, 14, 3558, 2392, 14, 1308, 7, 272, 291, 14, 2914, 63, 1943, 461, 275, 715, 272, 291, 14, 2914, 63, 1989, 63, 1907, 275, 715, 272, 291, 14, 2914, 63, 3554, 63, 3629, 275, 299, 2411, 63, 354, 14, 18351, 342, 819, 347, 3550, 63, 4731, 8, 277, 12, 536, 304, 272, 372, 8337, 14, 4835, 17, 8, 354, 435, 283, 3558, 2392, 63, 396, 26, 10678, 71, 4288, 1959, 11453, 3430, 16, 26, 713, 61, 819, 347, 1218, 63, 2914, 8, 277, 304, 5591, 862, 26, 489, 327, 893, 26, 489, 327, 221, 299, 2411, 63, 3554, 63, 3629, 275, 7543, 6700, 14, 1462, 14, 362, 8, 466, 29, 277, 14, 2914, 63, 3554, 63, 3629, 9, 489, 327, 2590, 7543, 6700, 14, 7400, 26, 489, 327, 221, 7543, 6700, 14, 1462, 14, 981, 8, 466, 29, 277, 14, 2914, 63, 3554, 63, 3629, 9, 2541, 862, 26, 267, 299, 2411, 275, 510, 6294, 14, 1462, 14, 362, 8, 8542, 63, 498, 29, 277, 14, 2914, 63, 498, 9, 489, 871, 510, 6294, 14, 7400, 26, 267, 299, 2411, 275, 510, 6294, 14, 1462, 14, 981, 8, 9790, 63, 498, 29, 277, 14, 2914, 63, 498, 12, 221, 3303, 7565, 29, 277, 14, 2914, 63, 4731, 12, 221, 3303, 536, 29, 277, 14, 2914, 63, 354, 12, 3303, 1369, 29, 277, 14, 2914, 63, 1802, 12, 3303, 1343, 63, 633, 63, 1160, 29, 277, 14, 2914, 63, 928, 63, 633, 63, 1160, 12, 3303, 3233, 63, 633, 29, 277, 14, 2914, 63, 3058, 63, 633, 12, 3303, 3031, 29, 277, 14, 2914, 63, 2123, 12, 3303, 2787, 461, 29, 277, 14, 2914, 63, 1943, 461, 12, 3303, 965, 63, 1907, 29, 277, 14, 2914, 63, 1989, 63, 1907, 12, 3303, 4177, 29, 403, 9, 267, 372, 299, 2411, 272, 871, 26, 489, 372, 756, 199, 199, 318, 664, 63, 3020, 8, 1080, 304, 523, 340, 822, 8, 1274, 14, 3020, 9, 690, 1478, 26, 272, 372, 984, 14, 3020, 59, 1080, 61, 523, 372, 2125, 199, 199, 318, 1218, 63, 8370, 63, 460, 63, 6502, 8, 2914, 63, 981, 63, 1113, 12, 299, 2411, 63, 354, 12, 8966, 63, 2123, 304, 523, 2881, 275, 10267, 88, 13, 26840, 14, 3558, 2392, 14, 1308, 7, 523, 922, 63, 513, 275, 788, 751, 63, 17, 297, 283, 751, 63, 18, 297, 283, 751, 63, 19, 418, 523, 367, 922, 315, 922, 63, 513, 26, 272, 3434, 275, 299, 2411, 63, 354, 435, 14135, 435, 922, 272, 2505, 275, 299, 2411, 63, 981, 63, 1113, 14, 4208, 63, 4731, 8, 2914, 63, 354, 435, 922, 9, 272, 2933, 275, 9973, 14, 1462, 14, 981, 8, 3031, 29, 2473, 435, 2881, 12, 221, 4228, 2615, 63, 354, 29, 2914, 63, 354, 12, 221, 4228, 8966, 63, 2123, 29, 7811, 63, 2123, 9, 272, 2933, 14, 409, 63, 2473, 63, 460, 63, 2060, 8, 2473, 29, 2473, 12, 2505, 29, 2060, 9, 272, 2777, 275, 12651, 14, 1462, 14, 981, 8, 4597, 29, 2048, 12, 1768, 29, 2473, 9, 272, 870, 1867, 78, 2, 272, 870, 298, 6009, 26, 298, 435, 3434, 435, 2881, 272, 870, 298, 6139, 26, 298, 435, 2505, 272, 870, 298, 5433, 26, 298, 435, 2777, 14, 344, 272, 870, 22250, 10, 1400, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 523, 299, 2411, 63, 354, 4483, 275, 2125, 523, 299, 2411, 63, 3058, 63, 633, 263, 275, 2125, 523, 299, 2411, 63, 928, 63, 633, 63, 1160, 221, 275, 2125, 523, 299, 2411, 63, 354, 12, 8966, 63, 2123, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 275, 664, 63, 3020, 8, 17, 395, 664, 63, 3020, 8, 18, 395, 664, 63, 3020, 8, 19, 395, 664, 63, 3020, 8, 20, 9, 523, 340, 299, 2411, 63, 354, 436, 8966, 63, 2123, 26, 272, 299, 2411, 63, 981, 63, 1113, 275, 510, 6294, 63, 13921, 8, 2914, 63, 354, 12, 299, 2411, 63, 928, 63, 633, 63, 1160, 12, 299, 2411, 63, 3058, 63, 633, 9, 272, 299, 2411, 275, 299, 2411, 63, 981, 63, 1113, 14, 981, 63, 2914, 342, 272, 340, 299, 2411, 26, 489, 870, 283, 2914, 7143, 9512, 7, 489, 870, 298, 18186, 2606, 26, 298, 435, 299, 2411, 14, 8542, 63, 498, 489, 870, 298, 18186, 23580, 26, 298, 435, 299, 2411, 14, 4731, 489, 870, 298, 16520, 2812, 26, 298, 435, 299, 2411, 14, 354, 489, 870, 298, 16520, 11994, 26, 298, 435, 299, 2411, 14, 1802, 489, 870, 298, 16520, 7707, 2851, 5458, 26, 298, 435, 299, 2411, 14, 928, 63, 633, 63, 1160, 489, 870, 298, 16520, 17555, 2851, 26, 298, 435, 299, 2411, 14, 3058, 63, 633, 489, 870, 298, 16520, 11426, 26, 298, 435, 299, 2411, 14, 2123, 489, 870, 298, 16520, 11726, 461, 26, 298, 435, 620, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bc-python-tools/orpyste
orpyste/parse/walk.py
1
23403
#! /usr/bin/env python3 """ prototype:: date = 2017-07-31 This module contains a class ``WalkInAST`` to be subclassed so as to walk in the intermediate AST view made by the class ``parse.ast.AST``, and also to act regarding the context or the data met during the walk. info:: The class ``WalkInAST`` do some semantic analysis that had not been done by the class ``parse.ast.AST``. """ from collections import Hashable, OrderedDict from orpyste.parse.ast import * from orpyste.tools.ioview import IOView # ------------------------- # # -- FOR ERRORS TO RAISE -- # # ------------------------- # class PeufError(ValueError): """ prototype:: type = cls ; base class for errors specific to the ¨peuf specifications. """ pass # -------------------- # # -- SAFE CONSTANTS -- # # -------------------- # KEYVAL_TAGS = KEY_TAG, SEP_TAG, VAL_TAG \ = "key" , "sep" , "value" VAL_IN_LINE_TAG = "value_in_line" # -------------------------- # # -- SPECIAL DICTIONARIES -- # # -------------------------- # # The following code of the class ``MKOrderedDict`` comes directly from the # module ``mistool.python_use`` where it is maintained. class MKOrderedDict(): """ This class allows to work easily with multikeys ordered dictionaries. Here is a complete example of use where some ouputs have been hand formatted. pyterm:: >>> from orpyste.parse.walk import MKOrderedDict >>> onemkdict = MKOrderedDict() >>> onemkdict[(1, 2, 4)] = "1st value" >>> onemkdict["key"] = "2nd value" >>> onemkdict["key"] = "3rd value" >>> print(onemkdict) MKOrderedDict([ ((id=0, key=(1, 2, 4)), value='1st value'), ((id=0, key='key') , value='2nd value'), ((id=1, key='key') , value='3rd value') ]) >>> for val in onemkdict["key"]: ... print(k_id, val) ... 0 2nd value 1 3rd value >>> print(onemkdict.getitembyid(1, "key")) 3rd value >>> for (k_id, key), val in onemkdict.items(): ... print((k_id, key), "===>", val) ... (0, (1, 2, 4)) ===> 1st value (0, 'key') ===> 2nd value (1, 'key') ===> 3rd value >>> for key, val in onemkdict.items(noid=True): ... print(key, "===>", val) ... (1, 2, 4) ===> 1st value key ===> 2nd value key ===> 3rd value >>> "key" in onemkdict True >>> "kaaaay" in onemkdict False >>> onemkdict.setitembyid(0, "key", "New 2nd value") >>> print(onemkdict) MKOrderedDict([ ((id=0, key=(1, 2, 4)), value='1st value'), ((id=0, key='key') , value='New 2nd value'), ((id=1, key='key') , value='3rd value')]) """ def __init__(self): self._internaldict = OrderedDict() self._keyids = {} self._len = 0 def __setitem__(self, key, val): if not isinstance(key, Hashable): raise KeyError("key must be hashable") if key in self._keyids: self._keyids[key] += 1 else: self._keyids[key] = 0 self._internaldict[(self._keyids[key], key)] = val self._len += 1 def setitembyid(self, keyid, key, val): if (keyid, key) not in self._internaldict: self._len += 1 self._internaldict[(keyid, key)] = val def __getitem__(self, key, keyid = None): keyfound = False for (oneid, onekey), oneval in self._internaldict.items(): if key == onekey: keyfound = True yield oneid, oneval if not keyfound: raise KeyError("key not used in the MKOrderedDict") def getitembyid(self, keyid, key): for (oneid, onekey), oneval in self._internaldict.items(): if keyid == oneid and key == onekey: return oneval raise KeyError("key not used in the MKOrderedDict") def items(self, noid = False): for id_key, oneval in self._internaldict.items(): if noid: yield id_key[1], oneval else: yield id_key, oneval def __contains__(self, key): for (oneid, onekey), oneval in self._internaldict.items(): if key == onekey: return True return False def __len__(self): return self._len def __eq__(self, other): if not isinstance(other, MKOrderedDict): return False if self._internaldict.keys() != other._internaldict.keys(): return False for k, v in self._internaldict.items(): if v != other.getitembyid(*k): return False return True def __str__(self): text = repr(self) while "\n " in text: text = text.replace("\n ", "\n") text = text.replace("\n", "") return text def __repr__(self): text = ["MKOrderedDict(["] for (oneid, onekey), oneval in self._internaldict.items(): text.append( " (id={0}, key={1}, value={2}), ".format( oneid, repr(onekey), repr(oneval).replace("\n ", "\n ") ) ) if len(text) != 1: text[-1] = text[-1][:-2] text.append("])") text = "\n".join(text) return text # The following code of the class ``MKOrderedDict`` comes directly from the # module ``mistool.python_use`` where it is maintained. class RecuOrderedDict(OrderedDict): """ This subclass of ``collections.OrderedDict`` allows to use a list of hashable keys, or just a single hashable key. Here is a complete example of use where some ouputs have been hand formatted. pyterm:: >>> from orpyste.parse.walk import RecuOrderedDict >>> onerecudict = RecuOrderedDict() >>> onerecudict[[1, 2, 4]] = "1st value" >>> onerecudict[(1, 2, 4)] = "2nd value" >>> onerecudict["key"] = "3rd value" >>> print(onerecudict) RecuOrderedDict([ ( 1, RecuOrderedDict([ ( 2, RecuOrderedDict([ (4, '1st value') ]) ) ]) ), ( (1, 2, 4), '2nd value' ), ( 'key', '3rd value' ) ]) >>> [1, 2, 4] in onerecudict True >>> [2, 4] in onerecudict[1] True """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def __getitem__(self, keys): if isinstance(keys, Hashable): return super().__getitem__(keys) else: first, *others = keys if others: return self[first][others] else: return self[first] def __setitem__(self, keys, val): if isinstance(keys, Hashable): super().__setitem__(keys, val) else: first, *others = keys if first in self and others: self[first][others] = val else: if others: subdict = RecuOrderedDict() subdict[others] = val val = subdict self[first] = val def __contains__(self, keys): if isinstance(keys, Hashable): return super().__contains__(keys) else: first, *others = keys if first in self: if not others: return True subdict = self[first] if isinstance(subdict, OrderedDict): return others in subdict return False # ----------------------------------- # # -- DECORATOR(S) FOR THE LAZY MAN -- # # ----------------------------------- # def newcontent(meth): """ prototype:: see = WalkInAST type = decorator arg = method: meth ; one method of the class ``WalkInAST`` This decorator "indicates" that something has been found. """ def newmeth(self, *args, **kwargs): self._methodname = meth.__name__ self.add_extra() return meth(self, *args, **kwargs) return newmeth # ------------- # # -- WALKING -- # # ------------- # class WalkInAST(): """ prototype:: see = parse.ast.AST arg-attr = pathlib.Path, str: content ; see the documentation of ``parse.ast.AST`` arg-attr = str, dict: mode ; see the documentation of ``parse.ast.AST`` arg-attr = str: encoding = "utf-8" ; see the documentation of ``parse.ast.AST`` arg-attr = bool: build_asts = True ; **this variable is only useful for a content in a file.** ``build_asts = True`` indicates to analyse a file and to produce temporary files, whereas ``build_asts = False`` asks to use the temporary files (this is a way to store physically the partial analysis) arg-attr = bool: remove_asts = True ; **this variable is only useful for a content in a file.** ``remove_asts = True`` indicates to remove temporary files built to analyze a file, whereas ``remove_asts = False`` asks to keep the temporary files (this is a way to store physically the partial analysis) attr = orpyste.tools.ioview.IOView: walk_view ; this is the attribut to use if you want to store information during the walk. attr = str: last_mode ; this string is the mode of the very last block opened  attr = list: modes_stack ; this stack list contains the modes of the last blocks opened  attr = dict: metadata ; this is a dictionary sent when using ``for metadata in oneast: ...`` where ``oneast`` is an instance of ``parse.ast.AST``. This gives you all informations about the current piece of the AST. warning:: This class only implements the walking but she doesn't acheive any action. To do something, you have to subclass ``WalkInAST`` and to implement what you need in the following methods (see their documentations for more informations and also the class ``orpyste.data.Read`` for one real example of use). * ``start`` and ``end`` are methods called just before and after the walk. * ``open_comment`` and ``close_comment`` are called when a comment has to be opened or closed, whereas ``content_in_comment`` allows to add a content met inside a comment. * ``open_section`` and ``close_section`` are called when a section has to be opened or closed, whereas ``section_title`` is for managing the title of section. * ``open_block`` and ``close_block`` are methods called just before and after a block is opened or closed respectively. * ``add_keyval`` can add a key-separator-value data. * ``add_line`` allows to add a single verbatim line. """ AST = AST def __init__( self, content, mode, encoding = "utf-8", build_asts = True, remove_asts = True ): self.content = content self.mode = mode self.encoding = encoding self.build_asts = build_asts self.remove_asts = remove_asts self.builddone = False def build(self): # We build the AST view. self.ast = self.AST( mode = self.mode, content = self.content ) self.ast.build() if self.ast.view.mode == "list": self.walk_view = IOView(self.ast.view.mode) else: self.walk_view = IOView( mode = self.ast.view.mode, path = self.ast.view.datas.with_suffix(".walk") ) with self.walk_view: # -- START OF THE WALK -- # self.start() # We must keep all metadatas for fine tuning in the attribut ``self.metadata`` # that contains all the necessary informations. self.datashasbeenfound = False self.isfirstsection = True self.insection = False self._section_title = [] self.incomment = False self.indentlevel = -1 self.last_mode = "" self.modes_stack = [] self.names_stack = [] self.nb_empty_verbline = 0 self.kv_nbline = -1 lastkeyval = {} for self.metadata in self.ast: # --- IMPORTANT : UGLY DEBUG --- # # print("--- @@@ WALK @@@ ---", self.metadata,sep="\n");continue kind = self.metadata[KIND_TAG] self.nbline = self.metadata[NBLINE_TAG] # -- SECTION -- # if kind == "section": if self.metadata[OPENCLOSE] == OPEN: if self.isfirstsection \ and self.datashasbeenfound: raise PeufError( "datas found before the first section" ) self.insection = True self.datashasbeenfound = True self.isfirstsection = False self.open_section() else: titlesize = len(self._section_title) if titlesize == 0: raise PeufError( "empty title for a section" ) elif titlesize != 1: raise PeufError( "title for a section not upon a single line" ) if "\\" in self._section_title[0] \ or "/" in self._section_title[0]: raise PeufError( "title can't contain << \ >> or << / >>" ) self.section_title(self._section_title.pop(0)) self.insection = False self.close_section() # -- COMMENT -- # elif kind.startswith("comment-"): if self.metadata[OPENCLOSE] == OPEN: self.incomment = True # Verbatim content is verbatim !!!! if self.last_mode == VERBATIM: self._add_empty_verbline() self.open_comment(kind[8:]) else: self.incomment = False self.close_comment(kind[8:]) # -- COMMENT LINE OR TITLE OF A SECTION -- # elif kind == VERB_CONTENT_TAG: if self.insection: self._section_title.append(self.metadata[CONTENT_TAG]) else: self.content_in_comment(self.metadata[CONTENT_TAG]) # -- EMPTY LINE -- # elif kind == EMPTYLINE_TAG: if self.incomment: self.content_in_comment("") elif self.last_mode == VERBATIM: self.nb_empty_verbline += 1 # -- BLOCK -- # elif kind == BLOCK_TAG: # An opening block if self.metadata[OPENCLOSE] == OPEN: self.indentlevel += 1 self.last_mode = self.metadata[MODE_TAG] self.modes_stack.append(self.last_mode) name = self.metadata[GRPS_FOUND_TAG][NAME_TAG] self.names_stack.append(name) self.datashasbeenfound = True self.open_block(name) # For block with a content, we have to augment the value of the indentation. if self.last_mode != CONTAINER: self.indentlevel += 1 # We have to manage key-value modes fo which a value can be written over # several lines ! if self.last_mode.endswith(KEYVAL): lastkeyval = {} keysused = [] # A closing block else: if self.last_mode == VERBATIM: self.nb_empty_verbline = 0 name = self.names_stack.pop(-1) # Do we have a key-value couple ? if lastkeyval: self.add_keyval(lastkeyval) lastkeyval = {} keysused = [] self.indentlevel -= 1 # We have to take care of last comments in a block self.kv_nbline = float("inf") self.close_block(name) self.kv_nbline = -1 else: # Are we closing a block with a content ? if self.last_mode != CONTAINER: self.indentlevel -= 1 self.close_block(name) self.indentlevel -= 1 self.modes_stack.pop(-1) if self.modes_stack: self.last_mode = self.modes_stack[-1] else: self.last_mode = "" # -- MAGIC COMMENT -- # elif kind == MAGIC_COMMENT: if self.last_mode != VERBATIM: raise PeufError( "magic comment not used for a verbatim content" ) if self.metadata[OPENCLOSE] == OPEN: self._add_empty_verbline() self.add_magic_comment() # -- VERBATIM CONTENT -- # UTILE ?????? elif self.last_mode == VERBATIM: self._add_empty_verbline() self.add_line( self.metadata[CONTENT_TAG][VAL_IN_LINE_TAG] ) # -- KEY-VAL CONTENT -- # else: content = self.metadata[CONTENT_TAG] if VAL_IN_LINE_TAG in content: if not lastkeyval: raise PeufError( "missing first key, see line #{0}".format( self.metadata[NBLINE_TAG] ) ) lastkeyval[VAL_TAG] \ += " " + content[VAL_IN_LINE_TAG].strip() self.kv_nbline = self.metadata[NBLINE_TAG] else: if lastkeyval: self.add_keyval(lastkeyval) self.kv_nbline = self.metadata[NBLINE_TAG] key = content[KEY_TAG] if self.last_mode == KEYVAL and key in keysused: raise PeufError( "key already used, see line #{0}".format( self.metadata[NBLINE_TAG] ) ) keysused.append(key) lastkeyval = content # -- END OF THE WALK -- # self.end() self.builddone = True return self # -- START AND END OF THE WALK -- # def start(self): """ This method is called just before the walk starts. """ ... def end(self): """ This method is called just after the end of the walk. """ ... def remove_extras(self): self.ast.view.remove() self.walk_view.remove() # -- COMMENTS -- # def open_comment(self, kind): """ prototype:: arg = str: kind in ["singleline", "multilines", "multilines-singleline"] ; ``kind = "singleline"`` is for orpyste::``// ...``, ``kind = "multilines"`` is for orpyste::``/* ... */`` where the content contains at least one back return, and ``kind = "multilines-singleline"`` is for orpyste::``/* ... */`` which is all in a single line This method is for opening a comment. No content is given there (see the method ``content_in_comment``). """ ... def close_comment(self, kind): """ prototype:: arg = str: kind in ["singleline", "multilines", "multilines-singleline"] ; ``kind = "singleline"`` is for orpyste::``// ...``, ``kind = "multilines"`` is for orpyste::``/* ... */`` where the content contains at least one back return, and ``kind = "multilines-singleline"`` is for orpyste::``/* ... */`` which is all in a single line This method is for closing a comment. No content is given there (see the method ``content_in_comment``). """ ... def content_in_comment(self, line): """ prototype:: arg = str: line This method is for adding content inside a comment (see the methods ``open_comment`` and ``close_comment``). """ ... # -- SECTIONS -- # def open_section(self): """ This method is for opening a section. """ ... def close_section(self): """ This method is for closing a section. """ ... def section_title(self, title): """ This method manages the title of a section. """ ... # -- BLOCKS -- # def open_block(self, name): """ prototype:: arg = str: name This method is for opening a new block knowning its name. """ ... def close_block(self, name): """ This method is for closing a block knowning its name. """ ... # -- (MULTI)KEYVAL -- # def add_keyval(self, keyval): """ prototype:: arg = {"key": str, "sep": str, "value": str}: keyval This method is for adding a new key with its associated value and separator. All this informations are in the dictionary ``keyval``. """ ... # -- VERBATIM -- # # We have to take care of the last empty lines !!! def _add_empty_verbline(self): if self.nb_empty_verbline: self.nbline -= self.nb_empty_verbline + 1 for _ in range(self.nb_empty_verbline): self.nbline += 1 self.add_line("") self.nbline += 1 self.nb_empty_verbline = 0 def add_line(self, line): """ prototype:: arg = str: line This method is for adding verbatim content. """ ... def add_magic_comment(self): """ This method is for adding the magic comment used for empty lines at the end of verbatim contents. """ ... # -- CONTEXT MANAGER -- # def __enter__(self): # We have to always build asts if the content is a string ! if self.build_asts \ or not isinstance(self.content, str): self.build() return self def __exit__(self, type, value, traceback): if self.remove_asts: self.remove_extras()
gpl-3.0
[ 3168, 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 199, 16141, 447, 272, 1434, 275, 9708, 13, 1780, 13, 2192, 421, 199, 2765, 859, 3509, 282, 1021, 1124, 31491, 607, 11307, 1040, 370, 506, 1007, 28271, 880, 465, 370, 12778, 315, 199, 1589, 13197, 20788, 2455, 6326, 701, 314, 1021, 1124, 1122, 14, 1810, 14, 11307, 4542, 436, 2597, 370, 2454, 199, 1135, 1005, 316, 314, 1067, 503, 314, 666, 7647, 5309, 314, 12778, 14, 421, 199, 815, 447, 272, 710, 1021, 1124, 31491, 607, 11307, 1040, 886, 2005, 32451, 11284, 626, 10530, 440, 2757, 4224, 272, 701, 314, 1021, 1124, 1122, 14, 1810, 14, 11307, 4345, 199, 624, 199, 199, 504, 5055, 492, 16101, 461, 12, 8773, 199, 199, 504, 503, 15983, 266, 14, 1122, 14, 1810, 492, 627, 199, 504, 503, 15983, 266, 14, 2537, 14, 2308, 1345, 492, 5004, 2768, 421, 199, 3, 10652, 9960, 327, 199, 3, 1553, 2381, 12539, 51, 2296, 31632, 4971, 1553, 327, 199, 3, 10652, 9960, 327, 199, 199, 533, 11379, 1286, 547, 8, 3393, 304, 272, 408, 199, 16141, 447, 272, 730, 275, 843, 8700, 1779, 1300, 1021, 367, 2552, 2488, 370, 314, 22405, 102, 321, 1286, 28754, 14, 272, 408, 272, 986, 421, 199, 3, 10652, 375, 327, 199, 3, 1553, 13950, 5100, 21803, 1441, 51, 1553, 327, 199, 3, 10652, 375, 327, 199, 199, 3078, 3204, 63, 17626, 275, 9301, 63, 6967, 12, 5795, 48, 63, 6967, 12, 8986, 63, 6967, 971, 288, 275, 298, 498, 2, 221, 2360, 298, 4127, 2, 221, 2360, 298, 585, 2, 199, 3204, 63, 568, 63, 6174, 63, 6967, 275, 298, 585, 63, 262, 63, 604, 2, 421, 199, 3, 10652, 9460, 327, 199, 3, 1553, 8820, 577, 6196, 1075, 25244, 1553, 327, 199, 3, 10652, 9460, 327, 199, 199, 3, 710, 2569, 1233, 402, 314, 1021, 1124, 18379, 16882, 1040, 12477, 5370, 687, 314, 199, 3, 859, 1124, 77, 7133, 393, 14, 1548, 63, 1180, 1040, 2382, 652, 365, 26391, 14, 199, 199, 533, 603, 43, 16882, 837, 272, 408, 199, 2765, 1021, 6127, 370, 1736, 16174, 543, 3510, 1612, 7741, 11196, 14, 11842, 365, 199, 65, 4890, 2893, 402, 675, 2382, 2005, 312, 384, 14608, 1172, 2757, 4926, 7871, 14, 199, 199, 647, 5125, 447, 272, 1306, 687, 503, 15983, 266, 14, 1122, 14, 7757, 492, 603, 43, 16882, 272, 1306, 1373, 3880, 807, 275, 603, 43, 16882, 342, 272, 1306, 1373, 3880, 807, 7528, 17, 12, 499, 12, 841, 1874, 275, 298, 17, 270, 574, 2, 272, 1306, 1373, 3880, 807, 905, 498, 937, 275, 298, 18, 977, 574, 2, 272, 1306, 1373, 3880, 807, 905, 498, 937, 275, 298, 19, 6883, 574, 2, 272, 1306, 870, 8, 368, 3880, 807, 9, 272, 603, 43, 16882, 779, 267, 3666, 344, 29, 16, 12, 790, 2687, 17, 12, 499, 12, 841, 1826, 574, 534, 17, 270, 574, 659, 267, 3666, 344, 29, 16, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 18, 977, 574, 659, 267, 3666, 344, 29, 17, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 19, 6883, 574, 358, 272, 4794, 272, 1306, 367, 1139, 315, 1373, 3880, 807, 905, 498, 6229, 272, 2263, 258, 870, 8, 75, 63, 344, 12, 1139, 9, 272, 2263, 272, 378, 499, 977, 574, 272, 413, 650, 6883, 574, 272, 1306, 870, 8, 368, 3880, 807, 14, 6095, 991, 344, 8, 17, 12, 298, 498, 2237, 272, 650, 6883, 574, 272, 1306, 367, 334, 75, 63, 344, 12, 790, 395, 1139, 315, 1373, 3880, 807, 14, 1744, 837, 272, 2263, 258, 870, 1332, 75, 63, 344, 12, 790, 395, 298, 5918, 7166, 1139, 9, 272, 2263, 272, 334, 16, 12, 334, 17, 12, 499, 12, 841, 430, 275, 19833, 413, 270, 574, 272, 334, 16, 12, 283, 498, 358, 275, 19833, 499, 977, 574, 272, 334, 17, 12, 283, 498, 358, 275, 19833, 650, 6883, 574, 272, 1306, 367, 790, 12, 1139, 315, 1373, 3880, 807, 14, 1744, 8, 889, 344, 29, 549, 304, 272, 2263, 258, 870, 8, 498, 12, 298, 5918, 7166, 1139, 9, 272, 2263, 272, 334, 17, 12, 499, 12, 841, 9, 275, 19833, 413, 270, 574, 272, 790, 275, 19833, 499, 977, 574, 272, 790, 275, 19833, 650, 6883, 574, 272, 1306, 298, 498, 2, 315, 1373, 3880, 807, 272, 715, 272, 1306, 298, 75, 11629, 1187, 2, 315, 1373, 3880, 807, 272, 756, 272, 1306, 1373, 3880, 807, 14, 8617, 991, 344, 8, 16, 12, 298, 498, 401, 298, 4665, 499, 977, 574, 531, 272, 1306, 870, 8, 368, 3880, 807, 9, 272, 603, 43, 16882, 779, 267, 3666, 344, 29, 16, 12, 790, 2687, 17, 12, 499, 12, 841, 1826, 574, 534, 17, 270, 574, 659, 267, 3666, 344, 29, 16, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 4665, 499, 977, 574, 659, 267, 3666, 344, 29, 17, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 19, 6883, 574, 2023, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 4672, 807, 275, 8773, 342, 267, 291, 423, 498, 1580, 755, 275, 1052, 267, 291, 423, 552, 3515, 275, 378, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 267, 340, 440, 1228, 8, 498, 12, 16101, 461, 304, 288, 746, 4067, 480, 498, 1471, 506, 21197, 531, 398, 340, 790, 315, 291, 423, 498, 1580, 26, 288, 291, 423, 498, 1580, 59, 498, 61, 847, 413, 398, 587, 26, 288, 291, 423, 498, 1580, 59, 498, 61, 275, 378, 398, 291, 423, 4672, 807, 7528, 277, 423, 498, 1580, 59, 498, 467, 790, 1874, 275, 1139, 398, 291, 423, 552, 847, 413, 339, 347, 542, 4484, 991, 344, 8, 277, 12, 790, 344, 12, 790, 12, 1139, 304, 267, 340, 334, 498, 344, 12, 790, 9, 440, 315, 291, 423, 4672, 807, 26, 288, 291, 423, 552, 847, 413, 398, 291, 423, 4672, 807, 7528, 498, 344, 12, 790, 1874, 275, 1139, 339, 347, 636, 6095, 721, 277, 12, 790, 12, 790, 344, 275, 488, 304, 267, 790, 4214, 275, 756, 398, 367, 334, 368, 344, 12, 1373, 498, 395, 1373, 637, 315, 291, 423, 4672 ]
[ 1182, 2647, 15, 1393, 15, 1813, 2366, 19, 199, 199, 624, 199, 16141, 447, 272, 1434, 275, 9708, 13, 1780, 13, 2192, 421, 199, 2765, 859, 3509, 282, 1021, 1124, 31491, 607, 11307, 1040, 370, 506, 1007, 28271, 880, 465, 370, 12778, 315, 199, 1589, 13197, 20788, 2455, 6326, 701, 314, 1021, 1124, 1122, 14, 1810, 14, 11307, 4542, 436, 2597, 370, 2454, 199, 1135, 1005, 316, 314, 1067, 503, 314, 666, 7647, 5309, 314, 12778, 14, 421, 199, 815, 447, 272, 710, 1021, 1124, 31491, 607, 11307, 1040, 886, 2005, 32451, 11284, 626, 10530, 440, 2757, 4224, 272, 701, 314, 1021, 1124, 1122, 14, 1810, 14, 11307, 4345, 199, 624, 199, 199, 504, 5055, 492, 16101, 461, 12, 8773, 199, 199, 504, 503, 15983, 266, 14, 1122, 14, 1810, 492, 627, 199, 504, 503, 15983, 266, 14, 2537, 14, 2308, 1345, 492, 5004, 2768, 421, 199, 3, 10652, 9960, 327, 199, 3, 1553, 2381, 12539, 51, 2296, 31632, 4971, 1553, 327, 199, 3, 10652, 9960, 327, 199, 199, 533, 11379, 1286, 547, 8, 3393, 304, 272, 408, 199, 16141, 447, 272, 730, 275, 843, 8700, 1779, 1300, 1021, 367, 2552, 2488, 370, 314, 22405, 102, 321, 1286, 28754, 14, 272, 408, 272, 986, 421, 199, 3, 10652, 375, 327, 199, 3, 1553, 13950, 5100, 21803, 1441, 51, 1553, 327, 199, 3, 10652, 375, 327, 199, 199, 3078, 3204, 63, 17626, 275, 9301, 63, 6967, 12, 5795, 48, 63, 6967, 12, 8986, 63, 6967, 971, 288, 275, 298, 498, 2, 221, 2360, 298, 4127, 2, 221, 2360, 298, 585, 2, 199, 3204, 63, 568, 63, 6174, 63, 6967, 275, 298, 585, 63, 262, 63, 604, 2, 421, 199, 3, 10652, 9460, 327, 199, 3, 1553, 8820, 577, 6196, 1075, 25244, 1553, 327, 199, 3, 10652, 9460, 327, 199, 199, 3, 710, 2569, 1233, 402, 314, 1021, 1124, 18379, 16882, 1040, 12477, 5370, 687, 314, 199, 3, 859, 1124, 77, 7133, 393, 14, 1548, 63, 1180, 1040, 2382, 652, 365, 26391, 14, 199, 199, 533, 603, 43, 16882, 837, 272, 408, 199, 2765, 1021, 6127, 370, 1736, 16174, 543, 3510, 1612, 7741, 11196, 14, 11842, 365, 199, 65, 4890, 2893, 402, 675, 2382, 2005, 312, 384, 14608, 1172, 2757, 4926, 7871, 14, 199, 199, 647, 5125, 447, 272, 1306, 687, 503, 15983, 266, 14, 1122, 14, 7757, 492, 603, 43, 16882, 272, 1306, 1373, 3880, 807, 275, 603, 43, 16882, 342, 272, 1306, 1373, 3880, 807, 7528, 17, 12, 499, 12, 841, 1874, 275, 298, 17, 270, 574, 2, 272, 1306, 1373, 3880, 807, 905, 498, 937, 275, 298, 18, 977, 574, 2, 272, 1306, 1373, 3880, 807, 905, 498, 937, 275, 298, 19, 6883, 574, 2, 272, 1306, 870, 8, 368, 3880, 807, 9, 272, 603, 43, 16882, 779, 267, 3666, 344, 29, 16, 12, 790, 2687, 17, 12, 499, 12, 841, 1826, 574, 534, 17, 270, 574, 659, 267, 3666, 344, 29, 16, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 18, 977, 574, 659, 267, 3666, 344, 29, 17, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 19, 6883, 574, 358, 272, 4794, 272, 1306, 367, 1139, 315, 1373, 3880, 807, 905, 498, 6229, 272, 2263, 258, 870, 8, 75, 63, 344, 12, 1139, 9, 272, 2263, 272, 378, 499, 977, 574, 272, 413, 650, 6883, 574, 272, 1306, 870, 8, 368, 3880, 807, 14, 6095, 991, 344, 8, 17, 12, 298, 498, 2237, 272, 650, 6883, 574, 272, 1306, 367, 334, 75, 63, 344, 12, 790, 395, 1139, 315, 1373, 3880, 807, 14, 1744, 837, 272, 2263, 258, 870, 1332, 75, 63, 344, 12, 790, 395, 298, 5918, 7166, 1139, 9, 272, 2263, 272, 334, 16, 12, 334, 17, 12, 499, 12, 841, 430, 275, 19833, 413, 270, 574, 272, 334, 16, 12, 283, 498, 358, 275, 19833, 499, 977, 574, 272, 334, 17, 12, 283, 498, 358, 275, 19833, 650, 6883, 574, 272, 1306, 367, 790, 12, 1139, 315, 1373, 3880, 807, 14, 1744, 8, 889, 344, 29, 549, 304, 272, 2263, 258, 870, 8, 498, 12, 298, 5918, 7166, 1139, 9, 272, 2263, 272, 334, 17, 12, 499, 12, 841, 9, 275, 19833, 413, 270, 574, 272, 790, 275, 19833, 499, 977, 574, 272, 790, 275, 19833, 650, 6883, 574, 272, 1306, 298, 498, 2, 315, 1373, 3880, 807, 272, 715, 272, 1306, 298, 75, 11629, 1187, 2, 315, 1373, 3880, 807, 272, 756, 272, 1306, 1373, 3880, 807, 14, 8617, 991, 344, 8, 16, 12, 298, 498, 401, 298, 4665, 499, 977, 574, 531, 272, 1306, 870, 8, 368, 3880, 807, 9, 272, 603, 43, 16882, 779, 267, 3666, 344, 29, 16, 12, 790, 2687, 17, 12, 499, 12, 841, 1826, 574, 534, 17, 270, 574, 659, 267, 3666, 344, 29, 16, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 4665, 499, 977, 574, 659, 267, 3666, 344, 29, 17, 12, 790, 534, 498, 358, 259, 2360, 574, 534, 19, 6883, 574, 2023, 272, 408, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 4672, 807, 275, 8773, 342, 267, 291, 423, 498, 1580, 755, 275, 1052, 267, 291, 423, 552, 3515, 275, 378, 339, 347, 636, 8617, 721, 277, 12, 790, 12, 1139, 304, 267, 340, 440, 1228, 8, 498, 12, 16101, 461, 304, 288, 746, 4067, 480, 498, 1471, 506, 21197, 531, 398, 340, 790, 315, 291, 423, 498, 1580, 26, 288, 291, 423, 498, 1580, 59, 498, 61, 847, 413, 398, 587, 26, 288, 291, 423, 498, 1580, 59, 498, 61, 275, 378, 398, 291, 423, 4672, 807, 7528, 277, 423, 498, 1580, 59, 498, 467, 790, 1874, 275, 1139, 398, 291, 423, 552, 847, 413, 339, 347, 542, 4484, 991, 344, 8, 277, 12, 790, 344, 12, 790, 12, 1139, 304, 267, 340, 334, 498, 344, 12, 790, 9, 440, 315, 291, 423, 4672, 807, 26, 288, 291, 423, 552, 847, 413, 398, 291, 423, 4672, 807, 7528, 498, 344, 12, 790, 1874, 275, 1139, 339, 347, 636, 6095, 721, 277, 12, 790, 12, 790, 344, 275, 488, 304, 267, 790, 4214, 275, 756, 398, 367, 334, 368, 344, 12, 1373, 498, 395, 1373, 637, 315, 291, 423, 4672, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
elky/django
tests/prefetch_related/models.py
14
8132
import uuid from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models.query import ModelIterable, QuerySet from django.utils.functional import cached_property class Author(models.Model): name = models.CharField(max_length=50, unique=True) first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors') favorite_authors = models.ManyToManyField( 'self', through='FavoriteAuthors', symmetrical=False, related_name='favors_me') def __str__(self): return self.name class Meta: ordering = ['id'] class AuthorWithAge(Author): author = models.OneToOneField(Author, models.CASCADE, parent_link=True) age = models.IntegerField() class FavoriteAuthors(models.Model): author = models.ForeignKey(Author, models.CASCADE, to_field='name', related_name='i_like') likes_author = models.ForeignKey(Author, models.CASCADE, to_field='name', related_name='likes_me') class Meta: ordering = ['id'] class AuthorAddress(models.Model): author = models.ForeignKey(Author, models.CASCADE, to_field='name', related_name='addresses') address = models.TextField() class Meta: ordering = ['id'] def __str__(self): return self.address class Book(models.Model): title = models.CharField(max_length=255) authors = models.ManyToManyField(Author, related_name='books') def __str__(self): return self.title class Meta: ordering = ['id'] class BookWithYear(Book): book = models.OneToOneField(Book, models.CASCADE, parent_link=True) published_year = models.IntegerField() aged_authors = models.ManyToManyField( AuthorWithAge, related_name='books_with_year') class Bio(models.Model): author = models.OneToOneField( Author, models.CASCADE, primary_key=True, to_field='name', ) books = models.ManyToManyField(Book, blank=True) class Reader(models.Model): name = models.CharField(max_length=50) books_read = models.ManyToManyField(Book, related_name='read_by') def __str__(self): return self.name class Meta: ordering = ['id'] class BookReview(models.Model): book = models.ForeignKey(BookWithYear, models.CASCADE) notes = models.TextField(null=True, blank=True) # Models for default manager tests class Qualification(models.Model): name = models.CharField(max_length=10) class Meta: ordering = ['id'] class ModelIterableSubclass(ModelIterable): pass class TeacherQuerySet(QuerySet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._iterable_class = ModelIterableSubclass class TeacherManager(models.Manager): def get_queryset(self): return super().get_queryset().prefetch_related('qualifications') class Teacher(models.Model): name = models.CharField(max_length=50) qualifications = models.ManyToManyField(Qualification) objects = TeacherManager() objects_custom = TeacherQuerySet.as_manager() def __str__(self): return "%s (%s)" % (self.name, ", ".join(q.name for q in self.qualifications.all())) class Meta: ordering = ['id'] class Department(models.Model): name = models.CharField(max_length=50) teachers = models.ManyToManyField(Teacher) class Meta: ordering = ['id'] # GenericRelation/GenericForeignKey tests class TaggedItem(models.Model): tag = models.SlugField() content_type = models.ForeignKey( ContentType, models.CASCADE, related_name="taggeditem_set2", ) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') created_by_ct = models.ForeignKey( ContentType, models.SET_NULL, null=True, related_name='taggeditem_set3', ) created_by_fkey = models.PositiveIntegerField(null=True) created_by = GenericForeignKey('created_by_ct', 'created_by_fkey',) favorite_ct = models.ForeignKey( ContentType, models.SET_NULL, null=True, related_name='taggeditem_set4', ) favorite_fkey = models.CharField(max_length=64, null=True) favorite = GenericForeignKey('favorite_ct', 'favorite_fkey') def __str__(self): return self.tag class Meta: ordering = ['id'] class Bookmark(models.Model): url = models.URLField() tags = GenericRelation(TaggedItem, related_query_name='bookmarks') favorite_tags = GenericRelation(TaggedItem, content_type_field='favorite_ct', object_id_field='favorite_fkey', related_query_name='favorite_bookmarks') class Meta: ordering = ['id'] class Comment(models.Model): comment = models.TextField() # Content-object field content_type = models.ForeignKey(ContentType, models.CASCADE) object_pk = models.TextField() content_object = GenericForeignKey(ct_field="content_type", fk_field="object_pk") class Meta: ordering = ['id'] # Models for lookup ordering tests class House(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=255) owner = models.ForeignKey('Person', models.SET_NULL, null=True) main_room = models.OneToOneField('Room', models.SET_NULL, related_name='main_room_of', null=True) class Meta: ordering = ['id'] class Room(models.Model): name = models.CharField(max_length=50) house = models.ForeignKey(House, models.CASCADE, related_name='rooms') class Meta: ordering = ['id'] class Person(models.Model): name = models.CharField(max_length=50) houses = models.ManyToManyField(House, related_name='occupants') @property def primary_house(self): # Assume business logic forces every person to have at least one house. return sorted(self.houses.all(), key=lambda house: -house.rooms.count())[0] @property def all_houses(self): return list(self.houses.all()) @cached_property def cached_all_houses(self): return self.all_houses class Meta: ordering = ['id'] # Models for nullable FK tests class Employee(models.Model): name = models.CharField(max_length=50) boss = models.ForeignKey('self', models.SET_NULL, null=True, related_name='serfs') def __str__(self): return self.name class Meta: ordering = ['id'] # Ticket #19607 class LessonEntry(models.Model): name1 = models.CharField(max_length=200) name2 = models.CharField(max_length=200) def __str__(self): return "%s %s" % (self.name1, self.name2) class WordEntry(models.Model): lesson_entry = models.ForeignKey(LessonEntry, models.CASCADE) name = models.CharField(max_length=200) def __str__(self): return "%s (%s)" % (self.name, self.id) # Ticket #21410: Regression when related_name="+" class Author2(models.Model): name = models.CharField(max_length=50, unique=True) first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors+') favorite_books = models.ManyToManyField('Book', related_name='+') def __str__(self): return self.name class Meta: ordering = ['id'] # Models for many-to-many with UUID pk test: class Pet(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=20) people = models.ManyToManyField(Person, related_name='pets') class Flea(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) current_room = models.ForeignKey(Room, models.SET_NULL, related_name='fleas', null=True) pets_visited = models.ManyToManyField(Pet, related_name='fleas_hosted') people_visited = models.ManyToManyField(Person, related_name='fleas_hosted')
bsd-3-clause
[ 646, 5377, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 5822, 20852, 12, 18397, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 421, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 3747, 29, 549, 9, 272, 1642, 63, 2706, 275, 1709, 14, 3190, 360, 8696, 297, 1709, 14, 10855, 12, 4048, 63, 354, 534, 2246, 63, 521, 63, 8149, 358, 272, 17914, 1175, 63, 8149, 275, 1709, 14, 7624, 8, 267, 283, 277, 297, 4012, 534, 24335, 1175, 2817, 1384, 297, 30091, 29, 797, 12, 4048, 63, 354, 534, 30763, 1384, 63, 278, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 6529, 3007, 20480, 8, 5949, 304, 272, 4132, 275, 1709, 14, 14298, 8, 5949, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 272, 11437, 275, 1709, 14, 3901, 342, 421, 199, 533, 481, 12958, 1175, 2817, 1384, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 73, 63, 2930, 358, 272, 1212, 9246, 63, 2502, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 29572, 63, 278, 358, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 6529, 1476, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 7423, 358, 272, 2287, 275, 1709, 14, 6254, 342, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1562, 421, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 12, 4048, 63, 354, 534, 8858, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 8944, 3007, 15731, 8, 8696, 304, 272, 6719, 275, 1709, 14, 14298, 8, 8696, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 272, 3267, 63, 3403, 275, 1709, 14, 3901, 342, 272, 282, 3046, 63, 8149, 275, 1709, 14, 7624, 8, 267, 6529, 3007, 20480, 12, 4048, 63, 354, 534, 8858, 63, 1045, 63, 3403, 358, 421, 199, 533, 699, 2308, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 14298, 8, 267, 6529, 12, 267, 1709, 14, 10855, 12, 267, 5062, 63, 498, 29, 549, 12, 267, 370, 63, 698, 534, 354, 297, 272, 776, 272, 19040, 275, 1709, 14, 7624, 8, 8696, 12, 4596, 29, 549, 9, 421, 199, 533, 23099, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 19040, 63, 739, 275, 1709, 14, 7624, 8, 8696, 12, 4048, 63, 354, 534, 739, 63, 991, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 8944, 21000, 8, 992, 14, 1685, 304, 272, 6719, 275, 1709, 14, 3190, 8, 8696, 3007, 15731, 12, 1709, 14, 10855, 9, 272, 12681, 275, 1709, 14, 6254, 8, 2307, 29, 549, 12, 4596, 29, 549, 9, 421, 199, 3, 29941, 367, 849, 5256, 2295, 199, 199, 533, 19933, 7313, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 9, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 5822, 20852, 23636, 8, 1685, 20852, 304, 272, 986, 421, 199, 533, 5773, 19728, 13689, 8, 13689, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 423, 8147, 63, 533, 275, 5822, 20852, 23636, 421, 199, 533, 5773, 19728, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 1252, 362, 63, 7924, 1252, 15576, 63, 2407, 360, 537, 7313, 83, 358, 421, 199, 533, 5773, 19728, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 6420, 7313, 83, 275, 1709, 14, 7624, 8, 12621, 7313, 9, 339, 2251, 275, 5773, 19728, 2988, 342, 272, 2251, 63, 4229, 275, 5773, 19728, 13689, 14, 305, 63, 2609, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 4366, 83, 2924, 450, 334, 277, 14, 354, 12, 3872, 3680, 904, 8, 81, 14, 354, 367, 1894, 315, 291, 14, 537, 7313, 83, 14, 452, 4059, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 1487, 12493, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1565, 1225, 1192, 275, 1709, 14, 7624, 8, 6301, 19728, 9, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 3, 8307, 12617, 15, 9417, 3190, 2295, 199, 199, 533, 32121, 2081, 8, 992, 14, 1685, 304, 272, 1947, 275, 1709, 14, 17315, 342, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 267, 14501, 12, 267, 1709, 14, 10855, 12, 267, 4048, 63, 354, 628, 1450, 303, 328, 563, 63, 409, 18, 401, 272, 776, 272, 909, 63, 344, 275, 1709, 14, 8591, 342, 272, 1564, 63, 785, 275, 8307, 3190, 360, 1317, 63, 466, 297, 283, 785, 63, 344, 358, 272, 2737, 63, 991, 63, 319, 275, 1709, 14, 3190, 8, 267, 14501, 12, 267, 1709, 14, 3597, 63, 8084, 12, 267, 2973, 29, 549, 12, 267, 4048, 63, 354, 534, 1450 ]
[ 5377, 199, 199, 504, 1639, 14, 2828, 14, 10778, 14, 955, 492, 334, 272, 8307, 3190, 12, 8307, 12617, 12, 199, 9, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 697, 14, 992, 14, 1131, 492, 5822, 20852, 12, 18397, 199, 504, 1639, 14, 1208, 14, 15481, 492, 6328, 63, 1829, 421, 199, 533, 6529, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 12, 3747, 29, 549, 9, 272, 1642, 63, 2706, 275, 1709, 14, 3190, 360, 8696, 297, 1709, 14, 10855, 12, 4048, 63, 354, 534, 2246, 63, 521, 63, 8149, 358, 272, 17914, 1175, 63, 8149, 275, 1709, 14, 7624, 8, 267, 283, 277, 297, 4012, 534, 24335, 1175, 2817, 1384, 297, 30091, 29, 797, 12, 4048, 63, 354, 534, 30763, 1384, 63, 278, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 6529, 3007, 20480, 8, 5949, 304, 272, 4132, 275, 1709, 14, 14298, 8, 5949, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 272, 11437, 275, 1709, 14, 3901, 342, 421, 199, 533, 481, 12958, 1175, 2817, 1384, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 73, 63, 2930, 358, 272, 1212, 9246, 63, 2502, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 29572, 63, 278, 358, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 6529, 1476, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 3190, 8, 5949, 12, 1709, 14, 10855, 12, 370, 63, 698, 534, 354, 297, 4048, 63, 354, 534, 7423, 358, 272, 2287, 275, 1709, 14, 6254, 342, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1562, 421, 199, 533, 8944, 8, 992, 14, 1685, 304, 272, 2538, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 2299, 9, 272, 11462, 275, 1709, 14, 7624, 8, 5949, 12, 4048, 63, 354, 534, 8858, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 1213, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 8944, 3007, 15731, 8, 8696, 304, 272, 6719, 275, 1709, 14, 14298, 8, 8696, 12, 1709, 14, 10855, 12, 1676, 63, 1073, 29, 549, 9, 272, 3267, 63, 3403, 275, 1709, 14, 3901, 342, 272, 282, 3046, 63, 8149, 275, 1709, 14, 7624, 8, 267, 6529, 3007, 20480, 12, 4048, 63, 354, 534, 8858, 63, 1045, 63, 3403, 358, 421, 199, 533, 699, 2308, 8, 992, 14, 1685, 304, 272, 4132, 275, 1709, 14, 14298, 8, 267, 6529, 12, 267, 1709, 14, 10855, 12, 267, 5062, 63, 498, 29, 549, 12, 267, 370, 63, 698, 534, 354, 297, 272, 776, 272, 19040, 275, 1709, 14, 7624, 8, 8696, 12, 4596, 29, 549, 9, 421, 199, 533, 23099, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 19040, 63, 739, 275, 1709, 14, 7624, 8, 8696, 12, 4048, 63, 354, 534, 739, 63, 991, 358, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 354, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 8944, 21000, 8, 992, 14, 1685, 304, 272, 6719, 275, 1709, 14, 3190, 8, 8696, 3007, 15731, 12, 1709, 14, 10855, 9, 272, 12681, 275, 1709, 14, 6254, 8, 2307, 29, 549, 12, 4596, 29, 549, 9, 421, 199, 3, 29941, 367, 849, 5256, 2295, 199, 199, 533, 19933, 7313, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 709, 9, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 5822, 20852, 23636, 8, 1685, 20852, 304, 272, 986, 421, 199, 533, 5773, 19728, 13689, 8, 13689, 304, 272, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1613, 11027, 826, 9308, 589, 12, 1011, 958, 9, 267, 291, 423, 8147, 63, 533, 275, 5822, 20852, 23636, 421, 199, 533, 5773, 19728, 2988, 8, 992, 14, 2988, 304, 272, 347, 664, 63, 7924, 8, 277, 304, 267, 372, 1613, 1252, 362, 63, 7924, 1252, 15576, 63, 2407, 360, 537, 7313, 83, 358, 421, 199, 533, 5773, 19728, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 6420, 7313, 83, 275, 1709, 14, 7624, 8, 12621, 7313, 9, 339, 2251, 275, 5773, 19728, 2988, 342, 272, 2251, 63, 4229, 275, 5773, 19728, 13689, 14, 305, 63, 2609, 342, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2071, 83, 4366, 83, 2924, 450, 334, 277, 14, 354, 12, 3872, 3680, 904, 8, 81, 14, 354, 367, 1894, 315, 291, 14, 537, 7313, 83, 14, 452, 4059, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 533, 1487, 12493, 8, 992, 14, 1685, 304, 272, 536, 275, 1709, 14, 2183, 8, 988, 63, 1267, 29, 1400, 9, 272, 1565, 1225, 1192, 275, 1709, 14, 7624, 8, 6301, 19728, 9, 339, 1021, 6288, 26, 267, 7794, 275, 788, 344, 418, 421, 199, 3, 8307, 12617, 15, 9417, 3190, 2295, 199, 199, 533, 32121, 2081, 8, 992, 14, 1685, 304, 272, 1947, 275, 1709, 14, 17315, 342, 272, 1564, 63, 466, 275, 1709, 14, 3190, 8, 267, 14501, 12, 267, 1709, 14, 10855, 12, 267, 4048, 63, 354, 628, 1450, 303, 328, 563, 63, 409, 18, 401, 272, 776, 272, 909, 63, 344, 275, 1709, 14,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
openhatch/oh-mainline
vendor/packages/Jinja2/jinja2/testsuite/lexnparse.py
402
22314
# -*- coding: utf-8 -*- """ jinja2.testsuite.lexnparse ~~~~~~~~~~~~~~~~~~~~~~~~~~ All the unittests regarding lexing, parsing and syntax. :copyright: (c) 2010 by the Jinja Team. :license: BSD, see LICENSE for more details. """ import unittest from jinja2.testsuite import JinjaTestCase from jinja2 import Environment, Template, TemplateSyntaxError, \ UndefinedError, nodes from jinja2._compat import next, iteritems, text_type, PY2 from jinja2.lexer import Token, TokenStream, TOKEN_EOF, \ TOKEN_BLOCK_BEGIN, TOKEN_BLOCK_END env = Environment() # how does a string look like in jinja syntax? if PY2: def jinja_string_repr(string): return repr(string)[1:] else: jinja_string_repr = repr class TokenStreamTestCase(JinjaTestCase): test_tokens = [Token(1, TOKEN_BLOCK_BEGIN, ''), Token(2, TOKEN_BLOCK_END, ''), ] def test_simple(self): ts = TokenStream(self.test_tokens, "foo", "bar") assert ts.current.type is TOKEN_BLOCK_BEGIN assert bool(ts) assert not bool(ts.eos) next(ts) assert ts.current.type is TOKEN_BLOCK_END assert bool(ts) assert not bool(ts.eos) next(ts) assert ts.current.type is TOKEN_EOF assert not bool(ts) assert bool(ts.eos) def test_iter(self): token_types = [t.type for t in TokenStream(self.test_tokens, "foo", "bar")] assert token_types == ['block_begin', 'block_end', ] class LexerTestCase(JinjaTestCase): def test_raw1(self): tmpl = env.from_string('{% raw %}foo{% endraw %}|' '{%raw%}{{ bar }}|{% baz %}{% endraw %}') assert tmpl.render() == 'foo|{{ bar }}|{% baz %}' def test_raw2(self): tmpl = env.from_string('1 {%- raw -%} 2 {%- endraw -%} 3') assert tmpl.render() == '123' def test_balancing(self): env = Environment('{%', '%}', '${', '}') tmpl = env.from_string('''{% for item in seq %}${{'foo': item}|upper}{% endfor %}''') assert tmpl.render(seq=list(range(3))) == "{'FOO': 0}{'FOO': 1}{'FOO': 2}" def test_comments(self): env = Environment('<!--', '-->', '{', '}') tmpl = env.from_string('''\ <ul> <!--- for item in seq --> <li>{item}</li> <!--- endfor --> </ul>''') assert tmpl.render(seq=list(range(3))) == ("<ul>\n <li>0</li>\n " "<li>1</li>\n <li>2</li>\n</ul>") def test_string_escapes(self): for char in u'\0', u'\u2668', u'\xe4', u'\t', u'\r', u'\n': tmpl = env.from_string('{{ %s }}' % jinja_string_repr(char)) assert tmpl.render() == char assert env.from_string('{{ "\N{HOT SPRINGS}" }}').render() == u'\u2668' def test_bytefallback(self): from pprint import pformat tmpl = env.from_string(u'''{{ 'foo'|pprint }}|{{ 'bär'|pprint }}''') assert tmpl.render() == pformat('foo') + '|' + pformat(u'bär') def test_operators(self): from jinja2.lexer import operators for test, expect in iteritems(operators): if test in '([{}])': continue stream = env.lexer.tokenize('{{ %s }}' % test) next(stream) assert stream.current.type == expect def test_normalizing(self): for seq in '\r', '\r\n', '\n': env = Environment(newline_sequence=seq) tmpl = env.from_string('1\n2\r\n3\n4\n') result = tmpl.render() assert result.replace(seq, 'X') == '1X2X3X4' def test_trailing_newline(self): for keep in [True, False]: env = Environment(keep_trailing_newline=keep) for template,expected in [ ('', {}), ('no\nnewline', {}), ('with\nnewline\n', {False: 'with\nnewline'}), ('with\nseveral\n\n\n', {False: 'with\nseveral\n\n'}), ]: tmpl = env.from_string(template) expect = expected.get(keep, template) result = tmpl.render() assert result == expect, (keep, template, result, expect) class ParserTestCase(JinjaTestCase): def test_php_syntax(self): env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->') tmpl = env.from_string('''\ <!-- I'm a comment, I'm not interesting -->\ <? for item in seq -?> <?= item ?> <?- endfor ?>''') assert tmpl.render(seq=list(range(5))) == '01234' def test_erb_syntax(self): env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>') tmpl = env.from_string('''\ <%# I'm a comment, I'm not interesting %>\ <% for item in seq -%> <%= item %> <%- endfor %>''') assert tmpl.render(seq=list(range(5))) == '01234' def test_comment_syntax(self): env = Environment('<!--', '-->', '${', '}', '<!--#', '-->') tmpl = env.from_string('''\ <!--# I'm a comment, I'm not interesting -->\ <!-- for item in seq ---> ${item} <!--- endfor -->''') assert tmpl.render(seq=list(range(5))) == '01234' def test_balancing(self): tmpl = env.from_string('''{{{'foo':'bar'}.foo}}''') assert tmpl.render() == 'bar' def test_start_comment(self): tmpl = env.from_string('''{# foo comment and bar comment #} {% macro blub() %}foo{% endmacro %} {{ blub() }}''') assert tmpl.render().strip() == 'foo' def test_line_syntax(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%') tmpl = env.from_string('''\ <%# regular comment %> % for item in seq: ${item} % endfor''') assert [int(x.strip()) for x in tmpl.render(seq=list(range(5))).split()] == \ list(range(5)) env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##') tmpl = env.from_string('''\ <%# regular comment %> % for item in seq: ${item} ## the rest of the stuff % endfor''') assert [int(x.strip()) for x in tmpl.render(seq=list(range(5))).split()] == \ list(range(5)) def test_line_syntax_priority(self): # XXX: why is the whitespace there in front of the newline? env = Environment('{%', '%}', '${', '}', '/*', '*/', '##', '#') tmpl = env.from_string('''\ /* ignore me. I'm a multiline comment */ ## for item in seq: * ${item} # this is just extra stuff ## endfor''') assert tmpl.render(seq=[1, 2]).strip() == '* 1\n* 2' env = Environment('{%', '%}', '${', '}', '/*', '*/', '#', '##') tmpl = env.from_string('''\ /* ignore me. I'm a multiline comment */ # for item in seq: * ${item} ## this is just extra stuff ## extra stuff i just want to ignore # endfor''') assert tmpl.render(seq=[1, 2]).strip() == '* 1\n\n* 2' def test_error_messages(self): def assert_error(code, expected): try: Template(code) except TemplateSyntaxError as e: assert str(e) == expected, 'unexpected error message' else: assert False, 'that was supposed to be an error' assert_error('{% for item in seq %}...{% endif %}', "Encountered unknown tag 'endif'. Jinja was looking " "for the following tags: 'endfor' or 'else'. The " "innermost block that needs to be closed is 'for'.") assert_error('{% if foo %}{% for item in seq %}...{% endfor %}{% endfor %}', "Encountered unknown tag 'endfor'. Jinja was looking for " "the following tags: 'elif' or 'else' or 'endif'. The " "innermost block that needs to be closed is 'if'.") assert_error('{% if foo %}', "Unexpected end of template. Jinja was looking for the " "following tags: 'elif' or 'else' or 'endif'. The " "innermost block that needs to be closed is 'if'.") assert_error('{% for item in seq %}', "Unexpected end of template. Jinja was looking for the " "following tags: 'endfor' or 'else'. The innermost block " "that needs to be closed is 'for'.") assert_error('{% block foo-bar-baz %}', "Block names in Jinja have to be valid Python identifiers " "and may not contain hyphens, use an underscore instead.") assert_error('{% unknown_tag %}', "Encountered unknown tag 'unknown_tag'.") class SyntaxTestCase(JinjaTestCase): def test_call(self): env = Environment() env.globals['foo'] = lambda a, b, c, e, g: a + b + c + e + g tmpl = env.from_string("{{ foo('a', c='d', e='f', *['b'], **{'g': 'h'}) }}") assert tmpl.render() == 'abdfh' def test_slicing(self): tmpl = env.from_string('{{ [1, 2, 3][:] }}|{{ [1, 2, 3][::-1] }}') assert tmpl.render() == '[1, 2, 3]|[3, 2, 1]' def test_attr(self): tmpl = env.from_string("{{ foo.bar }}|{{ foo['bar'] }}") assert tmpl.render(foo={'bar': 42}) == '42|42' def test_subscript(self): tmpl = env.from_string("{{ foo[0] }}|{{ foo[-1] }}") assert tmpl.render(foo=[0, 1, 2]) == '0|2' def test_tuple(self): tmpl = env.from_string('{{ () }}|{{ (1,) }}|{{ (1, 2) }}') assert tmpl.render() == '()|(1,)|(1, 2)' def test_math(self): tmpl = env.from_string('{{ (1 + 1 * 2) - 3 / 2 }}|{{ 2**3 }}') assert tmpl.render() == '1.5|8' def test_div(self): tmpl = env.from_string('{{ 3 // 2 }}|{{ 3 / 2 }}|{{ 3 % 2 }}') assert tmpl.render() == '1|1.5|1' def test_unary(self): tmpl = env.from_string('{{ +3 }}|{{ -3 }}') assert tmpl.render() == '3|-3' def test_concat(self): tmpl = env.from_string("{{ [1, 2] ~ 'foo' }}") assert tmpl.render() == '[1, 2]foo' def test_compare(self): tmpl = env.from_string('{{ 1 > 0 }}|{{ 1 >= 1 }}|{{ 2 < 3 }}|' '{{ 2 == 2 }}|{{ 1 <= 1 }}') assert tmpl.render() == 'True|True|True|True|True' def test_inop(self): tmpl = env.from_string('{{ 1 in [1, 2, 3] }}|{{ 1 not in [1, 2, 3] }}') assert tmpl.render() == 'True|False' def test_literals(self): tmpl = env.from_string('{{ [] }}|{{ {} }}|{{ () }}') assert tmpl.render().lower() == '[]|{}|()' def test_bool(self): tmpl = env.from_string('{{ true and false }}|{{ false ' 'or true }}|{{ not false }}') assert tmpl.render() == 'False|True|True' def test_grouping(self): tmpl = env.from_string('{{ (true and false) or (false and true) and not false }}') assert tmpl.render() == 'False' def test_django_attr(self): tmpl = env.from_string('{{ [1, 2, 3].0 }}|{{ [[1]].0.0 }}') assert tmpl.render() == '1|1' def test_conditional_expression(self): tmpl = env.from_string('''{{ 0 if true else 1 }}''') assert tmpl.render() == '0' def test_short_conditional_expression(self): tmpl = env.from_string('<{{ 1 if false }}>') assert tmpl.render() == '<>' tmpl = env.from_string('<{{ (1 if false).bar }}>') self.assert_raises(UndefinedError, tmpl.render) def test_filter_priority(self): tmpl = env.from_string('{{ "foo"|upper + "bar"|upper }}') assert tmpl.render() == 'FOOBAR' def test_function_calls(self): tests = [ (True, '*foo, bar'), (True, '*foo, *bar'), (True, '*foo, bar=42'), (True, '**foo, *bar'), (True, '**foo, bar'), (False, 'foo, bar'), (False, 'foo, bar=42'), (False, 'foo, bar=23, *args'), (False, 'a, b=c, *d, **e'), (False, '*foo, **bar') ] for should_fail, sig in tests: if should_fail: self.assert_raises(TemplateSyntaxError, env.from_string, '{{ foo(%s) }}' % sig) else: env.from_string('foo(%s)' % sig) def test_tuple_expr(self): for tmpl in [ '{{ () }}', '{{ (1, 2) }}', '{{ (1, 2,) }}', '{{ 1, }}', '{{ 1, 2 }}', '{% for foo, bar in seq %}...{% endfor %}', '{% for x in foo, bar %}...{% endfor %}', '{% for x in foo, %}...{% endfor %}' ]: assert env.from_string(tmpl) def test_trailing_comma(self): tmpl = env.from_string('{{ (1, 2,) }}|{{ [1, 2,] }}|{{ {1: 2,} }}') assert tmpl.render().lower() == '(1, 2)|[1, 2]|{1: 2}' def test_block_end_name(self): env.from_string('{% block foo %}...{% endblock foo %}') self.assert_raises(TemplateSyntaxError, env.from_string, '{% block x %}{% endblock y %}') def test_constant_casing(self): for const in True, False, None: tmpl = env.from_string('{{ %s }}|{{ %s }}|{{ %s }}' % ( str(const), str(const).lower(), str(const).upper() )) assert tmpl.render() == '%s|%s|' % (const, const) def test_test_chaining(self): self.assert_raises(TemplateSyntaxError, env.from_string, '{{ foo is string is sequence }}') assert env.from_string('{{ 42 is string or 42 is number }}' ).render() == 'True' def test_string_concatenation(self): tmpl = env.from_string('{{ "foo" "bar" "baz" }}') assert tmpl.render() == 'foobarbaz' def test_notin(self): bar = range(100) tmpl = env.from_string('''{{ not 42 in bar }}''') assert tmpl.render(bar=bar) == text_type(not 42 in bar) def test_implicit_subscribed_tuple(self): class Foo(object): def __getitem__(self, x): return x t = env.from_string('{{ foo[1, 2] }}') assert t.render(foo=Foo()) == u'(1, 2)' def test_raw2(self): tmpl = env.from_string('{% raw %}{{ FOO }} and {% BAR %}{% endraw %}') assert tmpl.render() == '{{ FOO }} and {% BAR %}' def test_const(self): tmpl = env.from_string('{{ true }}|{{ false }}|{{ none }}|' '{{ none is defined }}|{{ missing is defined }}') assert tmpl.render() == 'True|False|None|True|False' def test_neg_filter_priority(self): node = env.parse('{{ -1|foo }}') assert isinstance(node.body[0].nodes[0], nodes.Filter) assert isinstance(node.body[0].nodes[0].node, nodes.Neg) def test_const_assign(self): constass1 = '''{% set true = 42 %}''' constass2 = '''{% for none in seq %}{% endfor %}''' for tmpl in constass1, constass2: self.assert_raises(TemplateSyntaxError, env.from_string, tmpl) def test_localset(self): tmpl = env.from_string('''{% set foo = 0 %}\ {% for item in [1, 2] %}{% set foo = 1 %}{% endfor %}\ {{ foo }}''') assert tmpl.render() == '0' def test_parse_unary(self): tmpl = env.from_string('{{ -foo["bar"] }}') assert tmpl.render(foo={'bar': 42}) == '-42' tmpl = env.from_string('{{ -foo["bar"]|abs }}') assert tmpl.render(foo={'bar': 42}) == '42' class LstripBlocksTestCase(JinjaTestCase): def test_lstrip(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {% if True %}\n {% endif %}''') assert tmpl.render() == "\n" def test_lstrip_trim(self): env = Environment(lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string(''' {% if True %}\n {% endif %}''') assert tmpl.render() == "" def test_no_lstrip(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {%+ if True %}\n {%+ endif %}''') assert tmpl.render() == " \n " def test_lstrip_endline(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' hello{% if True %}\n goodbye{% endif %}''') assert tmpl.render() == " hello\n goodbye" def test_lstrip_inline(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {% if True %}hello {% endif %}''') assert tmpl.render() == 'hello ' def test_lstrip_nested(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {% if True %}a {% if True %}b {% endif %}c {% endif %}''') assert tmpl.render() == 'a b c ' def test_lstrip_left_chars(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' abc {% if True %} hello{% endif %}''') assert tmpl.render() == ' abc \n hello' def test_lstrip_embeded_strings(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {% set x = " {% str %} " %}{{ x }}''') assert tmpl.render() == ' {% str %} ' def test_lstrip_preserve_leading_newlines(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string('''\n\n\n{% set hello = 1 %}''') assert tmpl.render() == '\n\n\n' def test_lstrip_comment(self): env = Environment(lstrip_blocks=True, trim_blocks=False) tmpl = env.from_string(''' {# if True #} hello {#endif#}''') assert tmpl.render() == '\nhello\n' def test_lstrip_angle_bracket_simple(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string(''' <% if True %>hello <% endif %>''') assert tmpl.render() == 'hello ' def test_lstrip_angle_bracket_comment(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string(''' <%# if True %>hello <%# endif %>''') assert tmpl.render() == 'hello ' def test_lstrip_angle_bracket(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <%# regular comment %> <% for item in seq %> ${item} ## the rest of the stuff <% endfor %>''') assert tmpl.render(seq=range(5)) == \ ''.join('%s\n' % x for x in range(5)) def test_lstrip_angle_bracket_compact(self): env = Environment('<%', '%>', '${', '}', '<%#', '%>', '%', '##', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <%#regular comment%> <%for item in seq%> ${item} ## the rest of the stuff <%endfor%>''') assert tmpl.render(seq=range(5)) == \ ''.join('%s\n' % x for x in range(5)) def test_php_syntax_with_manual(self): env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <!-- I'm a comment, I'm not interesting --> <? for item in seq -?> <?= item ?> <?- endfor ?>''') assert tmpl.render(seq=range(5)) == '01234' def test_php_syntax(self): env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <!-- I'm a comment, I'm not interesting --> <? for item in seq ?> <?= item ?> <? endfor ?>''') assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5)) def test_php_syntax_compact(self): env = Environment('<?', '?>', '<?=', '?>', '<!--', '-->', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <!-- I'm a comment, I'm not interesting --> <?for item in seq?> <?=item?> <?endfor?>''') assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5)) def test_erb_syntax(self): env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', lstrip_blocks=True, trim_blocks=True) #env.from_string('') #for n,r in env.lexer.rules.iteritems(): # print n #print env.lexer.rules['root'][0][0].pattern #print "'%s'" % tmpl.render(seq=range(5)) tmpl = env.from_string('''\ <%# I'm a comment, I'm not interesting %> <% for item in seq %> <%= item %> <% endfor %> ''') assert tmpl.render(seq=range(5)) == ''.join(' %s\n' % x for x in range(5)) def test_erb_syntax_with_manual(self): env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <%# I'm a comment, I'm not interesting %> <% for item in seq -%> <%= item %> <%- endfor %>''') assert tmpl.render(seq=range(5)) == '01234' def test_erb_syntax_no_lstrip(self): env = Environment('<%', '%>', '<%=', '%>', '<%#', '%>', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <%# I'm a comment, I'm not interesting %> <%+ for item in seq -%> <%= item %> <%- endfor %>''') assert tmpl.render(seq=range(5)) == ' 01234' def test_comment_syntax(self): env = Environment('<!--', '-->', '${', '}', '<!--#', '-->', lstrip_blocks=True, trim_blocks=True) tmpl = env.from_string('''\ <!--# I'm a comment, I'm not interesting -->\ <!-- for item in seq ---> ${item} <!--- endfor -->''') assert tmpl.render(seq=range(5)) == '01234' def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TokenStreamTestCase)) suite.addTest(unittest.makeSuite(LexerTestCase)) suite.addTest(unittest.makeSuite(ParserTestCase)) suite.addTest(unittest.makeSuite(SyntaxTestCase)) suite.addTest(unittest.makeSuite(LstripBlocksTestCase)) return suite
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 14239, 14, 3113, 78, 1122, 272, 18294, 4919, 1714, 339, 2900, 314, 2882, 83, 12602, 7103, 316, 12, 6057, 436, 6302, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 2882, 199, 199, 504, 10321, 18, 14, 14239, 492, 17300, 1746, 199, 199, 504, 10321, 18, 492, 9711, 12, 5458, 12, 17762, 12, 971, 1362, 25868, 547, 12, 3380, 199, 504, 10321, 18, 423, 5819, 492, 2163, 12, 10849, 12, 1318, 63, 466, 12, 7843, 18, 199, 504, 10321, 18, 14, 11729, 492, 8767, 12, 8767, 3296, 12, 18243, 63, 13178, 12, 971, 1362, 18243, 63, 8475, 63, 15947, 12, 18243, 63, 8475, 63, 3902, 199, 199, 1813, 275, 9711, 342, 421, 199, 3, 4212, 1630, 282, 1059, 3648, 2839, 315, 10321, 6302, 31, 199, 692, 7843, 18, 26, 272, 347, 10321, 63, 875, 63, 2722, 8, 875, 304, 267, 372, 4700, 8, 875, 2788, 17, 2938, 199, 2836, 26, 272, 10321, 63, 875, 63, 2722, 275, 4700, 421, 199, 533, 8767, 3296, 1746, 8, 42, 4135, 1746, 304, 272, 511, 63, 4504, 275, 359, 3264, 8, 17, 12, 18243, 63, 8475, 63, 15947, 12, 9929, 673, 8767, 8, 18, 12, 18243, 63, 8475, 63, 3902, 12, 9929, 2116, 1622, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 6714, 275, 8767, 3296, 8, 277, 14, 396, 63, 4504, 12, 298, 1421, 401, 298, 1700, 531, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 8475, 63, 15947, 267, 702, 2155, 8, 1086, 9, 267, 702, 440, 2155, 8, 1086, 14, 24909, 9, 267, 2163, 8, 1086, 9, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 8475, 63, 3902, 267, 702, 2155, 8, 1086, 9, 267, 702, 440, 2155, 8, 1086, 14, 24909, 9, 267, 2163, 8, 1086, 9, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 13178, 267, 702, 440, 2155, 8, 1086, 9, 267, 702, 2155, 8, 1086, 14, 24909, 9, 339, 347, 511, 63, 1661, 8, 277, 304, 267, 1526, 63, 1313, 275, 359, 84, 14, 466, 367, 307, 315, 8767, 3296, 8, 277, 14, 396, 63, 4504, 12, 298, 1421, 401, 298, 1700, 11323, 267, 702, 1526, 63, 1313, 508, 788, 1457, 63, 5037, 297, 283, 1457, 63, 500, 297, 1622, 421, 199, 533, 21125, 1746, 8, 42, 4135, 1746, 304, 339, 347, 511, 63, 1773, 17, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 24103, 3066, 3674, 1421, 3996, 1284, 1773, 3674, 5227, 3044, 12100, 1773, 5, 93, 3638, 4681, 3586, 92, 3996, 15507, 12760, 755, 1284, 1773, 259, 31246, 267, 702, 9675, 14, 3352, 342, 508, 283, 1421, 92, 3638, 4681, 3586, 92, 3996, 15507, 25509, 339, 347, 511, 63, 1773, 18, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 360, 17, 221, 7749, 13, 3066, 446, 5, 93, 257, 499, 257, 7749, 13, 1284, 1773, 446, 5, 93, 257, 650, 358, 267, 702, 9675, 14, 3352, 342, 508, 283, 4288, 7, 339, 347, 511, 63, 30260, 8, 277, 304, 267, 2589, 275, 9711, 24103, 297, 1543, 7293, 20044, 297, 283, 12216, 267, 9675, 275, 2589, 14, 504, 63, 875, 10505, 3996, 367, 1242, 315, 5412, 288, 3674, 10545, 1445, 1421, 356, 1242, 22441, 4142, 93, 3996, 17273, 3674, 12310, 267, 702, 9675, 14, 3352, 8, 3610, 29, 513, 8, 1842, 8, 19, 1724, 508, 298, 1445, 13046, 356, 378, 93, 1445, 13046, 356, 413, 93, 1445, 13046, 356, 499, 7063, 339, 347, 511, 63, 6223, 8, 277, 304, 267, 2589, 275, 9711, 4827, 17722, 297, 2850, 4206, 5041, 297, 283, 12216, 267, 9675, 275, 2589, 14, 504, 63, 875, 10505, 60, 199, 28, 348, 30, 199, 11230, 2595, 367, 1242, 315, 5412, 10541, 523, 665, 317, 22266, 1053, 17890, 317, 30, 199, 11230, 2595, 17273, 10541, 199, 1108, 348, 30, 12310, 267, 702, 9675, 14, 3352, 8, 3610, 29, 513, 8, 1842, 8, 19, 1724, 508, 1689, 28, 348, 3072, 78, 221, 665, 317, 30, 16, 1108, 317, 3072, 78, 221, 298, 6163, 3886, 317, 30, 17, 1108, 317, 3072, 78, 221, 665, 317, 30, 18, 1108, 317, 3072, 78, 1108, 348, 9579, 339, 347, 511, 63, 875, 63, 3765, 83, 8, 277, 304, 267, 367, 1495, 315, 399, 1154, 16, 297, 399, 1154, 85, 9969, 24, 297, 399, 1154, 1845, 20, 297, 399, 1154, 84, 297, 399, 1154, 82, 297, 399, 1154, 78, 356, 288, 9675, 275, 2589, 14, 504, 63, 875, 18976, 450, 83, 16339, 450, 10321, 63, 875, 63, 2722, 8, 1560, 430, 288, 702, 9675, 14, 3352, 342, 508, 1495, 267, 702, 2589, 14, 504, 63, 875, 18976, 1867, 46, 91, 40, 1387, 428, 3311, 3881, 7063, 3586, 1959, 3352, 342, 508, 399, 1154, 85, 9969, 24, 7, 339, 347, 511, 63, 4414, 10538, 8, 277, 304, 267, 687, 10933, 492, 30843, 267, 9675, 275, 2589, 14, 504, 63, 875, 8, 85, 2344, 3638, 283, 1421, 17018, 15380, 3586, 92, 3638, 283, 66, 13733, 82, 17018, 15380, 3586, 12310, 267, 702, 9675, 14, 3352, 342, 508, 30843, 360, 1421, 358, 435, 24628, 435, 30843, 8, 85, 7, 66, 13733, 82, 358, 339, 347, 511, 63, 12688, 8, 277, 304, 267, 687, 10321, 18, 14, 11729, 492, 10211, 267, 367, 511, 12, 4282, 315, 10849, 8, 12688, 304, 288, 340, 511, 315, 283, 779, 2440, 566, 356, 355, 1980, 288, 2547, 275, 2589, 14, 11729, 14, 15246, 18976, 450, 83, 16339, 450, 511, 9, 288, 2163, 8, 1745, 9, 288, 702, 2547, 14, 1818, 14, 466, 508, 4282, 339, 347, 511, 63, 3302, 9147, 8, 277, 304, 267, 367, 5412, 315, 1557, 82, 297, 1557, 82, 60, 78, 297, 1557, 78, 356, 288, 2589, 275, 9711, 8, 12210, 63, 4041, 29, 3610, 9, 288, 9675, 275, 2589, 14, 504, 63, 875, 360, 17, 60, 78, 18, 60, 82, 60, 78, 19, 60, 78, 20, 60, 78, 358, 288, 754, 275, 9675, 14, 3352, 342, 288, 702, 754, 14, 1814, 8, 3610, 12, 283, 56, 358, 508, 283, 17 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 10321, 18, 14, 14239, 14, 3113, 78, 1122, 272, 18294, 4919, 1714, 339, 2900, 314, 2882, 83, 12602, 7103, 316, 12, 6057, 436, 6302, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 314, 17300, 11682, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 199, 646, 2882, 199, 199, 504, 10321, 18, 14, 14239, 492, 17300, 1746, 199, 199, 504, 10321, 18, 492, 9711, 12, 5458, 12, 17762, 12, 971, 1362, 25868, 547, 12, 3380, 199, 504, 10321, 18, 423, 5819, 492, 2163, 12, 10849, 12, 1318, 63, 466, 12, 7843, 18, 199, 504, 10321, 18, 14, 11729, 492, 8767, 12, 8767, 3296, 12, 18243, 63, 13178, 12, 971, 1362, 18243, 63, 8475, 63, 15947, 12, 18243, 63, 8475, 63, 3902, 199, 199, 1813, 275, 9711, 342, 421, 199, 3, 4212, 1630, 282, 1059, 3648, 2839, 315, 10321, 6302, 31, 199, 692, 7843, 18, 26, 272, 347, 10321, 63, 875, 63, 2722, 8, 875, 304, 267, 372, 4700, 8, 875, 2788, 17, 2938, 199, 2836, 26, 272, 10321, 63, 875, 63, 2722, 275, 4700, 421, 199, 533, 8767, 3296, 1746, 8, 42, 4135, 1746, 304, 272, 511, 63, 4504, 275, 359, 3264, 8, 17, 12, 18243, 63, 8475, 63, 15947, 12, 9929, 673, 8767, 8, 18, 12, 18243, 63, 8475, 63, 3902, 12, 9929, 2116, 1622, 339, 347, 511, 63, 4129, 8, 277, 304, 267, 6714, 275, 8767, 3296, 8, 277, 14, 396, 63, 4504, 12, 298, 1421, 401, 298, 1700, 531, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 8475, 63, 15947, 267, 702, 2155, 8, 1086, 9, 267, 702, 440, 2155, 8, 1086, 14, 24909, 9, 267, 2163, 8, 1086, 9, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 8475, 63, 3902, 267, 702, 2155, 8, 1086, 9, 267, 702, 440, 2155, 8, 1086, 14, 24909, 9, 267, 2163, 8, 1086, 9, 267, 702, 6714, 14, 1818, 14, 466, 365, 18243, 63, 13178, 267, 702, 440, 2155, 8, 1086, 9, 267, 702, 2155, 8, 1086, 14, 24909, 9, 339, 347, 511, 63, 1661, 8, 277, 304, 267, 1526, 63, 1313, 275, 359, 84, 14, 466, 367, 307, 315, 8767, 3296, 8, 277, 14, 396, 63, 4504, 12, 298, 1421, 401, 298, 1700, 11323, 267, 702, 1526, 63, 1313, 508, 788, 1457, 63, 5037, 297, 283, 1457, 63, 500, 297, 1622, 421, 199, 533, 21125, 1746, 8, 42, 4135, 1746, 304, 339, 347, 511, 63, 1773, 17, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 24103, 3066, 3674, 1421, 3996, 1284, 1773, 3674, 5227, 3044, 12100, 1773, 5, 93, 3638, 4681, 3586, 92, 3996, 15507, 12760, 755, 1284, 1773, 259, 31246, 267, 702, 9675, 14, 3352, 342, 508, 283, 1421, 92, 3638, 4681, 3586, 92, 3996, 15507, 25509, 339, 347, 511, 63, 1773, 18, 8, 277, 304, 267, 9675, 275, 2589, 14, 504, 63, 875, 360, 17, 221, 7749, 13, 3066, 446, 5, 93, 257, 499, 257, 7749, 13, 1284, 1773, 446, 5, 93, 257, 650, 358, 267, 702, 9675, 14, 3352, 342, 508, 283, 4288, 7, 339, 347, 511, 63, 30260, 8, 277, 304, 267, 2589, 275, 9711, 24103, 297, 1543, 7293, 20044, 297, 283, 12216, 267, 9675, 275, 2589, 14, 504, 63, 875, 10505, 3996, 367, 1242, 315, 5412, 288, 3674, 10545, 1445, 1421, 356, 1242, 22441, 4142, 93, 3996, 17273, 3674, 12310, 267, 702, 9675, 14, 3352, 8, 3610, 29, 513, 8, 1842, 8, 19, 1724, 508, 298, 1445, 13046, 356, 378, 93, 1445, 13046, 356, 413, 93, 1445, 13046, 356, 499, 7063, 339, 347, 511, 63, 6223, 8, 277, 304, 267, 2589, 275, 9711, 4827, 17722, 297, 2850, 4206, 5041, 297, 283, 12216, 267, 9675, 275, 2589, 14, 504, 63, 875, 10505, 60, 199, 28, 348, 30, 199, 11230, 2595, 367, 1242, 315, 5412, 10541, 523, 665, 317, 22266, 1053, 17890, 317, 30, 199, 11230, 2595, 17273, 10541, 199, 1108, 348, 30, 12310, 267, 702, 9675, 14, 3352, 8, 3610, 29, 513, 8, 1842, 8, 19, 1724, 508, 1689, 28, 348, 3072, 78, 221, 665, 317, 30, 16, 1108, 317, 3072, 78, 221, 298, 6163, 3886, 317, 30, 17, 1108, 317, 3072, 78, 221, 665, 317, 30, 18, 1108, 317, 3072, 78, 1108, 348, 9579, 339, 347, 511, 63, 875, 63, 3765, 83, 8, 277, 304, 267, 367, 1495, 315, 399, 1154, 16, 297, 399, 1154, 85, 9969, 24, 297, 399, 1154, 1845, 20, 297, 399, 1154, 84, 297, 399, 1154, 82, 297, 399, 1154, 78, 356, 288, 9675, 275, 2589, 14, 504, 63, 875, 18976, 450, 83, 16339, 450, 10321, 63, 875, 63, 2722, 8, 1560, 430, 288, 702, 9675, 14, 3352, 342, 508, 1495, 267, 702, 2589, 14, 504, 63, 875, 18976, 1867, 46, 91, 40, 1387, 428, 3311, 3881, 7063, 3586, 1959, 3352, 342, 508, 399, 1154, 85, 9969, 24, 7, 339, 347, 511, 63, 4414, 10538, 8, 277, 304, 267, 687, 10933, 492, 30843, 267, 9675, 275, 2589, 14, 504, 63, 875, 8, 85, 2344, 3638, 283, 1421, 17018, 15380, 3586, 92, 3638, 283, 66, 13733, 82, 17018, 15380, 3586, 12310, 267, 702, 9675, 14, 3352, 342, 508, 30843, 360, 1421, 358, 435, 24628, 435, 30843, 8, 85, 7, 66, 13733, 82, 358, 339, 347, 511, 63, 12688, 8, 277, 304, 267, 687, 10321, 18, 14, 11729, 492, 10211, 267, 367, 511, 12, 4282, 315, 10849, 8, 12688, 304, 288, 340, 511, 315, 283, 779, 2440, 566, 356, 355, 1980, 288, 2547, 275, 2589, 14, 11729, 14, 15246, 18976, 450, 83, 16339, 450, 511, 9, 288, 2163, 8, 1745, 9, 288, 702, 2547, 14, 1818, 14, 466, 508, 4282, 339, 347, 511, 63, 3302, 9147, 8, 277, 304, 267, 367, 5412, 315, 1557, 82, 297, 1557, 82, 60, 78, 297, 1557, 78, 356, 288, 2589, 275, 9711, 8, 12210, 63, 4041, 29, 3610, 9, 288, 9675, 275, 2589, 14, 504, 63, 875, 360, 17, 60, 78, 18, 60, 82, 60, 78, 19, 60, 78, 20, 60, 78, 358, 288, 754, 275, 9675, 14, 3352, 342, 288, 702, 754, 14, 1814, 8, 3610, 12, 283, 56, 358, 508, 283, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
omnirom/android_external_chromium-org
third_party/markupsafe/_constants.py
1535
4795
# -*- coding: utf-8 -*- """ markupsafe._constants ~~~~~~~~~~~~~~~~~~~~~ Highlevel implementation of the Markup string. :copyright: (c) 2010 by Armin Ronacher. :license: BSD, see LICENSE for more details. """ HTML_ENTITIES = { 'AElig': 198, 'Aacute': 193, 'Acirc': 194, 'Agrave': 192, 'Alpha': 913, 'Aring': 197, 'Atilde': 195, 'Auml': 196, 'Beta': 914, 'Ccedil': 199, 'Chi': 935, 'Dagger': 8225, 'Delta': 916, 'ETH': 208, 'Eacute': 201, 'Ecirc': 202, 'Egrave': 200, 'Epsilon': 917, 'Eta': 919, 'Euml': 203, 'Gamma': 915, 'Iacute': 205, 'Icirc': 206, 'Igrave': 204, 'Iota': 921, 'Iuml': 207, 'Kappa': 922, 'Lambda': 923, 'Mu': 924, 'Ntilde': 209, 'Nu': 925, 'OElig': 338, 'Oacute': 211, 'Ocirc': 212, 'Ograve': 210, 'Omega': 937, 'Omicron': 927, 'Oslash': 216, 'Otilde': 213, 'Ouml': 214, 'Phi': 934, 'Pi': 928, 'Prime': 8243, 'Psi': 936, 'Rho': 929, 'Scaron': 352, 'Sigma': 931, 'THORN': 222, 'Tau': 932, 'Theta': 920, 'Uacute': 218, 'Ucirc': 219, 'Ugrave': 217, 'Upsilon': 933, 'Uuml': 220, 'Xi': 926, 'Yacute': 221, 'Yuml': 376, 'Zeta': 918, 'aacute': 225, 'acirc': 226, 'acute': 180, 'aelig': 230, 'agrave': 224, 'alefsym': 8501, 'alpha': 945, 'amp': 38, 'and': 8743, 'ang': 8736, 'apos': 39, 'aring': 229, 'asymp': 8776, 'atilde': 227, 'auml': 228, 'bdquo': 8222, 'beta': 946, 'brvbar': 166, 'bull': 8226, 'cap': 8745, 'ccedil': 231, 'cedil': 184, 'cent': 162, 'chi': 967, 'circ': 710, 'clubs': 9827, 'cong': 8773, 'copy': 169, 'crarr': 8629, 'cup': 8746, 'curren': 164, 'dArr': 8659, 'dagger': 8224, 'darr': 8595, 'deg': 176, 'delta': 948, 'diams': 9830, 'divide': 247, 'eacute': 233, 'ecirc': 234, 'egrave': 232, 'empty': 8709, 'emsp': 8195, 'ensp': 8194, 'epsilon': 949, 'equiv': 8801, 'eta': 951, 'eth': 240, 'euml': 235, 'euro': 8364, 'exist': 8707, 'fnof': 402, 'forall': 8704, 'frac12': 189, 'frac14': 188, 'frac34': 190, 'frasl': 8260, 'gamma': 947, 'ge': 8805, 'gt': 62, 'hArr': 8660, 'harr': 8596, 'hearts': 9829, 'hellip': 8230, 'iacute': 237, 'icirc': 238, 'iexcl': 161, 'igrave': 236, 'image': 8465, 'infin': 8734, 'int': 8747, 'iota': 953, 'iquest': 191, 'isin': 8712, 'iuml': 239, 'kappa': 954, 'lArr': 8656, 'lambda': 955, 'lang': 9001, 'laquo': 171, 'larr': 8592, 'lceil': 8968, 'ldquo': 8220, 'le': 8804, 'lfloor': 8970, 'lowast': 8727, 'loz': 9674, 'lrm': 8206, 'lsaquo': 8249, 'lsquo': 8216, 'lt': 60, 'macr': 175, 'mdash': 8212, 'micro': 181, 'middot': 183, 'minus': 8722, 'mu': 956, 'nabla': 8711, 'nbsp': 160, 'ndash': 8211, 'ne': 8800, 'ni': 8715, 'not': 172, 'notin': 8713, 'nsub': 8836, 'ntilde': 241, 'nu': 957, 'oacute': 243, 'ocirc': 244, 'oelig': 339, 'ograve': 242, 'oline': 8254, 'omega': 969, 'omicron': 959, 'oplus': 8853, 'or': 8744, 'ordf': 170, 'ordm': 186, 'oslash': 248, 'otilde': 245, 'otimes': 8855, 'ouml': 246, 'para': 182, 'part': 8706, 'permil': 8240, 'perp': 8869, 'phi': 966, 'pi': 960, 'piv': 982, 'plusmn': 177, 'pound': 163, 'prime': 8242, 'prod': 8719, 'prop': 8733, 'psi': 968, 'quot': 34, 'rArr': 8658, 'radic': 8730, 'rang': 9002, 'raquo': 187, 'rarr': 8594, 'rceil': 8969, 'rdquo': 8221, 'real': 8476, 'reg': 174, 'rfloor': 8971, 'rho': 961, 'rlm': 8207, 'rsaquo': 8250, 'rsquo': 8217, 'sbquo': 8218, 'scaron': 353, 'sdot': 8901, 'sect': 167, 'shy': 173, 'sigma': 963, 'sigmaf': 962, 'sim': 8764, 'spades': 9824, 'sub': 8834, 'sube': 8838, 'sum': 8721, 'sup': 8835, 'sup1': 185, 'sup2': 178, 'sup3': 179, 'supe': 8839, 'szlig': 223, 'tau': 964, 'there4': 8756, 'theta': 952, 'thetasym': 977, 'thinsp': 8201, 'thorn': 254, 'tilde': 732, 'times': 215, 'trade': 8482, 'uArr': 8657, 'uacute': 250, 'uarr': 8593, 'ucirc': 251, 'ugrave': 249, 'uml': 168, 'upsih': 978, 'upsilon': 965, 'uuml': 252, 'weierp': 8472, 'xi': 958, 'yacute': 253, 'yen': 165, 'yuml': 255, 'zeta': 950, 'zwj': 8205, 'zwnj': 8204 }
bsd-3-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 9189, 3489, 423, 5559, 272, 18294, 2878, 94, 339, 16332, 1896, 4514, 402, 314, 17504, 1059, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 421, 199, 4943, 63, 1309, 19144, 275, 469, 272, 283, 12500, 17506, 356, 413, 2905, 12, 272, 283, 33, 14696, 356, 413, 3129, 12, 272, 283, 33, 6092, 356, 413, 2635, 12, 272, 283, 33, 19612, 356, 13567, 12, 272, 283, 16192, 356, 1749, 969, 12, 272, 283, 1596, 316, 356, 413, 2576, 12, 272, 283, 33, 16488, 356, 413, 2720, 12, 272, 283, 33, 26297, 356, 32132, 12, 272, 283, 21732, 356, 1749, 1079, 12, 272, 283, 35, 27916, 356, 9013, 12, 272, 283, 29218, 356, 1749, 1276, 12, 272, 283, 36, 16267, 356, 1695, 10932, 12, 272, 283, 13411, 356, 1749, 975, 12, 272, 283, 21265, 356, 29203, 12, 272, 283, 37, 14696, 356, 1784, 12, 272, 283, 37, 6092, 356, 19328, 12, 272, 283, 37, 19612, 356, 1926, 12, 272, 283, 14057, 8746, 356, 1749, 1196, 12, 272, 283, 37, 502, 356, 1749, 1167, 12, 272, 283, 37, 26297, 356, 29202, 12, 272, 283, 15091, 356, 1749, 1046, 12, 272, 283, 41, 14696, 356, 24005, 12, 272, 283, 41, 6092, 356, 26761, 12, 272, 283, 41, 19612, 356, 14785, 12, 272, 283, 41, 12041, 356, 1749, 2025, 12, 272, 283, 41, 26297, 356, 31533, 12, 272, 283, 43, 15999, 356, 1749, 1081, 12, 272, 283, 21350, 356, 1749, 1789, 12, 272, 283, 16215, 356, 1749, 1194, 12, 272, 283, 46, 16488, 356, 499, 1643, 12, 272, 283, 21988, 356, 1749, 821, 12, 272, 283, 27588, 17506, 356, 650, 1703, 12, 272, 283, 47, 14696, 356, 30301, 12, 272, 283, 47, 6092, 356, 29532, 12, 272, 283, 47, 19612, 356, 26160, 12, 272, 283, 47, 29073, 356, 1749, 1401, 12, 272, 283, 47, 15003, 2641, 356, 1749, 1465, 12, 272, 283, 47, 7001, 356, 30630, 12, 272, 283, 47, 16488, 356, 499, 969, 12, 272, 283, 47, 26297, 356, 21237, 12, 272, 283, 5663, 73, 356, 1749, 1082, 12, 272, 283, 10542, 356, 1749, 1651, 12, 272, 283, 4562, 278, 356, 1695, 13440, 12, 272, 283, 48, 338, 356, 1749, 1344, 12, 272, 283, 50, 526, 356, 1749, 1398, 12, 272, 283, 51, 27627, 356, 650, 2528, 12, 272, 283, 23394, 356, 1749, 2192, 12, 272, 283, 2080, 32080, 356, 26485, 12, 272, 283, 52, 3844, 356, 1749, 708, 12, 272, 283, 2719, 1841, 356, 1749, 1165, 12, 272, 283, 53, 14696, 356, 32319, 12, 272, 283, 53, 6092, 356, 499, 1167, 12, 272, 283, 53, 19612, 356, 499, 1196, 12, 272, 283, 1721, 8746, 356, 1749, 1153, 12, 272, 283, 53, 26297, 356, 25647, 12, 272, 283, 14828, 356, 1749, 1479, 12, 272, 283, 57, 14696, 356, 499, 2025, 12, 272, 283, 57, 26297, 356, 650, 2114, 12, 272, 283, 25929, 356, 1749, 1085, 12, 272, 283, 65, 14696, 356, 28842, 12, 272, 283, 65, 6092, 356, 32584, 12, 272, 283, 14696, 356, 13576, 12, 272, 283, 3624, 17506, 356, 28700, 12, 272, 283, 643, 345, 432, 356, 18565, 12, 272, 283, 1895, 70, 3840, 356, 1695, 8216, 12, 272, 283, 4468, 356, 1749, 2322, 12, 272, 283, 5282, 356, 10448, 12, 272, 283, 460, 356, 1695, 21712, 12, 272, 283, 621, 356, 10513, 1344, 12, 272, 283, 439, 736, 356, 10551, 12, 272, 283, 9332, 356, 499, 1398, 12, 272, 283, 5660, 311, 356, 1695, 14626, 12, 272, 283, 2159, 76, 271, 356, 499, 1465, 12, 272, 283, 65, 26297, 356, 499, 1651, 12, 272, 283, 3691, 14209, 356, 1695, 9485, 12, 272, 283, 5683, 356, 1749, 2466, 12, 272, 283, 3289, 86, 1700, 356, 29923, 12, 272, 283, 66, 979, 356, 1695, 11085, 12, 272, 283, 2874, 356, 1695, 17007, 12, 272, 283, 67, 27916, 356, 499, 2192, 12, 272, 283, 27916, 356, 27631, 12, 272, 283, 2946, 356, 32729, 12, 272, 283, 13175, 356, 1749, 1822, 12, 272, 283, 6092, 356, 1520, 709, 12, 272, 283, 429, 30327, 356, 16096, 1465, 12, 272, 283, 388, 71, 356, 1695, 18507, 12, 272, 283, 1574, 356, 20680, 12, 272, 283, 1556, 5250, 356, 10300, 1398, 12, 272, 283, 17500, 356, 1695, 17718, 12, 272, 283, 895, 828, 356, 30380, 12, 272, 283, 68, 22011, 356, 10300, 1427, 12, 272, 283, 7406, 836, 356, 1695, 8731, 12, 272, 283, 4460, 82, 356, 1695, 16447, 12, 272, 283, 6458, 356, 27827, 12, 272, 283, 3136, 356, 1749, 2006, 12, 272, 283, 328, 19470, 356, 16096, 1216, 12, 272, 283, 16081, 356, 499, 2417, 12, 272, 283, 69, 14696, 356, 499, 1153, 12, 272, 283, 69, 6092, 356, 26569, 12, 272, 283, 69, 19612, 356, 499, 708, 12, 272, 283, 1667, 356, 10513, 1643, 12, 272, 283, 5633, 681, 356, 1695, 11874, 12, 272, 283, 287, 681, 356, 1695, 10860, 12, 272, 283, 15761, 356, 1749, 1887, 12, 272, 283, 20146, 356, 10523, 614, 12, 272, 283, 1841, 356, 1749, 2869, 12, 272, 283, 12391, 356, 21883, 12, 272, 283, 69, 26297, 356, 31071, 12, 272, 283, 27089, 356, 20582, 772, 12, 272, 283, 4494, 356, 10513, 1780, 12, 272, 283, 70, 889, 70, 356, 841, 996, 12, 272, 283, 509, 452, 356, 10513, 966, 12, 272, 283, 10865, 713, 356, 31446, 12, 272, 283, 10865, 1079, 356, 413, 1299, 12, 272, 283, 10865, 1082, 356, 29682, 12, 272, 283, 4391, 305, 76, 356, 1695, 13085, 12, 272, 283, 7325, 356, 1749, 2417, 12, 272, 283, 303, 356, 1695, 13027, 12, 272, 283, 3308, 356, 16202, 12, 272, 283, 72, 22011, 356, 10300, 2259, 12, 272, 283, 72, 5250, 356, 1695, 15112, 12, 272, 283, 426, 32611, 356, 16096, 1398, 12, 272, 283, 72, 16514, 356, 1695, 9687, 12, 272, 283, 73, 14696, 356, 499, 1401, 12, 272, 283, 530, 5958, 356, 27077, 12, 272, 283, 73, 476, 429, 356, 32372, 12, 272, 283, 528, 345, 432, 356, 499, 1344, 12, 272, 283, 1569, 356, 8264, 2182, 12, 272, 283, 262, 2408, 356, 10513, 1082, 12, 272 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 9189, 3489, 423, 5559, 272, 18294, 2878, 94, 339, 16332, 1896, 4514, 402, 314, 17504, 1059, 14, 339, 520, 7307, 26, 334, 67, 9, 7129, 701, 1952, 827, 32472, 19728, 14, 272, 520, 1682, 26, 6289, 12, 1937, 5113, 367, 1655, 2436, 14, 199, 624, 421, 199, 4943, 63, 1309, 19144, 275, 469, 272, 283, 12500, 17506, 356, 413, 2905, 12, 272, 283, 33, 14696, 356, 413, 3129, 12, 272, 283, 33, 6092, 356, 413, 2635, 12, 272, 283, 33, 19612, 356, 13567, 12, 272, 283, 16192, 356, 1749, 969, 12, 272, 283, 1596, 316, 356, 413, 2576, 12, 272, 283, 33, 16488, 356, 413, 2720, 12, 272, 283, 33, 26297, 356, 32132, 12, 272, 283, 21732, 356, 1749, 1079, 12, 272, 283, 35, 27916, 356, 9013, 12, 272, 283, 29218, 356, 1749, 1276, 12, 272, 283, 36, 16267, 356, 1695, 10932, 12, 272, 283, 13411, 356, 1749, 975, 12, 272, 283, 21265, 356, 29203, 12, 272, 283, 37, 14696, 356, 1784, 12, 272, 283, 37, 6092, 356, 19328, 12, 272, 283, 37, 19612, 356, 1926, 12, 272, 283, 14057, 8746, 356, 1749, 1196, 12, 272, 283, 37, 502, 356, 1749, 1167, 12, 272, 283, 37, 26297, 356, 29202, 12, 272, 283, 15091, 356, 1749, 1046, 12, 272, 283, 41, 14696, 356, 24005, 12, 272, 283, 41, 6092, 356, 26761, 12, 272, 283, 41, 19612, 356, 14785, 12, 272, 283, 41, 12041, 356, 1749, 2025, 12, 272, 283, 41, 26297, 356, 31533, 12, 272, 283, 43, 15999, 356, 1749, 1081, 12, 272, 283, 21350, 356, 1749, 1789, 12, 272, 283, 16215, 356, 1749, 1194, 12, 272, 283, 46, 16488, 356, 499, 1643, 12, 272, 283, 21988, 356, 1749, 821, 12, 272, 283, 27588, 17506, 356, 650, 1703, 12, 272, 283, 47, 14696, 356, 30301, 12, 272, 283, 47, 6092, 356, 29532, 12, 272, 283, 47, 19612, 356, 26160, 12, 272, 283, 47, 29073, 356, 1749, 1401, 12, 272, 283, 47, 15003, 2641, 356, 1749, 1465, 12, 272, 283, 47, 7001, 356, 30630, 12, 272, 283, 47, 16488, 356, 499, 969, 12, 272, 283, 47, 26297, 356, 21237, 12, 272, 283, 5663, 73, 356, 1749, 1082, 12, 272, 283, 10542, 356, 1749, 1651, 12, 272, 283, 4562, 278, 356, 1695, 13440, 12, 272, 283, 48, 338, 356, 1749, 1344, 12, 272, 283, 50, 526, 356, 1749, 1398, 12, 272, 283, 51, 27627, 356, 650, 2528, 12, 272, 283, 23394, 356, 1749, 2192, 12, 272, 283, 2080, 32080, 356, 26485, 12, 272, 283, 52, 3844, 356, 1749, 708, 12, 272, 283, 2719, 1841, 356, 1749, 1165, 12, 272, 283, 53, 14696, 356, 32319, 12, 272, 283, 53, 6092, 356, 499, 1167, 12, 272, 283, 53, 19612, 356, 499, 1196, 12, 272, 283, 1721, 8746, 356, 1749, 1153, 12, 272, 283, 53, 26297, 356, 25647, 12, 272, 283, 14828, 356, 1749, 1479, 12, 272, 283, 57, 14696, 356, 499, 2025, 12, 272, 283, 57, 26297, 356, 650, 2114, 12, 272, 283, 25929, 356, 1749, 1085, 12, 272, 283, 65, 14696, 356, 28842, 12, 272, 283, 65, 6092, 356, 32584, 12, 272, 283, 14696, 356, 13576, 12, 272, 283, 3624, 17506, 356, 28700, 12, 272, 283, 643, 345, 432, 356, 18565, 12, 272, 283, 1895, 70, 3840, 356, 1695, 8216, 12, 272, 283, 4468, 356, 1749, 2322, 12, 272, 283, 5282, 356, 10448, 12, 272, 283, 460, 356, 1695, 21712, 12, 272, 283, 621, 356, 10513, 1344, 12, 272, 283, 439, 736, 356, 10551, 12, 272, 283, 9332, 356, 499, 1398, 12, 272, 283, 5660, 311, 356, 1695, 14626, 12, 272, 283, 2159, 76, 271, 356, 499, 1465, 12, 272, 283, 65, 26297, 356, 499, 1651, 12, 272, 283, 3691, 14209, 356, 1695, 9485, 12, 272, 283, 5683, 356, 1749, 2466, 12, 272, 283, 3289, 86, 1700, 356, 29923, 12, 272, 283, 66, 979, 356, 1695, 11085, 12, 272, 283, 2874, 356, 1695, 17007, 12, 272, 283, 67, 27916, 356, 499, 2192, 12, 272, 283, 27916, 356, 27631, 12, 272, 283, 2946, 356, 32729, 12, 272, 283, 13175, 356, 1749, 1822, 12, 272, 283, 6092, 356, 1520, 709, 12, 272, 283, 429, 30327, 356, 16096, 1465, 12, 272, 283, 388, 71, 356, 1695, 18507, 12, 272, 283, 1574, 356, 20680, 12, 272, 283, 1556, 5250, 356, 10300, 1398, 12, 272, 283, 17500, 356, 1695, 17718, 12, 272, 283, 895, 828, 356, 30380, 12, 272, 283, 68, 22011, 356, 10300, 1427, 12, 272, 283, 7406, 836, 356, 1695, 8731, 12, 272, 283, 4460, 82, 356, 1695, 16447, 12, 272, 283, 6458, 356, 27827, 12, 272, 283, 3136, 356, 1749, 2006, 12, 272, 283, 328, 19470, 356, 16096, 1216, 12, 272, 283, 16081, 356, 499, 2417, 12, 272, 283, 69, 14696, 356, 499, 1153, 12, 272, 283, 69, 6092, 356, 26569, 12, 272, 283, 69, 19612, 356, 499, 708, 12, 272, 283, 1667, 356, 10513, 1643, 12, 272, 283, 5633, 681, 356, 1695, 11874, 12, 272, 283, 287, 681, 356, 1695, 10860, 12, 272, 283, 15761, 356, 1749, 1887, 12, 272, 283, 20146, 356, 10523, 614, 12, 272, 283, 1841, 356, 1749, 2869, 12, 272, 283, 12391, 356, 21883, 12, 272, 283, 69, 26297, 356, 31071, 12, 272, 283, 27089, 356, 20582, 772, 12, 272, 283, 4494, 356, 10513, 1780, 12, 272, 283, 70, 889, 70, 356, 841, 996, 12, 272, 283, 509, 452, 356, 10513, 966, 12, 272, 283, 10865, 713, 356, 31446, 12, 272, 283, 10865, 1079, 356, 413, 1299, 12, 272, 283, 10865, 1082, 356, 29682, 12, 272, 283, 4391, 305, 76, 356, 1695, 13085, 12, 272, 283, 7325, 356, 1749, 2417, 12, 272, 283, 303, 356, 1695, 13027, 12, 272, 283, 3308, 356, 16202, 12, 272, 283, 72, 22011, 356, 10300, 2259, 12, 272, 283, 72, 5250, 356, 1695, 15112, 12, 272, 283, 426, 32611, 356, 16096, 1398, 12, 272, 283, 72, 16514, 356, 1695, 9687, 12, 272, 283, 73, 14696, 356, 499, 1401, 12, 272, 283, 530, 5958, 356, 27077, 12, 272, 283, 73, 476, 429, 356, 32372, 12, 272, 283, 528, 345, 432, 356, 499, 1344, 12, 272, 283, 1569, 356, 8264, 2182, 12, 272, 283, 262, 2408, 356, 10513, 1082, 12, 272, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
maraoz/proofofexistence
pycoin/scripts/bitcoin_utils.py
3
4930
#!/usr/bin/env python import argparse import binascii import sys from pycoin import ecdsa, encoding from pycoin.ecdsa import secp256k1 def b2h(b): return binascii.hexlify(b).decode("utf8") def parse_as_number(s): try: return int(s) except ValueError: pass try: return int(s, 16) except ValueError: pass def parse_as_private_key(s): v = parse_as_number(s) if v and v < secp256k1._r: return v try: v = encoding.wif_to_secret_exponent(s) return v except encoding.EncodingError: pass def parse_as_public_pair(s): try: if s[:2] in (["02", "03", "04"]): return encoding.sec_to_public_pair(encoding.h2b(s)) except (encoding.EncodingError, binascii.Error): pass for c in ",/": if c in s: s0, s1 = s.split(c, 1) v0 = parse_as_number(s0) if v0: if s1 in ("even", "odd"): return ecdsa.public_pair_for_x(ecdsa.generator_secp256k1, v0, is_even=(s1=='even')) v1 = parse_as_number(s1) if v1: if not ecdsa.is_public_pair_valid(ecdsa.generator_secp256k1, (v0, v1)): sys.stderr.write("invalid (x, y) pair\n") sys.exit(1) return (v0, v1) def parse_as_address(s): try: return encoding.bitcoin_address_to_hash160_sec(s) except encoding.EncodingError: pass try: v = encoding.h2b(s) if len(v) == 20: return v except binascii.Error: pass def main(): parser = argparse.ArgumentParser(description="Bitcoin utilities.") parser.add_argument('-a', "--address", help='show as Bitcoin address', action='store_true') parser.add_argument('-1', "--hash160", help='show as hash 160', action='store_true') parser.add_argument('-v', "--verbose", help='dump all information available', action='store_true') parser.add_argument('-w', "--wif", help='show as Bitcoin WIF', action='store_true') parser.add_argument('-n', "--uncompressed", help='show in uncompressed form', action='store_true') parser.add_argument('item', help='a WIF, secret exponent, X/Y public pair, SEC (as hex), hash160 (as hex), Bitcoin address', nargs="+") args = parser.parse_args() for c in args.item: # figure out what it is: # - secret exponent # - WIF # - X/Y public key (base 10 or hex) # - sec # - hash160 # - Bitcoin address secret_exponent = parse_as_private_key(c) if secret_exponent: public_pair = ecdsa.public_pair_for_secret_exponent(secp256k1.generator_secp256k1, secret_exponent) print("secret exponent: %d" % secret_exponent) print(" hex: %x" % secret_exponent) print("WIF: %s" % encoding.secret_exponent_to_wif(secret_exponent, compressed=True)) print(" uncompressed: %s" % encoding.secret_exponent_to_wif(secret_exponent, compressed=False)) else: public_pair = parse_as_public_pair(c) if public_pair: bitcoin_address_uncompressed = encoding.public_pair_to_bitcoin_address(public_pair, compressed=False) bitcoin_address_compressed = encoding.public_pair_to_bitcoin_address(public_pair, compressed=True) print("public pair x: %d" % public_pair[0]) print("public pair y: %d" % public_pair[1]) print(" x as hex: %x" % public_pair[0]) print(" y as hex: %x" % public_pair[1]) print("y parity: %s" % "odd" if (public_pair[1] & 1) else "even") print("key pair as sec: %s" % b2h(encoding.public_pair_to_sec(public_pair, compressed=True))) s = b2h(encoding.public_pair_to_sec(public_pair, compressed=False)) print(" uncompressed: %s\\\n %s" % (s[:66], s[66:])) hash160 = encoding.public_pair_to_hash160_sec(public_pair, compressed=True) hash160_unc = encoding.public_pair_to_hash160_sec(public_pair, compressed=False) else: hash160 = parse_as_address(c) hash160_unc = None if not hash160: sys.stderr.write("can't decode input %s\n" % c) sys.exit(1) print("hash160: %s" % b2h(hash160)) if hash160_unc: print(" uncompressed: %s" % b2h(hash160_unc)) print("Bitcoin address: %s" % encoding.hash160_sec_to_bitcoin_address(hash160)) if hash160_unc: print(" uncompressed: %s" % encoding.hash160_sec_to_bitcoin_address(hash160_unc)) # - hash 160 (hex), Bitcoin address if __name__ == '__main__': main()
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 646, 7534, 202, 199, 646, 14755, 202, 199, 646, 984, 2999, 199, 504, 1134, 9061, 492, 7062, 24760, 12, 2644, 202, 199, 504, 1134, 9061, 14, 825, 24760, 492, 542, 1850, 3912, 75, 17, 2999, 199, 318, 330, 18, 72, 8, 66, 304, 1128, 372, 14755, 14, 20677, 8, 66, 680, 2708, 480, 1624, 24, 531, 2999, 199, 318, 2198, 63, 305, 63, 1955, 8, 83, 304, 1128, 862, 26, 1039, 372, 1109, 8, 83, 9, 1128, 871, 1722, 26, 1039, 986, 1128, 862, 26, 1039, 372, 1109, 8, 83, 12, 3193, 9, 1128, 871, 1722, 26, 1039, 986, 2999, 199, 318, 2198, 63, 305, 63, 4239, 63, 498, 8, 83, 304, 1128, 373, 275, 2198, 63, 305, 63, 1955, 8, 83, 9, 1128, 340, 373, 436, 373, 665, 542, 1850, 3912, 75, 17, 423, 82, 26, 1039, 372, 373, 1128, 862, 26, 1039, 373, 275, 2644, 14, 87, 692, 63, 475, 63, 4731, 63, 23475, 8, 83, 9, 1039, 372, 373, 1128, 871, 2644, 14, 7630, 547, 26, 1039, 986, 2999, 199, 318, 2198, 63, 305, 63, 3455, 63, 3852, 8, 83, 304, 1128, 862, 26, 1039, 340, 308, 1491, 18, 61, 315, 334, 905, 996, 401, 298, 1644, 401, 298, 966, 21473, 1675, 372, 2644, 14, 3321, 63, 475, 63, 3455, 63, 3852, 8, 2991, 14, 72, 18, 66, 8, 83, 430, 1128, 871, 334, 2991, 14, 7630, 547, 12, 14755, 14, 547, 304, 1039, 986, 1128, 367, 286, 315, 3872, 15, 582, 1039, 340, 286, 315, 308, 26, 1675, 308, 16, 12, 308, 17, 275, 308, 14, 1294, 8, 67, 12, 413, 9, 1675, 373, 16, 275, 2198, 63, 305, 63, 1955, 8, 83, 16, 9, 1675, 340, 373, 16, 26, 2628, 340, 308, 17, 315, 1689, 12056, 401, 298, 16216, 2349, 4906, 372, 7062, 24760, 14, 3455, 63, 3852, 63, 509, 63, 88, 8, 825, 24760, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 373, 16, 12, 365, 63, 12056, 2687, 83, 17, 6803, 12056, 1333, 2628, 373, 17, 275, 2198, 63, 305, 63, 1955, 8, 83, 17, 9, 2628, 340, 373, 17, 26, 4906, 340, 440, 7062, 24760, 14, 374, 63, 3455, 63, 3852, 63, 1078, 8, 825, 24760, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 334, 86, 16, 12, 373, 17, 2298, 8282, 984, 14, 3083, 14, 952, 480, 3197, 334, 88, 12, 612, 9, 4092, 60, 78, 531, 8282, 984, 14, 2224, 8, 17, 9, 4906, 372, 334, 86, 16, 12, 373, 17, 9, 2999, 199, 318, 2198, 63, 305, 63, 1562, 8, 83, 304, 1128, 862, 26, 1039, 372, 2644, 14, 22816, 63, 1562, 63, 475, 63, 2227, 8488, 63, 3321, 8, 83, 9, 1128, 871, 2644, 14, 7630, 547, 26, 1039, 986, 1128, 862, 26, 1039, 373, 275, 2644, 14, 72, 18, 66, 8, 83, 9, 1039, 340, 822, 8, 86, 9, 508, 3388, 26, 1675, 372, 373, 1128, 871, 14755, 14, 547, 26, 1039, 986, 2999, 199, 318, 2446, 837, 1128, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 4734, 9061, 15841, 2685, 2958, 1798, 14, 525, 63, 2094, 3654, 65, 297, 4320, 1562, 401, 1720, 534, 2384, 465, 21158, 2287, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 17, 297, 4320, 2227, 8488, 401, 1720, 534, 2384, 465, 2631, 21235, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 86, 297, 4320, 3832, 401, 1720, 534, 2724, 1006, 2556, 2808, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 87, 297, 4320, 87, 692, 401, 1720, 534, 2384, 465, 21158, 644, 4656, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 78, 297, 4320, 324, 10895, 401, 1720, 534, 2384, 315, 25904, 1824, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 360, 1053, 297, 1720, 534, 65, 644, 4656, 12, 7565, 16588, 12, 1323, 15, 57, 4575, 4092, 12, 24143, 334, 305, 6318, 395, 2631, 8488, 334, 305, 6318, 395, 21158, 2287, 297, 9237, 16368, 531, 1128, 1249, 275, 1798, 14, 1122, 63, 589, 342, 2958, 367, 286, 315, 1249, 14, 1053, 26, 1039, 327, 9658, 734, 4052, 652, 365, 26, 1039, 327, 221, 446, 7565, 16588, 1039, 327, 221, 446, 644, 4656, 1039, 327, 221, 446, 1323, 15, 57, 4575, 790, 334, 1095, 1616, 503, 6318, 9, 1039, 327, 221, 446, 6513, 1039, 327, 221, 446, 2631, 8488, 1039, 327, 221, 446, 21158, 2287, 1039, 7565, 63, 23475, 275, 2198, 63, 305, 63, 4239, 63, 498, 8, 67, 9, 1039, 340, 7565, 63, 23475, 26, 1675, 4575, 63, 3852, 275, 7062, 24760, 14, 3455, 63, 3852, 63, 509, 63, 4731, 63, 23475, 8, 261, 1850, 3912, 75, 17, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 7565, 63, 23475, 9, 1675, 870, 480, 4731, 16588, 26, 450, 68, 2, 450, 7565, 63, 23475, 9, 1675, 870, 480, 221, 6318, 26, 3698, 450, 88, 2, 450, 7565, 63, 23475, 9, 1675, 870, 480, 55, 4656, 26, 3777, 450, 83, 2, 450, 2644, 14, 4731, 63, 23475, 63, 475, 63, 87, 692, 8, 4731, 63, 23475, 12, 12335, 29, 549, 430, 1675, 870, 480, 221, 25904, 26, 221, 450, 83, 2, 450, 2644, 14, 4731, 63, 23475, 63, 475, 63, 87, 692, 8, 4731, 63, 23475, 12, 12335, 29, 797, 430, 1039, 587, 26, 1675, 4575, 63, 3852, 275, 2198, 63, 305, 63, 3455, 63, 3852, 8, 67, 9, 1039, 340, 4575, 63, 3852, 26, 1675, 27214, 63, 1562, 63, 324, 10895, 275, 2644, 14, 3455, 63, 3852, 63, 475, 63, 22816, 63, 1562, 8, 3455, 63, 3852, 12, 12335, 29, 797, 9, 1675, 27214, 63, 1562, 63, 10895, 275, 2644, 14, 3455, 63, 3852, 63, 475, 63, 22816, 63, 1562, 8, 3455, 63, 3852, 12, 12335, 29, 549, 9, 1675, 870, 480, 3455, 4092, 671, 26, 257, 450, 68, 2, 450, 4575, 63, 3852, 59, 16, 566, 1675, 870, 480, 3455, 4092, 612, 26, 257, 450, 68, 2, 450, 4575, 63, 3852, 59, 17, 566, 1675, 870, 480, 221, 671, 465, 6318, 26, 420 ]
[ 2647, 15, 1393, 15, 1813, 2366, 2999, 199, 646, 7534, 202, 199, 646, 14755, 202, 199, 646, 984, 2999, 199, 504, 1134, 9061, 492, 7062, 24760, 12, 2644, 202, 199, 504, 1134, 9061, 14, 825, 24760, 492, 542, 1850, 3912, 75, 17, 2999, 199, 318, 330, 18, 72, 8, 66, 304, 1128, 372, 14755, 14, 20677, 8, 66, 680, 2708, 480, 1624, 24, 531, 2999, 199, 318, 2198, 63, 305, 63, 1955, 8, 83, 304, 1128, 862, 26, 1039, 372, 1109, 8, 83, 9, 1128, 871, 1722, 26, 1039, 986, 1128, 862, 26, 1039, 372, 1109, 8, 83, 12, 3193, 9, 1128, 871, 1722, 26, 1039, 986, 2999, 199, 318, 2198, 63, 305, 63, 4239, 63, 498, 8, 83, 304, 1128, 373, 275, 2198, 63, 305, 63, 1955, 8, 83, 9, 1128, 340, 373, 436, 373, 665, 542, 1850, 3912, 75, 17, 423, 82, 26, 1039, 372, 373, 1128, 862, 26, 1039, 373, 275, 2644, 14, 87, 692, 63, 475, 63, 4731, 63, 23475, 8, 83, 9, 1039, 372, 373, 1128, 871, 2644, 14, 7630, 547, 26, 1039, 986, 2999, 199, 318, 2198, 63, 305, 63, 3455, 63, 3852, 8, 83, 304, 1128, 862, 26, 1039, 340, 308, 1491, 18, 61, 315, 334, 905, 996, 401, 298, 1644, 401, 298, 966, 21473, 1675, 372, 2644, 14, 3321, 63, 475, 63, 3455, 63, 3852, 8, 2991, 14, 72, 18, 66, 8, 83, 430, 1128, 871, 334, 2991, 14, 7630, 547, 12, 14755, 14, 547, 304, 1039, 986, 1128, 367, 286, 315, 3872, 15, 582, 1039, 340, 286, 315, 308, 26, 1675, 308, 16, 12, 308, 17, 275, 308, 14, 1294, 8, 67, 12, 413, 9, 1675, 373, 16, 275, 2198, 63, 305, 63, 1955, 8, 83, 16, 9, 1675, 340, 373, 16, 26, 2628, 340, 308, 17, 315, 1689, 12056, 401, 298, 16216, 2349, 4906, 372, 7062, 24760, 14, 3455, 63, 3852, 63, 509, 63, 88, 8, 825, 24760, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 373, 16, 12, 365, 63, 12056, 2687, 83, 17, 6803, 12056, 1333, 2628, 373, 17, 275, 2198, 63, 305, 63, 1955, 8, 83, 17, 9, 2628, 340, 373, 17, 26, 4906, 340, 440, 7062, 24760, 14, 374, 63, 3455, 63, 3852, 63, 1078, 8, 825, 24760, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 334, 86, 16, 12, 373, 17, 2298, 8282, 984, 14, 3083, 14, 952, 480, 3197, 334, 88, 12, 612, 9, 4092, 60, 78, 531, 8282, 984, 14, 2224, 8, 17, 9, 4906, 372, 334, 86, 16, 12, 373, 17, 9, 2999, 199, 318, 2198, 63, 305, 63, 1562, 8, 83, 304, 1128, 862, 26, 1039, 372, 2644, 14, 22816, 63, 1562, 63, 475, 63, 2227, 8488, 63, 3321, 8, 83, 9, 1128, 871, 2644, 14, 7630, 547, 26, 1039, 986, 1128, 862, 26, 1039, 373, 275, 2644, 14, 72, 18, 66, 8, 83, 9, 1039, 340, 822, 8, 86, 9, 508, 3388, 26, 1675, 372, 373, 1128, 871, 14755, 14, 547, 26, 1039, 986, 2999, 199, 318, 2446, 837, 1128, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 4734, 9061, 15841, 2685, 2958, 1798, 14, 525, 63, 2094, 3654, 65, 297, 4320, 1562, 401, 1720, 534, 2384, 465, 21158, 2287, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 17, 297, 4320, 2227, 8488, 401, 1720, 534, 2384, 465, 2631, 21235, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 86, 297, 4320, 3832, 401, 1720, 534, 2724, 1006, 2556, 2808, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 87, 297, 4320, 87, 692, 401, 1720, 534, 2384, 465, 21158, 644, 4656, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 3654, 78, 297, 4320, 324, 10895, 401, 1720, 534, 2384, 315, 25904, 1824, 297, 1595, 534, 1617, 63, 2052, 358, 1128, 1798, 14, 525, 63, 2094, 360, 1053, 297, 1720, 534, 65, 644, 4656, 12, 7565, 16588, 12, 1323, 15, 57, 4575, 4092, 12, 24143, 334, 305, 6318, 395, 2631, 8488, 334, 305, 6318, 395, 21158, 2287, 297, 9237, 16368, 531, 1128, 1249, 275, 1798, 14, 1122, 63, 589, 342, 2958, 367, 286, 315, 1249, 14, 1053, 26, 1039, 327, 9658, 734, 4052, 652, 365, 26, 1039, 327, 221, 446, 7565, 16588, 1039, 327, 221, 446, 644, 4656, 1039, 327, 221, 446, 1323, 15, 57, 4575, 790, 334, 1095, 1616, 503, 6318, 9, 1039, 327, 221, 446, 6513, 1039, 327, 221, 446, 2631, 8488, 1039, 327, 221, 446, 21158, 2287, 1039, 7565, 63, 23475, 275, 2198, 63, 305, 63, 4239, 63, 498, 8, 67, 9, 1039, 340, 7565, 63, 23475, 26, 1675, 4575, 63, 3852, 275, 7062, 24760, 14, 3455, 63, 3852, 63, 509, 63, 4731, 63, 23475, 8, 261, 1850, 3912, 75, 17, 14, 4679, 63, 261, 1850, 3912, 75, 17, 12, 7565, 63, 23475, 9, 1675, 870, 480, 4731, 16588, 26, 450, 68, 2, 450, 7565, 63, 23475, 9, 1675, 870, 480, 221, 6318, 26, 3698, 450, 88, 2, 450, 7565, 63, 23475, 9, 1675, 870, 480, 55, 4656, 26, 3777, 450, 83, 2, 450, 2644, 14, 4731, 63, 23475, 63, 475, 63, 87, 692, 8, 4731, 63, 23475, 12, 12335, 29, 549, 430, 1675, 870, 480, 221, 25904, 26, 221, 450, 83, 2, 450, 2644, 14, 4731, 63, 23475, 63, 475, 63, 87, 692, 8, 4731, 63, 23475, 12, 12335, 29, 797, 430, 1039, 587, 26, 1675, 4575, 63, 3852, 275, 2198, 63, 305, 63, 3455, 63, 3852, 8, 67, 9, 1039, 340, 4575, 63, 3852, 26, 1675, 27214, 63, 1562, 63, 324, 10895, 275, 2644, 14, 3455, 63, 3852, 63, 475, 63, 22816, 63, 1562, 8, 3455, 63, 3852, 12, 12335, 29, 797, 9, 1675, 27214, 63, 1562, 63, 10895, 275, 2644, 14, 3455, 63, 3852, 63, 475, 63, 22816, 63, 1562, 8, 3455, 63, 3852, 12, 12335, 29, 549, 9, 1675, 870, 480, 3455, 4092, 671, 26, 257, 450, 68, 2, 450, 4575, 63, 3852, 59, 16, 566, 1675, 870, 480, 3455, 4092, 612, 26, 257, 450, 68, 2, 450, 4575, 63, 3852, 59, 17, 566, 1675, 870, 480, 221, 671, 465, 6318, 26, 420, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
OpenTSDB/tcollector
collectors/etc/config.py
1
3086
#!/usr/bin/env python # This file is part of tcollector. # Copyright (C) 2010 The tcollector Authors. # # This program 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. 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 Lesser # General Public License for more details. You should have received a copy # of the GNU Lesser General Public License along with this program. If not, # see <http://www.gnu.org/licenses/>. # This 'onload' function will be called by tcollector when it starts up. # You can put any code here that you want to load inside the tcollector. # This also gives you a chance to override the options from the command # line or to add custom sanity checks on their values. # You can also use this to change the global tags that will be added to # every single data point. For instance if you have multiple different # pools or clusters of machines, you might wanna lookup the name of the # pool or cluster the current host belongs to and add it to the tags. # Throwing an exception here will cause the tcollector to die before it # starts doing any work. # Python files in this directory that don't have an "onload" function # will be imported by tcollector too, but no function will be called. # When this file executes, you can assume that its directory is in # sys.path, so you can import other Python modules from this directory # or its subdirectories. import os import sys def onload(options, tags): """Function called by tcollector when it starts up. Args: options: The options as returned by the OptionParser. tags: A dictionnary that maps tag names to tag values. """ pass def get_defaults(): """Configuration values to use as defaults in the code This is called by the OptionParser. """ default_cdir = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'collectors') defaults = { 'verbose': False, 'no_tcollector_stats': False, 'evictinterval': 6000, 'dedupinterval': 300, 'deduponlyzero': False, 'allowed_inactivity_time': 600, 'dryrun': False, 'maxtags': 8, 'http_password': False, 'reconnectinterval': 0, 'http_username': False, 'port': 4242, 'pidfile': '/var/run/tcollector.pid', 'http': False, 'http_api_path': "api/put", 'tags': [], 'remove_inactive_collectors': False, 'host': 'localhost', 'logfile': '/var/log/tcollector.log', 'cdir': default_cdir, 'ssl': False, 'stdin': False, 'daemonize': False, 'hosts': False, "monitoring_interface": None, "monitoring_port": 13280, "namespace_prefix": "", } return defaults
lgpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 961, 570, 365, 1777, 402, 307, 10946, 14, 199, 3, 1898, 334, 35, 9, 7129, 221, 710, 307, 10946, 6642, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 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, 334, 292, 2195, 199, 3, 945, 9, 1263, 2945, 1015, 14, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 199, 3, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 199, 3, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 199, 3, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 199, 3, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 283, 265, 912, 7, 805, 911, 506, 2797, 701, 307, 10946, 1380, 652, 9174, 1536, 14, 199, 3, 2047, 883, 5324, 1263, 1233, 2348, 626, 1265, 2934, 370, 2248, 6272, 314, 307, 10946, 14, 199, 3, 961, 2597, 10557, 1265, 282, 22044, 370, 4278, 314, 1511, 687, 314, 1414, 199, 3, 1004, 503, 370, 1050, 3537, 16740, 5920, 641, 3932, 1338, 14, 199, 3, 2047, 883, 2597, 675, 642, 370, 1570, 314, 2288, 3762, 626, 911, 506, 3483, 370, 199, 3, 4036, 2849, 666, 2376, 14, 221, 2104, 1256, 340, 1265, 1172, 3663, 3365, 199, 3, 20092, 503, 13865, 402, 20601, 12, 1265, 5594, 336, 1189, 65, 4237, 314, 536, 402, 314, 199, 3, 4203, 503, 4350, 314, 1453, 1591, 15006, 370, 436, 1050, 652, 370, 314, 3762, 14, 199, 3, 3868, 1143, 316, 376, 1919, 2348, 911, 7675, 314, 307, 10946, 370, 18833, 2544, 652, 199, 3, 9174, 9689, 1263, 1736, 14, 199, 3, 2018, 1584, 315, 642, 2082, 626, 2793, 1133, 1172, 376, 298, 265, 912, 2, 805, 199, 3, 911, 506, 8439, 701, 307, 10946, 4634, 12, 1325, 949, 805, 911, 506, 2797, 14, 199, 3, 3979, 642, 570, 24956, 12, 1265, 883, 5534, 626, 2399, 2082, 365, 315, 199, 3, 984, 14, 515, 12, 880, 1265, 883, 492, 1163, 2018, 4621, 687, 642, 2082, 199, 3, 503, 2399, 24799, 14, 199, 646, 747, 199, 646, 984, 199, 199, 318, 641, 912, 8, 1419, 12, 3762, 304, 272, 408, 3481, 2797, 701, 307, 10946, 1380, 652, 9174, 1536, 14, 339, 3033, 26, 267, 1511, 26, 710, 1511, 465, 2138, 701, 314, 13491, 14, 267, 3762, 26, 437, 487, 414, 78, 695, 626, 9033, 1947, 1561, 370, 1947, 1338, 14, 272, 408, 272, 986, 199, 199, 318, 664, 63, 4322, 837, 272, 408, 5688, 1338, 370, 675, 465, 4243, 315, 314, 1233, 398, 961, 365, 2797, 701, 314, 13491, 14, 272, 408, 339, 849, 63, 67, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 12884, 283, 10946, 83, 358, 339, 4243, 275, 469, 267, 283, 3832, 356, 756, 12, 267, 283, 889, 63, 84, 10946, 63, 3200, 356, 756, 12, 267, 283, 69, 433, 319, 4284, 356, 1227, 1493, 12, 267, 283, 770, 384, 4284, 356, 9601, 12, 267, 283, 770, 384, 2118, 4262, 356, 756, 12, 267, 283, 6541, 63, 262, 8240, 63, 521, 356, 11624, 12, 267, 283, 10481, 1065, 356, 756, 12, 267, 283, 391, 400, 7391, 356, 1695, 12, 267, 283, 1014, 63, 2060, 356, 756, 12, 267, 283, 29464, 4284, 356, 378, 12, 267, 283, 1014, 63, 2473, 356, 756, 12, 267, 283, 719, 356, 841, 13212, 12, 267, 283, 21957, 356, 1994, 1391, 15, 1065, 15, 84, 10946, 14, 3150, 297, 267, 283, 1014, 356, 756, 12, 267, 283, 1014, 63, 1246, 63, 515, 356, 298, 1246, 15, 524, 401, 267, 283, 2969, 356, 990, 267, 283, 2168, 63, 16856, 63, 10946, 83, 356, 756, 12, 267, 283, 1102, 356, 283, 5967, 297, 267, 283, 12804, 356, 1994, 1391, 15, 793, 15, 84, 10946, 14, 793, 297, 267, 283, 67, 694, 356, 849, 63, 67, 694, 12, 267, 283, 4266, 356, 756, 12, 267, 283, 6626, 356, 756, 12, 267, 283, 10824, 794, 356, 756, 12, 267, 283, 5146, 356, 756, 12, 267, 298, 20554, 63, 3266, 582, 488, 12, 267, 298, 20554, 63, 719, 582, 27207, 1257, 12, 267, 298, 3251, 63, 1861, 582, 4873, 272, 789, 339, 372, 4243, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 961, 570, 365, 1777, 402, 307, 10946, 14, 199, 3, 1898, 334, 35, 9, 7129, 221, 710, 307, 10946, 6642, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 652, 199, 3, 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, 334, 292, 2195, 199, 3, 945, 9, 1263, 2945, 1015, 14, 221, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 199, 3, 911, 506, 2997, 12, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 199, 3, 402, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 6401, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 221, 2047, 1077, 1172, 3086, 282, 1331, 199, 3, 402, 314, 1664, 6401, 1696, 1684, 844, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 199, 3, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 3, 961, 283, 265, 912, 7, 805, 911, 506, 2797, 701, 307, 10946, 1380, 652, 9174, 1536, 14, 199, 3, 2047, 883, 5324, 1263, 1233, 2348, 626, 1265, 2934, 370, 2248, 6272, 314, 307, 10946, 14, 199, 3, 961, 2597, 10557, 1265, 282, 22044, 370, 4278, 314, 1511, 687, 314, 1414, 199, 3, 1004, 503, 370, 1050, 3537, 16740, 5920, 641, 3932, 1338, 14, 199, 3, 2047, 883, 2597, 675, 642, 370, 1570, 314, 2288, 3762, 626, 911, 506, 3483, 370, 199, 3, 4036, 2849, 666, 2376, 14, 221, 2104, 1256, 340, 1265, 1172, 3663, 3365, 199, 3, 20092, 503, 13865, 402, 20601, 12, 1265, 5594, 336, 1189, 65, 4237, 314, 536, 402, 314, 199, 3, 4203, 503, 4350, 314, 1453, 1591, 15006, 370, 436, 1050, 652, 370, 314, 3762, 14, 199, 3, 3868, 1143, 316, 376, 1919, 2348, 911, 7675, 314, 307, 10946, 370, 18833, 2544, 652, 199, 3, 9174, 9689, 1263, 1736, 14, 199, 3, 2018, 1584, 315, 642, 2082, 626, 2793, 1133, 1172, 376, 298, 265, 912, 2, 805, 199, 3, 911, 506, 8439, 701, 307, 10946, 4634, 12, 1325, 949, 805, 911, 506, 2797, 14, 199, 3, 3979, 642, 570, 24956, 12, 1265, 883, 5534, 626, 2399, 2082, 365, 315, 199, 3, 984, 14, 515, 12, 880, 1265, 883, 492, 1163, 2018, 4621, 687, 642, 2082, 199, 3, 503, 2399, 24799, 14, 199, 646, 747, 199, 646, 984, 199, 199, 318, 641, 912, 8, 1419, 12, 3762, 304, 272, 408, 3481, 2797, 701, 307, 10946, 1380, 652, 9174, 1536, 14, 339, 3033, 26, 267, 1511, 26, 710, 1511, 465, 2138, 701, 314, 13491, 14, 267, 3762, 26, 437, 487, 414, 78, 695, 626, 9033, 1947, 1561, 370, 1947, 1338, 14, 272, 408, 272, 986, 199, 199, 318, 664, 63, 4322, 837, 272, 408, 5688, 1338, 370, 675, 465, 4243, 315, 314, 1233, 398, 961, 365, 2797, 701, 314, 13491, 14, 272, 408, 339, 849, 63, 67, 694, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 11091, 8, 1274, 14, 3020, 59, 16, 12884, 283, 10946, 83, 358, 339, 4243, 275, 469, 267, 283, 3832, 356, 756, 12, 267, 283, 889, 63, 84, 10946, 63, 3200, 356, 756, 12, 267, 283, 69, 433, 319, 4284, 356, 1227, 1493, 12, 267, 283, 770, 384, 4284, 356, 9601, 12, 267, 283, 770, 384, 2118, 4262, 356, 756, 12, 267, 283, 6541, 63, 262, 8240, 63, 521, 356, 11624, 12, 267, 283, 10481, 1065, 356, 756, 12, 267, 283, 391, 400, 7391, 356, 1695, 12, 267, 283, 1014, 63, 2060, 356, 756, 12, 267, 283, 29464, 4284, 356, 378, 12, 267, 283, 1014, 63, 2473, 356, 756, 12, 267, 283, 719, 356, 841, 13212, 12, 267, 283, 21957, 356, 1994, 1391, 15, 1065, 15, 84, 10946, 14, 3150, 297, 267, 283, 1014, 356, 756, 12, 267, 283, 1014, 63, 1246, 63, 515, 356, 298, 1246, 15, 524, 401, 267, 283, 2969, 356, 990, 267, 283, 2168, 63, 16856, 63, 10946, 83, 356, 756, 12, 267, 283, 1102, 356, 283, 5967, 297, 267, 283, 12804, 356, 1994, 1391, 15, 793, 15, 84, 10946, 14, 793, 297, 267, 283, 67, 694, 356, 849, 63, 67, 694, 12, 267, 283, 4266, 356, 756, 12, 267, 283, 6626, 356, 756, 12, 267, 283, 10824, 794, 356, 756, 12, 267, 283, 5146, 356, 756, 12, 267, 298, 20554, 63, 3266, 582, 488, 12, 267, 298, 20554, 63, 719, 582, 27207, 1257, 12, 267, 298, 3251, 63, 1861, 582, 4873, 272, 789, 339, 372, 4243, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
brokenjacobs/ansible
lib/ansible/modules/identity/ipa/ipa_group.py
71
9707
#!/usr/bin/python # -*- coding: utf-8 -*- # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: ipa_group author: Thomas Krahn (@Nosmoht) short_description: Manage FreeIPA group description: - Add, modify and delete group within IPA server options: cn: description: - Canonical name. - Can not be changed as it is the unique identifier. required: true aliases: ['name'] external: description: - Allow adding external non-IPA members from trusted domains. required: false gidnumber: description: - GID (use this option to set it manually). required: false group: description: - List of group names assigned to this group. - If an empty list is passed all groups will be removed from this group. - If option is omitted assigned groups will not be checked or changed. - Groups that are already assigned but not passed will be removed. nonposix: description: - Create as a non-POSIX group. required: false user: description: - List of user names assigned to this group. - If an empty list is passed all users will be removed from this group. - If option is omitted assigned users will not be checked or changed. - Users that are already assigned but not passed will be removed. state: description: - State to ensure required: false default: "present" choices: ["present", "absent"] ipa_port: description: Port of IPA server required: false default: 443 ipa_host: description: IP or hostname of IPA server required: false default: "ipa.example.com" ipa_user: description: Administrative account used on IPA server required: false default: "admin" ipa_pass: description: Password of administrative user required: true ipa_prot: description: Protocol used by IPA server required: false default: "https" choices: ["http", "https"] validate_certs: description: - This only applies if C(ipa_prot) is I(https). - If set to C(no), the SSL certificates will not be validated. - This should only set to C(no) used on personally controlled sites using self-signed certificates. required: false default: true version_added: "2.3" ''' EXAMPLES = ''' # Ensure group is present - ipa_group: name: oinstall gidnumber: 54321 state: present ipa_host: ipa.example.com ipa_user: admin ipa_pass: topsecret # Ensure that groups sysops and appops are assigned to ops but no other group - ipa_group: name: ops group: - sysops - appops ipa_host: ipa.example.com ipa_user: admin ipa_pass: topsecret # Ensure that users linus and larry are assign to the group, but no other user - ipa_group: name: sysops user: - linus - larry ipa_host: ipa.example.com ipa_user: admin ipa_pass: topsecret # Ensure group is absent - ipa_group: name: sysops state: absent ipa_host: ipa.example.com ipa_user: admin ipa_pass: topsecret ''' RETURN = ''' group: description: Group as returned by IPA API returned: always type: dict ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.ipa import IPAClient class GroupIPAClient(IPAClient): def __init__(self, module, host, port, protocol): super(GroupIPAClient, self).__init__(module, host, port, protocol) def group_find(self, name): return self._post_json(method='group_find', name=None, item={'all': True, 'cn': name}) def group_add(self, name, item): return self._post_json(method='group_add', name=name, item=item) def group_mod(self, name, item): return self._post_json(method='group_mod', name=name, item=item) def group_del(self, name): return self._post_json(method='group_del', name=name) def group_add_member(self, name, item): return self._post_json(method='group_add_member', name=name, item=item) def group_add_member_group(self, name, item): return self.group_add_member(name=name, item={'group': item}) def group_add_member_user(self, name, item): return self.group_add_member(name=name, item={'user': item}) def group_remove_member(self, name, item): return self._post_json(method='group_remove_member', name=name, item=item) def group_remove_member_group(self, name, item): return self.group_remove_member(name=name, item={'group': item}) def group_remove_member_user(self, name, item): return self.group_remove_member(name=name, item={'user': item}) def get_group_dict(description=None, external=None, gid=None, nonposix=None): group = {} if description is not None: group['description'] = description if external is not None: group['external'] = external if gid is not None: group['gidnumber'] = gid if nonposix is not None: group['nonposix'] = nonposix return group def get_group_diff(client, ipa_group, module_group): data = [] # With group_add attribute nonposix is passed, whereas with group_mod only posix can be passed. if 'nonposix' in module_group: # Only non-posix groups can be changed to posix if not module_group['nonposix'] and ipa_group.get('nonposix'): module_group['posix'] = True del module_group['nonposix'] return client.get_diff(ipa_data=ipa_group, module_data=module_group) def ensure(module, client): state = module.params['state'] name = module.params['name'] group = module.params['group'] user = module.params['user'] module_group = get_group_dict(description=module.params['description'], external=module.params['external'], gid=module.params['gidnumber'], nonposix=module.params['nonposix']) ipa_group = client.group_find(name=name) changed = False if state == 'present': if not ipa_group: changed = True if not module.check_mode: ipa_group = client.group_add(name, item=module_group) else: diff = get_group_diff(client, ipa_group, module_group) if len(diff) > 0: changed = True if not module.check_mode: data = {} for key in diff: data[key] = module_group.get(key) client.group_mod(name=name, item=data) if group is not None: changed = client.modify_if_diff(name, ipa_group.get('member_group', []), group, client.group_add_member_group, client.group_remove_member_group) or changed if user is not None: changed = client.modify_if_diff(name, ipa_group.get('member_user', []), user, client.group_add_member_user, client.group_remove_member_user) or changed else: if ipa_group: changed = True if not module.check_mode: client.group_del(name) return changed, client.group_find(name=name) def main(): module = AnsibleModule( argument_spec=dict( cn=dict(type='str', required=True, aliases=['name']), description=dict(type='str', required=False), external=dict(type='bool', required=False), gidnumber=dict(type='str', required=False, aliases=['gid']), group=dict(type='list', required=False), nonposix=dict(type='bool', required=False), state=dict(type='str', required=False, default='present', choices=['present', 'absent']), user=dict(type='list', required=False), ipa_prot=dict(type='str', required=False, default='https', choices=['http', 'https']), ipa_host=dict(type='str', required=False, default='ipa.example.com'), ipa_port=dict(type='int', required=False, default=443), ipa_user=dict(type='str', required=False, default='admin'), ipa_pass=dict(type='str', required=True, no_log=True), validate_certs=dict(type='bool', required=False, default=True), ), supports_check_mode=True, ) client = GroupIPAClient(module=module, host=module.params['ipa_host'], port=module.params['ipa_port'], protocol=module.params['ipa_prot']) try: client.login(username=module.params['ipa_user'], password=module.params['ipa_pass']) changed, group = ensure(module, client) module.exit_json(changed=changed, group=group) except Exception: e = get_exception() module.fail_json(msg=str(e)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18210, 63, 923, 199, 2502, 26, 27864, 1804, 345, 6164, 8593, 46, 736, 573, 517, 9, 199, 3612, 63, 1802, 26, 14944, 2868, 1772, 33, 1572, 199, 1802, 26, 199, 13, 2654, 12, 2811, 436, 3145, 1572, 4453, 3531, 33, 1654, 199, 1419, 26, 523, 20087, 26, 272, 1369, 26, 272, 446, 6855, 7174, 536, 14, 272, 446, 6855, 440, 506, 2896, 465, 652, 365, 314, 3747, 5148, 14, 272, 1415, 26, 2549, 272, 5481, 26, 788, 354, 418, 523, 5957, 26, 272, 1369, 26, 272, 446, 9812, 7791, 5957, 2222, 13, 1772, 33, 7556, 687, 19427, 14006, 14, 272, 1415, 26, 3055, 523, 15122, 1955, 26, 272, 1369, 26, 272, 446, 598, 998, 334, 1180, 642, 945, 370, 663, 652, 10250, 680, 272, 1415, 26, 3055, 523, 1572, 26, 272, 1369, 26, 272, 446, 3820, 402, 1572, 1561, 7943, 370, 642, 1572, 14, 272, 446, 982, 376, 2701, 769, 365, 3032, 1006, 4652, 911, 506, 4829, 687, 642, 1572, 14, 272, 446, 982, 945, 365, 11684, 7943, 4652, 911, 440, 506, 7923, 503, 2896, 14, 272, 446, 25031, 626, 787, 2575, 7943, 1325, 440, 3032, 911, 506, 4829, 14, 523, 2222, 9228, 26, 272, 1369, 26, 272, 446, 2790, 465, 282, 2222, 13, 16399, 1572, 14, 272, 1415, 26, 3055, 523, 922, 26, 272, 1369, 26, 272, 446, 3820, 402, 922, 1561, 7943, 370, 642, 1572, 14, 272, 446, 982, 376, 2701, 769, 365, 3032, 1006, 4390, 911, 506, 4829, 687, 642, 1572, 14, 272, 446, 982, 945, 365, 11684, 7943, 4390, 911, 440, 506, 7923, 503, 2896, 14, 272, 446, 20123, 626, 787, 2575, 7943, 1325, 440, 3032, 911, 506, 4829, 14, 523, 1174, 26, 272, 1369, 26, 272, 446, 8511, 370, 4868, 272, 1415, 26, 3055, 272, 849, 26, 298, 1881, 2, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 18210, 63, 719, 26, 272, 1369, 26, 10977, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 3531, 503, 6246, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 20014, 14, 2694, 14, 957, 2, 523, 18210, 63, 751, 26, 272, 1369, 26, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 2113, 2, 523, 18210, 63, 1529, 26, 272, 1369, 26, 13635, 402, 4628, 25124, 922, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 11557, 1202, 701, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 2859, 2, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 1572, 365, 3451, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 312, 3174, 272, 15122, 1955, 26, 959, 10657, 17, 272, 1174, 26, 3451, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 626, 4652, 984, 1483, 436, 1145, 1483, 787, 7943, 370, 4156, 1325, 949, 1163, 1572, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 4156, 272, 1572, 26, 272, 446, 984, 1483, 272, 446, 1145, 1483, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 626, 4390, 7403, 527, 436, 9087, 651, 787, 5090, 370, 314, 1572, 12, 1325, 949, 1163, 922, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 984, 1483, 272, 922, 26, 272, 446, 7403, 527, 272, 446, 9087, 651, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 1572, 365, 9552, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 984, 1483, 272, 1174, 26, 9552, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 2344, 199, 199, 9677, 275, 1449, 199, 923, 26, 523, 1369, 26, 5611, 465, 2138, 701, 3531, 33, 3261, 523, 2138, 26, 3544, 523, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 20014 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 18210, 63, 923, 199, 2502, 26, 27864, 1804, 345, 6164, 8593, 46, 736, 573, 517, 9, 199, 3612, 63, 1802, 26, 14944, 2868, 1772, 33, 1572, 199, 1802, 26, 199, 13, 2654, 12, 2811, 436, 3145, 1572, 4453, 3531, 33, 1654, 199, 1419, 26, 523, 20087, 26, 272, 1369, 26, 272, 446, 6855, 7174, 536, 14, 272, 446, 6855, 440, 506, 2896, 465, 652, 365, 314, 3747, 5148, 14, 272, 1415, 26, 2549, 272, 5481, 26, 788, 354, 418, 523, 5957, 26, 272, 1369, 26, 272, 446, 9812, 7791, 5957, 2222, 13, 1772, 33, 7556, 687, 19427, 14006, 14, 272, 1415, 26, 3055, 523, 15122, 1955, 26, 272, 1369, 26, 272, 446, 598, 998, 334, 1180, 642, 945, 370, 663, 652, 10250, 680, 272, 1415, 26, 3055, 523, 1572, 26, 272, 1369, 26, 272, 446, 3820, 402, 1572, 1561, 7943, 370, 642, 1572, 14, 272, 446, 982, 376, 2701, 769, 365, 3032, 1006, 4652, 911, 506, 4829, 687, 642, 1572, 14, 272, 446, 982, 945, 365, 11684, 7943, 4652, 911, 440, 506, 7923, 503, 2896, 14, 272, 446, 25031, 626, 787, 2575, 7943, 1325, 440, 3032, 911, 506, 4829, 14, 523, 2222, 9228, 26, 272, 1369, 26, 272, 446, 2790, 465, 282, 2222, 13, 16399, 1572, 14, 272, 1415, 26, 3055, 523, 922, 26, 272, 1369, 26, 272, 446, 3820, 402, 922, 1561, 7943, 370, 642, 1572, 14, 272, 446, 982, 376, 2701, 769, 365, 3032, 1006, 4390, 911, 506, 4829, 687, 642, 1572, 14, 272, 446, 982, 945, 365, 11684, 7943, 4390, 911, 440, 506, 7923, 503, 2896, 14, 272, 446, 20123, 626, 787, 2575, 7943, 1325, 440, 3032, 911, 506, 4829, 14, 523, 1174, 26, 272, 1369, 26, 272, 446, 8511, 370, 4868, 272, 1415, 26, 3055, 272, 849, 26, 298, 1881, 2, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 18210, 63, 719, 26, 272, 1369, 26, 10977, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 23865, 523, 18210, 63, 1102, 26, 272, 1369, 26, 3531, 503, 6246, 402, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 20014, 14, 2694, 14, 957, 2, 523, 18210, 63, 751, 26, 272, 1369, 26, 9516, 25124, 2933, 1202, 641, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 2113, 2, 523, 18210, 63, 1529, 26, 272, 1369, 26, 13635, 402, 4628, 25124, 922, 272, 1415, 26, 2549, 523, 18210, 63, 2745, 26, 272, 1369, 26, 11557, 1202, 701, 3531, 33, 1654, 272, 1415, 26, 3055, 272, 849, 26, 298, 2859, 2, 272, 3415, 26, 2097, 1014, 401, 298, 2859, 937, 523, 4107, 63, 8356, 26, 272, 1369, 26, 272, 446, 961, 1454, 12966, 340, 445, 8, 20014, 63, 2745, 9, 365, 473, 8, 2859, 680, 272, 446, 982, 663, 370, 445, 8, 889, 395, 314, 7799, 14512, 911, 440, 506, 16468, 14, 272, 446, 961, 1077, 1454, 663, 370, 445, 8, 889, 9, 1202, 641, 4954, 1183, 22284, 15424, 1808, 291, 13, 1737, 14512, 14, 272, 1415, 26, 3055, 272, 849, 26, 2549, 199, 1023, 63, 3270, 26, 298, 18, 14, 19, 2, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 7523, 1572, 365, 3451, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 312, 3174, 272, 15122, 1955, 26, 959, 10657, 17, 272, 1174, 26, 3451, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 626, 4652, 984, 1483, 436, 1145, 1483, 787, 7943, 370, 4156, 1325, 949, 1163, 1572, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 4156, 272, 1572, 26, 272, 446, 984, 1483, 272, 446, 1145, 1483, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 626, 4390, 7403, 527, 436, 9087, 651, 787, 5090, 370, 314, 1572, 12, 1325, 949, 1163, 922, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 984, 1483, 272, 922, 26, 272, 446, 7403, 527, 272, 446, 9087, 651, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 199, 3, 7523, 1572, 365, 9552, 199, 13, 18210, 63, 923, 26, 272, 536, 26, 984, 1483, 272, 1174, 26, 9552, 272, 18210, 63, 1102, 26, 18210, 14, 2694, 14, 957, 272, 18210, 63, 751, 26, 4628, 272, 18210, 63, 1529, 26, 2746, 4731, 199, 2344, 199, 199, 9677, 275, 1449, 199, 923, 26, 523, 1369, 26, 5611, 465, 2138, 701, 3531, 33, 3261, 523, 2138, 26, 3544, 523, 730, 26, 1211, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 647, 5819, 1194, 492, 664, 63, 1971, 199, 504, 3242, 14, 578, 63, 1208, 14, 20014, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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/python # -*- coding: utf-8 -*- # Copyright: (c) 2017, Noah Sparks <nsparks@outlook.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = r''' --- module: win_audit_rule short_description: Adds an audit rule to files, folders, or registry keys description: - Used to apply audit rules to files, folders or registry keys. - Once applied, it will begin recording the user who performed the operation defined into the Security Log in the Event viewer. - The behavior is designed to ignore inherited rules since those cannot be adjusted without first disabling the inheritance behavior. It will still print inherited rules in the output though for debugging purposes. version_added: "2.5" author: - Noah Sparks (@nwsparks) options: path: description: - Path to the file, folder, or registry key. - Registry paths should be in Powershell format, beginning with an abbreviation for the root such as, 'hklm:\software'. required: yes aliases: [ dest, destination ] user: description: - The user or group to adjust rules for. required: yes rights: description: - Comma seperated list of the rights desired. Only required for adding a rule. - If I(path) is a file or directory, rights can be any right under MSDN FileSystemRights U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesystemrights.aspx). - If I(path) is a registry key, rights can be any right under MSDN RegistryRights U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.registryrights.aspx). required: yes inheritance_flags: description: - Defines what objects inside of a folder or registry key will inherit the settings. - If you are setting a rule on a file, this value has to be changed to C(none). - For more information on the choices see MSDN PropagationFlags enumeration at U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.inheritanceflags.aspx). default: "ContainerInherit,ObjectInherit" choices: [ ContainerInherit, ObjectInherit ] propagation_flags: description: - Propagation flag on the audit rules. - This value is ignored when the path type is a file. - For more information on the choices see MSDN PropagationFlags enumeration at U(https://msdn.microsoft.com/en-us/library/system.security.accesscontrol.propagationflags.aspx). default: "None" choices: [ None, InherityOnly, NoPropagateInherit ] audit_flags: description: - Defines whether to log on failure, success, or both. - To log both define as comma seperated list "Success, Failure". required: yes choices: [ Failure, Success ] state: description: - Whether the rule should be C(present) or C(absent). - For absent, only I(path), I(user), and I(state) are required. - Specifying C(absent) will remove all rules matching the defined I(user). choices: [ absent, present ] default: present ''' EXAMPLES = r''' - name: add filesystem audit rule for a folder win_audit_rule: path: C:\inetpub\wwwroot\website user: BUILTIN\Users rights: write,delete,changepermissions audit_flags: success,failure inheritance_flags: ContainerInherit,ObjectInherit - name: add filesystem audit rule for a file win_audit_rule: path: C:\inetpub\wwwroot\website\web.config user: BUILTIN\Users rights: write,delete,changepermissions audit_flags: success,failure inheritance_flags: None - name: add registry audit rule win_audit_rule: path: HKLM:\software user: BUILTIN\Users rights: delete audit_flags: 'success' - name: remove filesystem audit rule win_audit_rule: path: C:\inetpub\wwwroot\website user: BUILTIN\Users state: absent - name: remove registry audit rule win_audit_rule: path: HKLM:\software user: BUILTIN\Users state: absent ''' RETURN = r''' current_audit_rules: description: - The current rules on the defined I(path) - Will return "No audit rules defined on I(path)" returned: always type: dictionary sample: | { "audit_flags": "Success", "user": "Everyone", "inheritance_flags": "False", "is_inherited": "False", "propagation_flags": "None", "rights": "Delete" } path_type: description: - The type of I(path) being targetted. - Will be one of file, directory, registry. returned: always type: string '''
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 3091, 11326, 13932, 83, 665, 561, 5149, 83, 32, 548, 11660, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 14274, 63, 2200, 199, 3612, 63, 1802, 26, 15747, 376, 13968, 2332, 370, 1584, 12, 16533, 12, 503, 7086, 2883, 199, 1802, 26, 523, 446, 8051, 370, 4838, 13968, 4713, 370, 1584, 12, 16533, 503, 7086, 2883, 14, 523, 446, 19468, 6781, 12, 652, 911, 5386, 20952, 314, 922, 3963, 10585, 314, 3439, 3247, 1901, 314, 13863, 272, 5297, 315, 314, 6763, 27354, 14, 523, 446, 710, 5953, 365, 19829, 370, 3686, 12623, 4713, 3967, 5204, 3913, 506, 19477, 1928, 1642, 30723, 272, 314, 15433, 5953, 14, 2779, 911, 5139, 870, 12623, 4713, 315, 314, 1072, 10617, 367, 10201, 12901, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 523, 446, 3091, 11326, 13932, 83, 8593, 78, 3569, 5149, 83, 9, 199, 1419, 26, 523, 931, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 570, 12, 4922, 12, 503, 7086, 790, 14, 489, 446, 20738, 3792, 1077, 506, 315, 18879, 5641, 1475, 12, 9608, 543, 376, 2236, 30369, 367, 314, 1738, 267, 4066, 465, 12, 283, 72, 9503, 77, 3427, 15619, 1370, 272, 1415, 26, 9456, 272, 5481, 26, 359, 2053, 12, 5724, 1622, 523, 922, 26, 272, 1369, 26, 489, 446, 710, 922, 503, 1572, 370, 11311, 4713, 367, 14, 272, 1415, 26, 9456, 523, 4481, 26, 272, 1369, 26, 489, 446, 5429, 391, 542, 529, 972, 769, 402, 314, 4481, 6387, 14, 5972, 1415, 367, 7791, 282, 2332, 14, 489, 446, 982, 473, 8, 515, 9, 365, 282, 570, 503, 2082, 12, 4481, 883, 506, 1263, 2451, 1334, 603, 3693, 46, 267, 23754, 50, 2492, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 11381, 17307, 14, 26146, 680, 489, 446, 982, 473, 8, 515, 9, 365, 282, 7086, 790, 12, 4481, 883, 506, 1263, 2451, 1334, 603, 3693, 46, 267, 20738, 50, 2492, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 5189, 17307, 14, 26146, 680, 272, 1415, 26, 9456, 523, 15433, 63, 2469, 26, 272, 1369, 26, 489, 446, 25022, 4052, 2251, 6272, 402, 282, 4922, 503, 7086, 790, 911, 8287, 314, 2202, 14, 489, 446, 982, 1265, 787, 4260, 282, 2332, 641, 282, 570, 12, 642, 574, 965, 370, 506, 2896, 370, 445, 8, 3592, 680, 489, 446, 2104, 1655, 2556, 641, 314, 3415, 1937, 603, 3693, 46, 2165, 6861, 6381, 28640, 267, 737, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 13136, 2469, 14, 26146, 680, 272, 849, 26, 298, 4076, 23542, 12, 1692, 23542, 2, 272, 3415, 26, 359, 15395, 23542, 12, 6935, 23542, 1622, 523, 17012, 63, 2469, 26, 272, 1369, 26, 489, 446, 2165, 6861, 3305, 641, 314, 13968, 4713, 14, 489, 446, 961, 574, 365, 5525, 1380, 314, 931, 730, 365, 282, 570, 14, 489, 446, 2104, 1655, 2556, 641, 314, 3415, 1937, 603, 3693, 46, 2165, 6861, 6381, 28640, 267, 737, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 13535, 2469, 14, 26146, 680, 272, 849, 26, 298, 403, 2, 272, 3415, 26, 359, 488, 12, 1010, 2523, 1209, 5903, 12, 3091, 919, 12563, 23542, 1622, 523, 13968, 63, 2469, 26, 272, 1369, 26, 489, 446, 25022, 3775, 370, 943, 641, 5988, 12, 3182, 12, 503, 3865, 14, 489, 446, 4005, 943, 3865, 5627, 465, 10029, 542, 529, 972, 769, 298, 8300, 12, 20367, 1674, 272, 1415, 26, 9456, 272, 3415, 26, 359, 20367, 12, 22318, 1622, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 2332, 1077, 506, 445, 8, 1881, 9, 503, 445, 8, 5575, 680, 489, 446, 2104, 9552, 12, 1454, 473, 8, 515, 395, 473, 8, 751, 395, 436, 473, 8, 929, 9, 787, 1415, 14, 489, 446, 13327, 316, 445, 8, 5575, 9, 911, 2813, 1006, 4713, 4877, 314, 3247, 473, 8, 751, 680, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 1050, 10036, 13968, 2332, 367, 282, 4922, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 2218, 12, 1807, 12, 1461, 6060, 272, 13968, 63, 2469, 26, 3182, 12, 5328, 272, 15433, 63, 2469, 26, 15395, 23542, 12, 1692, 23542, 199, 199, 13, 536, 26, 1050, 10036, 13968, 2332, 367, 282, 570, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 60, 2520, 14, 888, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 2218, 12, 1807, 12, 1461, 6060, 272, 13968, 63, 2469, 26, 3182, 12, 5328, 272, 15433, 63, 2469, 26, 488, 199, 199, 13, 536, 26, 1050, 7086, 13968, 2332, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 869, 14307, 45, 3427, 15619, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 3145, 272, 13968, 63, 2469, 26, 283, 3742, 7, 199, 199, 13, 536, 26, 2813, 10036, 13968, 2332, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 272, 922, 26, 16331 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 9708, 12, 3091, 11326, 13932, 83, 665, 561, 5149, 83, 32, 548, 11660, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 4747, 63, 14274, 63, 2200, 199, 3612, 63, 1802, 26, 15747, 376, 13968, 2332, 370, 1584, 12, 16533, 12, 503, 7086, 2883, 199, 1802, 26, 523, 446, 8051, 370, 4838, 13968, 4713, 370, 1584, 12, 16533, 503, 7086, 2883, 14, 523, 446, 19468, 6781, 12, 652, 911, 5386, 20952, 314, 922, 3963, 10585, 314, 3439, 3247, 1901, 314, 13863, 272, 5297, 315, 314, 6763, 27354, 14, 523, 446, 710, 5953, 365, 19829, 370, 3686, 12623, 4713, 3967, 5204, 3913, 506, 19477, 1928, 1642, 30723, 272, 314, 15433, 5953, 14, 2779, 911, 5139, 870, 12623, 4713, 315, 314, 1072, 10617, 367, 10201, 12901, 14, 199, 1023, 63, 3270, 26, 298, 18, 14, 21, 2, 199, 2502, 26, 523, 446, 3091, 11326, 13932, 83, 8593, 78, 3569, 5149, 83, 9, 199, 1419, 26, 523, 931, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 570, 12, 4922, 12, 503, 7086, 790, 14, 489, 446, 20738, 3792, 1077, 506, 315, 18879, 5641, 1475, 12, 9608, 543, 376, 2236, 30369, 367, 314, 1738, 267, 4066, 465, 12, 283, 72, 9503, 77, 3427, 15619, 1370, 272, 1415, 26, 9456, 272, 5481, 26, 359, 2053, 12, 5724, 1622, 523, 922, 26, 272, 1369, 26, 489, 446, 710, 922, 503, 1572, 370, 11311, 4713, 367, 14, 272, 1415, 26, 9456, 523, 4481, 26, 272, 1369, 26, 489, 446, 5429, 391, 542, 529, 972, 769, 402, 314, 4481, 6387, 14, 5972, 1415, 367, 7791, 282, 2332, 14, 489, 446, 982, 473, 8, 515, 9, 365, 282, 570, 503, 2082, 12, 4481, 883, 506, 1263, 2451, 1334, 603, 3693, 46, 267, 23754, 50, 2492, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 11381, 17307, 14, 26146, 680, 489, 446, 982, 473, 8, 515, 9, 365, 282, 7086, 790, 12, 4481, 883, 506, 1263, 2451, 1334, 603, 3693, 46, 267, 20738, 50, 2492, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 5189, 17307, 14, 26146, 680, 272, 1415, 26, 9456, 523, 15433, 63, 2469, 26, 272, 1369, 26, 489, 446, 25022, 4052, 2251, 6272, 402, 282, 4922, 503, 7086, 790, 911, 8287, 314, 2202, 14, 489, 446, 982, 1265, 787, 4260, 282, 2332, 641, 282, 570, 12, 642, 574, 965, 370, 506, 2896, 370, 445, 8, 3592, 680, 489, 446, 2104, 1655, 2556, 641, 314, 3415, 1937, 603, 3693, 46, 2165, 6861, 6381, 28640, 267, 737, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 13136, 2469, 14, 26146, 680, 272, 849, 26, 298, 4076, 23542, 12, 1692, 23542, 2, 272, 3415, 26, 359, 15395, 23542, 12, 6935, 23542, 1622, 523, 17012, 63, 2469, 26, 272, 1369, 26, 489, 446, 2165, 6861, 3305, 641, 314, 13968, 4713, 14, 489, 446, 961, 574, 365, 5525, 1380, 314, 931, 730, 365, 282, 570, 14, 489, 446, 2104, 1655, 2556, 641, 314, 3415, 1937, 603, 3693, 46, 2165, 6861, 6381, 28640, 267, 737, 738, 8, 2859, 921, 706, 4272, 14, 17040, 14, 957, 15, 287, 13, 527, 15, 4342, 15, 2253, 14, 4416, 14, 2732, 2785, 14, 13535, 2469, 14, 26146, 680, 272, 849, 26, 298, 403, 2, 272, 3415, 26, 359, 488, 12, 1010, 2523, 1209, 5903, 12, 3091, 919, 12563, 23542, 1622, 523, 13968, 63, 2469, 26, 272, 1369, 26, 489, 446, 25022, 3775, 370, 943, 641, 5988, 12, 3182, 12, 503, 3865, 14, 489, 446, 4005, 943, 3865, 5627, 465, 10029, 542, 529, 972, 769, 298, 8300, 12, 20367, 1674, 272, 1415, 26, 9456, 272, 3415, 26, 359, 20367, 12, 22318, 1622, 523, 1174, 26, 272, 1369, 26, 489, 446, 7480, 314, 2332, 1077, 506, 445, 8, 1881, 9, 503, 445, 8, 5575, 680, 489, 446, 2104, 9552, 12, 1454, 473, 8, 515, 395, 473, 8, 751, 395, 436, 473, 8, 929, 9, 787, 1415, 14, 489, 446, 13327, 316, 445, 8, 5575, 9, 911, 2813, 1006, 4713, 4877, 314, 3247, 473, 8, 751, 680, 272, 3415, 26, 359, 9552, 12, 3451, 1622, 272, 849, 26, 3451, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 1050, 10036, 13968, 2332, 367, 282, 4922, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 2218, 12, 1807, 12, 1461, 6060, 272, 13968, 63, 2469, 26, 3182, 12, 5328, 272, 15433, 63, 2469, 26, 15395, 23542, 12, 1692, 23542, 199, 199, 13, 536, 26, 1050, 10036, 13968, 2332, 367, 282, 570, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 60, 2520, 14, 888, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 2218, 12, 1807, 12, 1461, 6060, 272, 13968, 63, 2469, 26, 3182, 12, 5328, 272, 15433, 63, 2469, 26, 488, 199, 199, 13, 536, 26, 1050, 7086, 13968, 2332, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 869, 14307, 45, 3427, 15619, 272, 922, 26, 16331, 1193, 20012, 60, 12117, 272, 4481, 26, 3145, 272, 13968, 63, 2469, 26, 283, 3742, 7, 199, 199, 13, 536, 26, 2813, 10036, 13968, 2332, 523, 4747, 63, 14274, 63, 2200, 26, 272, 931, 26, 445, 3427, 10811, 5645, 60, 1544, 1231, 60, 7360, 272, 922, 26, 16331, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
astondbs/googletest
test/gtest_shuffle_test.py
3023
12549
#!/usr/bin/env python # # Copyright 2009 Google Inc. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Verifies that test shuffling works.""" __author__ = 'wan@google.com (Zhanyong Wan)' import os import gtest_test_utils # Command to run the gtest_shuffle_test_ program. COMMAND = gtest_test_utils.GetTestExecutablePath('gtest_shuffle_test_') # The environment variables for test sharding. TOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS' SHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX' TEST_FILTER = 'A*.A:A*.B:C*' ALL_TESTS = [] ACTIVE_TESTS = [] FILTERED_TESTS = [] SHARDED_TESTS = [] SHUFFLED_ALL_TESTS = [] SHUFFLED_ACTIVE_TESTS = [] SHUFFLED_FILTERED_TESTS = [] SHUFFLED_SHARDED_TESTS = [] def AlsoRunDisabledTestsFlag(): return '--gtest_also_run_disabled_tests' def FilterFlag(test_filter): return '--gtest_filter=%s' % (test_filter,) def RepeatFlag(n): return '--gtest_repeat=%s' % (n,) def ShuffleFlag(): return '--gtest_shuffle' def RandomSeedFlag(n): return '--gtest_random_seed=%s' % (n,) def RunAndReturnOutput(extra_env, args): """Runs the test program and returns its output.""" environ_copy = os.environ.copy() environ_copy.update(extra_env) return gtest_test_utils.Subprocess([COMMAND] + args, env=environ_copy).output def GetTestsForAllIterations(extra_env, args): """Runs the test program and returns a list of test lists. Args: extra_env: a map from environment variables to their values args: command line flags to pass to gtest_shuffle_test_ Returns: A list where the i-th element is the list of tests run in the i-th test iteration. """ test_iterations = [] for line in RunAndReturnOutput(extra_env, args).split('\n'): if line.startswith('----'): tests = [] test_iterations.append(tests) elif line.strip(): tests.append(line.strip()) # 'TestCaseName.TestName' return test_iterations def GetTestCases(tests): """Returns a list of test cases in the given full test names. Args: tests: a list of full test names Returns: A list of test cases from 'tests', in their original order. Consecutive duplicates are removed. """ test_cases = [] for test in tests: test_case = test.split('.')[0] if not test_case in test_cases: test_cases.append(test_case) return test_cases def CalculateTestLists(): """Calculates the list of tests run under different flags.""" if not ALL_TESTS: ALL_TESTS.extend( GetTestsForAllIterations({}, [AlsoRunDisabledTestsFlag()])[0]) if not ACTIVE_TESTS: ACTIVE_TESTS.extend(GetTestsForAllIterations({}, [])[0]) if not FILTERED_TESTS: FILTERED_TESTS.extend( GetTestsForAllIterations({}, [FilterFlag(TEST_FILTER)])[0]) if not SHARDED_TESTS: SHARDED_TESTS.extend( GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, [])[0]) if not SHUFFLED_ALL_TESTS: SHUFFLED_ALL_TESTS.extend(GetTestsForAllIterations( {}, [AlsoRunDisabledTestsFlag(), ShuffleFlag(), RandomSeedFlag(1)])[0]) if not SHUFFLED_ACTIVE_TESTS: SHUFFLED_ACTIVE_TESTS.extend(GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1)])[0]) if not SHUFFLED_FILTERED_TESTS: SHUFFLED_FILTERED_TESTS.extend(GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), FilterFlag(TEST_FILTER)])[0]) if not SHUFFLED_SHARDED_TESTS: SHUFFLED_SHARDED_TESTS.extend( GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, [ShuffleFlag(), RandomSeedFlag(1)])[0]) class GTestShuffleUnitTest(gtest_test_utils.TestCase): """Tests test shuffling.""" def setUp(self): CalculateTestLists() def testShufflePreservesNumberOfTests(self): self.assertEqual(len(ALL_TESTS), len(SHUFFLED_ALL_TESTS)) self.assertEqual(len(ACTIVE_TESTS), len(SHUFFLED_ACTIVE_TESTS)) self.assertEqual(len(FILTERED_TESTS), len(SHUFFLED_FILTERED_TESTS)) self.assertEqual(len(SHARDED_TESTS), len(SHUFFLED_SHARDED_TESTS)) def testShuffleChangesTestOrder(self): self.assert_(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS) self.assert_(SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS) self.assert_(SHUFFLED_FILTERED_TESTS != FILTERED_TESTS, SHUFFLED_FILTERED_TESTS) self.assert_(SHUFFLED_SHARDED_TESTS != SHARDED_TESTS, SHUFFLED_SHARDED_TESTS) def testShuffleChangesTestCaseOrder(self): self.assert_(GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS), GetTestCases(SHUFFLED_ALL_TESTS)) self.assert_( GetTestCases(SHUFFLED_ACTIVE_TESTS) != GetTestCases(ACTIVE_TESTS), GetTestCases(SHUFFLED_ACTIVE_TESTS)) self.assert_( GetTestCases(SHUFFLED_FILTERED_TESTS) != GetTestCases(FILTERED_TESTS), GetTestCases(SHUFFLED_FILTERED_TESTS)) self.assert_( GetTestCases(SHUFFLED_SHARDED_TESTS) != GetTestCases(SHARDED_TESTS), GetTestCases(SHUFFLED_SHARDED_TESTS)) def testShuffleDoesNotRepeatTest(self): for test in SHUFFLED_ALL_TESTS: self.assertEqual(1, SHUFFLED_ALL_TESTS.count(test), '%s appears more than once' % (test,)) for test in SHUFFLED_ACTIVE_TESTS: self.assertEqual(1, SHUFFLED_ACTIVE_TESTS.count(test), '%s appears more than once' % (test,)) for test in SHUFFLED_FILTERED_TESTS: self.assertEqual(1, SHUFFLED_FILTERED_TESTS.count(test), '%s appears more than once' % (test,)) for test in SHUFFLED_SHARDED_TESTS: self.assertEqual(1, SHUFFLED_SHARDED_TESTS.count(test), '%s appears more than once' % (test,)) def testShuffleDoesNotCreateNewTest(self): for test in SHUFFLED_ALL_TESTS: self.assert_(test in ALL_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_ACTIVE_TESTS: self.assert_(test in ACTIVE_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_FILTERED_TESTS: self.assert_(test in FILTERED_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_SHARDED_TESTS: self.assert_(test in SHARDED_TESTS, '%s is an invalid test' % (test,)) def testShuffleIncludesAllTests(self): for test in ALL_TESTS: self.assert_(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,)) for test in ACTIVE_TESTS: self.assert_(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,)) for test in FILTERED_TESTS: self.assert_(test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,)) for test in SHARDED_TESTS: self.assert_(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,)) def testShuffleLeavesDeathTestsAtFront(self): non_death_test_found = False for test in SHUFFLED_ACTIVE_TESTS: if 'DeathTest.' in test: self.assert_(not non_death_test_found, '%s appears after a non-death test' % (test,)) else: non_death_test_found = True def _VerifyTestCasesDoNotInterleave(self, tests): test_cases = [] for test in tests: [test_case, _] = test.split('.') if test_cases and test_cases[-1] != test_case: test_cases.append(test_case) self.assertEqual(1, test_cases.count(test_case), 'Test case %s is not grouped together in %s' % (test_case, tests)) def testShuffleDoesNotInterleaveTestCases(self): self._VerifyTestCasesDoNotInterleave(SHUFFLED_ALL_TESTS) self._VerifyTestCasesDoNotInterleave(SHUFFLED_ACTIVE_TESTS) self._VerifyTestCasesDoNotInterleave(SHUFFLED_FILTERED_TESTS) self._VerifyTestCasesDoNotInterleave(SHUFFLED_SHARDED_TESTS) def testShuffleRestoresOrderAfterEachIteration(self): # Get the test lists in all 3 iterations, using random seed 1, 2, # and 3 respectively. Google Test picks a different seed in each # iteration, and this test depends on the current implementation # picking successive numbers. This dependency is not ideal, but # makes the test much easier to write. [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) # Make sure running the tests with random seed 1 gets the same # order as in iteration 1 above. [tests_with_seed1] = GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1)]) self.assertEqual(tests_in_iteration1, tests_with_seed1) # Make sure running the tests with random seed 2 gets the same # order as in iteration 2 above. Success means that Google Test # correctly restores the test order before re-shuffling at the # beginning of iteration 2. [tests_with_seed2] = GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(2)]) self.assertEqual(tests_in_iteration2, tests_with_seed2) # Make sure running the tests with random seed 3 gets the same # order as in iteration 3 above. Success means that Google Test # correctly restores the test order before re-shuffling at the # beginning of iteration 3. [tests_with_seed3] = GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(3)]) self.assertEqual(tests_in_iteration3, tests_with_seed3) def testShuffleGeneratesNewOrderInEachIteration(self): [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) self.assert_(tests_in_iteration1 != tests_in_iteration2, tests_in_iteration1) self.assert_(tests_in_iteration1 != tests_in_iteration3, tests_in_iteration1) self.assert_(tests_in_iteration2 != tests_in_iteration3, tests_in_iteration2) def testShuffleShardedTestsPreservesPartition(self): # If we run M tests on N shards, the same M tests should be run in # total, regardless of the random seeds used by the shards. [tests1] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '0'}, [ShuffleFlag(), RandomSeedFlag(1)]) [tests2] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, [ShuffleFlag(), RandomSeedFlag(20)]) [tests3] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '2'}, [ShuffleFlag(), RandomSeedFlag(25)]) sorted_sharded_tests = tests1 + tests2 + tests3 sorted_sharded_tests.sort() sorted_active_tests = [] sorted_active_tests.extend(ACTIVE_TESTS) sorted_active_tests.sort() self.assertEqual(sorted_active_tests, sorted_sharded_tests) if __name__ == '__main__': gtest_test_utils.Main()
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 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, 21168, 626, 511, 28126, 2983, 5419, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 199, 199, 3, 5817, 370, 1255, 314, 9088, 63, 11777, 63, 396, 63, 2240, 14, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 11777, 63, 396, 15452, 199, 199, 3, 710, 3734, 2860, 367, 511, 11814, 316, 14, 199, 15386, 63, 11152, 3177, 63, 9984, 63, 5568, 275, 283, 16151, 63, 15386, 63, 11152, 3177, 7, 199, 3234, 7816, 63, 10215, 63, 9984, 63, 5568, 275, 283, 16151, 63, 3234, 7816, 63, 10215, 7, 199, 199, 2864, 63, 9905, 275, 283, 33, 4856, 33, 26, 33, 4856, 34, 26, 35, 10223, 199, 199, 1761, 63, 7569, 275, 942, 199, 10401, 63, 7569, 275, 942, 199, 32359, 63, 7569, 275, 942, 199, 11152, 8280, 63, 7569, 275, 942, 199, 199, 28243, 63, 1761, 63, 7569, 275, 942, 199, 28243, 63, 10401, 63, 7569, 275, 942, 199, 28243, 63, 32359, 63, 7569, 275, 942, 199, 28243, 63, 11152, 8280, 63, 7569, 275, 942, 421, 199, 318, 6121, 2540, 15049, 2925, 5318, 837, 523, 372, 2850, 8385, 63, 12344, 63, 1065, 63, 7011, 63, 2219, 7, 421, 199, 318, 9388, 5318, 8, 396, 63, 1541, 304, 523, 372, 2850, 8385, 63, 1541, 2458, 83, 7, 450, 334, 396, 63, 1541, 4258, 421, 199, 318, 21973, 292, 5318, 8, 78, 304, 523, 372, 2850, 8385, 63, 8755, 2458, 83, 7, 450, 334, 78, 4258, 421, 199, 318, 5244, 6817, 5318, 837, 523, 372, 2850, 8385, 63, 11777, 7, 421, 199, 318, 9571, 19554, 5318, 8, 78, 304, 523, 372, 2850, 8385, 63, 2355, 63, 5176, 2458, 83, 7, 450, 334, 78, 4258, 421, 199, 318, 3378, 8572, 2959, 8, 2911, 63, 1813, 12, 1249, 304, 523, 408, 16291, 314, 511, 2240, 436, 2529, 2399, 1072, 1041, 819, 6160, 63, 1574, 275, 747, 14, 2314, 14, 1574, 342, 523, 6160, 63, 1574, 14, 873, 8, 2911, 63, 1813, 9, 819, 372, 9088, 63, 396, 63, 1208, 14, 22299, 779, 10761, 61, 435, 1249, 12, 2589, 29, 2314, 63, 1574, 680, 1199, 421, 199, 318, 2372, 2925, 30462, 26292, 8, 2911, 63, 1813, 12, 1249, 304, 523, 408, 16291, 314, 511, 2240, 436, 2529, 282, 769, 402, 511, 5548, 14, 819, 3033, 26, 272, 2402, 63, 1813, 26, 282, 2341, 687, 3734, 2860, 370, 3932, 1338, 272, 1249, 26, 1414, 1004, 3285, 370, 986, 370, 9088, 63, 11777, 63, 396, 63, 819, 1803, 26, 272, 437, 769, 2382, 314, 284, 13, 273, 1819, 365, 314, 769, 402, 2295, 1255, 315, 314, 284, 13, 273, 272, 511, 8494, 14, 523, 408, 819, 511, 63, 13570, 275, 942, 523, 367, 1004, 315, 3378, 8572, 2959, 8, 2911, 63, 1813, 12, 1249, 680, 1294, 2258, 78, 735, 272, 340, 1004, 14, 2460, 360, 375, 735, 489, 2295, 275, 942, 489, 511, 63, 13570, 14, 740, 8, 2219, 9, 272, 916, 1004, 14, 1913, 837, 489, 2295, 14, 740, 8, 604, 14, 1913, 1012, 221, 327, 283, 1746, 985, 14, 774, 985, 7, 819, 372, 511, 63, 13570, 421, 199, 318, 2372, 19346, 8, 2219, 304, 523, 408, 3407, 282, 769, 402, 511, 5560, 315, 314, 1627, 2615, 511, 1561, 14, 819, 3033, 26, 272, 2295, 26, 282, 769, 402, 2615, 511, 1561, 819, 1803, 26, 272, 437, 769, 402, 511, 5560, 687, 283, 2219, 297, 315, 3932, 3379, 1865, 14, 272, 1448, 19068, 15755, 787, 4829, 14, 523, 408, 819, 511, 63, 9403, 275, 942, 523, 367, 511, 315, 2295, 26, 272, 511, 63, 2546, 275, 511, 14, 1294, 19237, 16, 61, 272, 340, 440, 511, 63, 2546, 315, 511, 63, 9403, 26, 489, 511, 63, 9403, 14, 740, 8, 396, 63, 2546, 9, 819, 372, 511, 63, 9403, 421, 199, 318, 12707, 774, 15116, 837, 523, 408, 13862, 2335, 314, 769, 402, 2295, 1255, 1334, 3365, 3285, 1041, 819, 340, 440, 11727, 63, 7569, 26, 272, 11727, 63, 7569, 14, 2880, 8, 267, 2372, 2925, 30462, 26292, 16037, 359, 31892, 2540, 15049, 2925, 5318, 9383, 59, 16, 566, 819 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 8937, 4475, 3277, 14, 2900, 5924, 5702, 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, 21168, 626, 511, 28126, 2983, 5419, 1041, 199, 199, 363, 2502, 363, 275, 283, 20444, 32, 3098, 14, 957, 334, 12674, 1629, 951, 644, 290, 3171, 199, 199, 646, 747, 199, 646, 9088, 63, 396, 63, 1208, 199, 199, 3, 5817, 370, 1255, 314, 9088, 63, 11777, 63, 396, 63, 2240, 14, 199, 10761, 275, 9088, 63, 396, 63, 1208, 14, 28967, 27602, 360, 8385, 63, 11777, 63, 396, 15452, 199, 199, 3, 710, 3734, 2860, 367, 511, 11814, 316, 14, 199, 15386, 63, 11152, 3177, 63, 9984, 63, 5568, 275, 283, 16151, 63, 15386, 63, 11152, 3177, 7, 199, 3234, 7816, 63, 10215, 63, 9984, 63, 5568, 275, 283, 16151, 63, 3234, 7816, 63, 10215, 7, 199, 199, 2864, 63, 9905, 275, 283, 33, 4856, 33, 26, 33, 4856, 34, 26, 35, 10223, 199, 199, 1761, 63, 7569, 275, 942, 199, 10401, 63, 7569, 275, 942, 199, 32359, 63, 7569, 275, 942, 199, 11152, 8280, 63, 7569, 275, 942, 199, 199, 28243, 63, 1761, 63, 7569, 275, 942, 199, 28243, 63, 10401, 63, 7569, 275, 942, 199, 28243, 63, 32359, 63, 7569, 275, 942, 199, 28243, 63, 11152, 8280, 63, 7569, 275, 942, 421, 199, 318, 6121, 2540, 15049, 2925, 5318, 837, 523, 372, 2850, 8385, 63, 12344, 63, 1065, 63, 7011, 63, 2219, 7, 421, 199, 318, 9388, 5318, 8, 396, 63, 1541, 304, 523, 372, 2850, 8385, 63, 1541, 2458, 83, 7, 450, 334, 396, 63, 1541, 4258, 421, 199, 318, 21973, 292, 5318, 8, 78, 304, 523, 372, 2850, 8385, 63, 8755, 2458, 83, 7, 450, 334, 78, 4258, 421, 199, 318, 5244, 6817, 5318, 837, 523, 372, 2850, 8385, 63, 11777, 7, 421, 199, 318, 9571, 19554, 5318, 8, 78, 304, 523, 372, 2850, 8385, 63, 2355, 63, 5176, 2458, 83, 7, 450, 334, 78, 4258, 421, 199, 318, 3378, 8572, 2959, 8, 2911, 63, 1813, 12, 1249, 304, 523, 408, 16291, 314, 511, 2240, 436, 2529, 2399, 1072, 1041, 819, 6160, 63, 1574, 275, 747, 14, 2314, 14, 1574, 342, 523, 6160, 63, 1574, 14, 873, 8, 2911, 63, 1813, 9, 819, 372, 9088, 63, 396, 63, 1208, 14, 22299, 779, 10761, 61, 435, 1249, 12, 2589, 29, 2314, 63, 1574, 680, 1199, 421, 199, 318, 2372, 2925, 30462, 26292, 8, 2911, 63, 1813, 12, 1249, 304, 523, 408, 16291, 314, 511, 2240, 436, 2529, 282, 769, 402, 511, 5548, 14, 819, 3033, 26, 272, 2402, 63, 1813, 26, 282, 2341, 687, 3734, 2860, 370, 3932, 1338, 272, 1249, 26, 1414, 1004, 3285, 370, 986, 370, 9088, 63, 11777, 63, 396, 63, 819, 1803, 26, 272, 437, 769, 2382, 314, 284, 13, 273, 1819, 365, 314, 769, 402, 2295, 1255, 315, 314, 284, 13, 273, 272, 511, 8494, 14, 523, 408, 819, 511, 63, 13570, 275, 942, 523, 367, 1004, 315, 3378, 8572, 2959, 8, 2911, 63, 1813, 12, 1249, 680, 1294, 2258, 78, 735, 272, 340, 1004, 14, 2460, 360, 375, 735, 489, 2295, 275, 942, 489, 511, 63, 13570, 14, 740, 8, 2219, 9, 272, 916, 1004, 14, 1913, 837, 489, 2295, 14, 740, 8, 604, 14, 1913, 1012, 221, 327, 283, 1746, 985, 14, 774, 985, 7, 819, 372, 511, 63, 13570, 421, 199, 318, 2372, 19346, 8, 2219, 304, 523, 408, 3407, 282, 769, 402, 511, 5560, 315, 314, 1627, 2615, 511, 1561, 14, 819, 3033, 26, 272, 2295, 26, 282, 769, 402, 2615, 511, 1561, 819, 1803, 26, 272, 437, 769, 402, 511, 5560, 687, 283, 2219, 297, 315, 3932, 3379, 1865, 14, 272, 1448, 19068, 15755, 787, 4829, 14, 523, 408, 819, 511, 63, 9403, 275, 942, 523, 367, 511, 315, 2295, 26, 272, 511, 63, 2546, 275, 511, 14, 1294, 19237, 16, 61, 272, 340, 440, 511, 63, 2546, 315, 511, 63, 9403, 26, 489, 511, 63, 9403, 14, 740, 8, 396, 63, 2546, 9, 819, 372, 511, 63, 9403, 421, 199, 318, 12707, 774, 15116, 837, 523, 408, 13862, 2335, 314, 769, 402, 2295, 1255, 1334, 3365, 3285, 1041, 819, 340, 440, 11727, 63, 7569, 26, 272, 11727, 63, 7569, 14, 2880, 8, 267, 2372, 2925, 30462, 26292, 16037, 359, 31892, 2540, 15049, 2925, 5318, 9383, 59, 16, 566, 819, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
wkschwartz/django
tests/schema/tests.py
1
172263
import datetime import itertools import unittest from copy import copy from unittest import mock from django.core.exceptions import FieldError from django.core.management.color import no_style from django.db import ( DatabaseError, DataError, IntegrityError, OperationalError, connection, ) from django.db.models import ( CASCADE, PROTECT, AutoField, BigAutoField, BigIntegerField, BinaryField, BooleanField, CharField, CheckConstraint, DateField, DateTimeField, DecimalField, F, FloatField, ForeignKey, ForeignObject, Index, IntegerField, JSONField, ManyToManyField, Model, OneToOneField, OrderBy, PositiveIntegerField, Q, SlugField, SmallAutoField, SmallIntegerField, TextField, TimeField, UniqueConstraint, UUIDField, Value, ) from django.db.models.fields.json import KeyTextTransform from django.db.models.functions import Abs, Cast, Collate, Lower, Random, Upper from django.db.models.indexes import IndexExpression from django.db.transaction import TransactionManagementError, atomic from django.test import ( TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from django.test.utils import ( CaptureQueriesContext, isolate_apps, register_lookup, ) from django.utils import timezone from .fields import ( CustomManyToManyField, InheritedManyToManyField, MediumBlobField, ) from .models import ( Author, AuthorCharFieldWithIndex, AuthorTextFieldWithIndex, AuthorWithDefaultHeight, AuthorWithEvenLongerName, AuthorWithIndexedName, AuthorWithIndexedNameAndBirthday, AuthorWithUniqueName, AuthorWithUniqueNameAndBirthday, Book, BookForeignObj, BookWeak, BookWithLongName, BookWithO2O, BookWithoutAuthor, BookWithSlug, IntegerPK, Node, Note, NoteRename, Tag, TagIndexed, TagM2MTest, TagUniqueRename, Thing, UniqueTest, new_apps, ) class SchemaTests(TransactionTestCase): """ Tests for the schema-alteration code. Be aware that these tests are more liable than most to false results, as sometimes the code to check if a test has worked is almost as complex as the code it is testing. """ available_apps = [] models = [ Author, AuthorCharFieldWithIndex, AuthorTextFieldWithIndex, AuthorWithDefaultHeight, AuthorWithEvenLongerName, Book, BookWeak, BookWithLongName, BookWithO2O, BookWithSlug, IntegerPK, Node, Note, Tag, TagIndexed, TagM2MTest, TagUniqueRename, Thing, UniqueTest, ] # Utility functions def setUp(self): # local_models should contain test dependent model classes that will be # automatically removed from the app cache on test tear down. self.local_models = [] # isolated_local_models contains models that are in test methods # decorated with @isolate_apps. self.isolated_local_models = [] def tearDown(self): # Delete any tables made for our models self.delete_tables() new_apps.clear_cache() for model in new_apps.get_models(): model._meta._expire_cache() if 'schema' in new_apps.all_models: for model in self.local_models: for many_to_many in model._meta.many_to_many: through = many_to_many.remote_field.through if through and through._meta.auto_created: del new_apps.all_models['schema'][through._meta.model_name] del new_apps.all_models['schema'][model._meta.model_name] if self.isolated_local_models: with connection.schema_editor() as editor: for model in self.isolated_local_models: editor.delete_model(model) def delete_tables(self): "Deletes all model tables for our models for a clean test environment" converter = connection.introspection.identifier_converter with connection.schema_editor() as editor: connection.disable_constraint_checking() table_names = connection.introspection.table_names() if connection.features.ignores_table_name_case: table_names = [table_name.lower() for table_name in table_names] for model in itertools.chain(SchemaTests.models, self.local_models): tbl = converter(model._meta.db_table) if connection.features.ignores_table_name_case: tbl = tbl.lower() if tbl in table_names: editor.delete_model(model) table_names.remove(tbl) connection.enable_constraint_checking() def column_classes(self, model): with connection.cursor() as cursor: columns = { d[0]: (connection.introspection.get_field_type(d[1], d), d) for d in connection.introspection.get_table_description( cursor, model._meta.db_table, ) } # SQLite has a different format for field_type for name, (type, desc) in columns.items(): if isinstance(type, tuple): columns[name] = (type[0], desc) # SQLite also doesn't error properly if not columns: raise DatabaseError("Table does not exist (empty pragma)") return columns def get_primary_key(self, table): with connection.cursor() as cursor: return connection.introspection.get_primary_key_column(cursor, table) def get_indexes(self, table): """ Get the indexes on the table using a new cursor. """ with connection.cursor() as cursor: return [ c['columns'][0] for c in connection.introspection.get_constraints(cursor, table).values() if c['index'] and len(c['columns']) == 1 ] def get_uniques(self, table): with connection.cursor() as cursor: return [ c['columns'][0] for c in connection.introspection.get_constraints(cursor, table).values() if c['unique'] and len(c['columns']) == 1 ] def get_constraints(self, table): """ Get the constraints on a table using a new cursor. """ with connection.cursor() as cursor: return connection.introspection.get_constraints(cursor, table) def get_constraints_for_column(self, model, column_name): constraints = self.get_constraints(model._meta.db_table) constraints_for_column = [] for name, details in constraints.items(): if details['columns'] == [column_name]: constraints_for_column.append(name) return sorted(constraints_for_column) def check_added_field_default(self, schema_editor, model, field, field_name, expected_default, cast_function=None): with connection.cursor() as cursor: schema_editor.add_field(model, field) cursor.execute("SELECT {} FROM {};".format(field_name, model._meta.db_table)) database_default = cursor.fetchall()[0][0] if cast_function and type(database_default) != type(expected_default): database_default = cast_function(database_default) self.assertEqual(database_default, expected_default) def get_constraints_count(self, table, column, fk_to): """ Return a dict with keys 'fks', 'uniques, and 'indexes' indicating the number of foreign keys, unique constraints, and indexes on `table`.`column`. The `fk_to` argument is a 2-tuple specifying the expected foreign key relationship's (table, column). """ with connection.cursor() as cursor: constraints = connection.introspection.get_constraints(cursor, table) counts = {'fks': 0, 'uniques': 0, 'indexes': 0} for c in constraints.values(): if c['columns'] == [column]: if c['foreign_key'] == fk_to: counts['fks'] += 1 if c['unique']: counts['uniques'] += 1 elif c['index']: counts['indexes'] += 1 return counts def get_column_collation(self, table, column): with connection.cursor() as cursor: return next( f.collation for f in connection.introspection.get_table_description(cursor, table) if f.name == column ) def assertIndexOrder(self, table, index, order): constraints = self.get_constraints(table) self.assertIn(index, constraints) index_orders = constraints[index]['orders'] self.assertTrue(all(val == expected for val, expected in zip(index_orders, order))) def assertForeignKeyExists(self, model, column, expected_fk_table, field='id'): """ Fail if the FK constraint on `model.Meta.db_table`.`column` to `expected_fk_table`.id doesn't exist. """ constraints = self.get_constraints(model._meta.db_table) constraint_fk = None for details in constraints.values(): if details['columns'] == [column] and details['foreign_key']: constraint_fk = details['foreign_key'] break self.assertEqual(constraint_fk, (expected_fk_table, field)) def assertForeignKeyNotExists(self, model, column, expected_fk_table): with self.assertRaises(AssertionError): self.assertForeignKeyExists(model, column, expected_fk_table) # Tests def test_creation_deletion(self): """ Tries creating a model's table, and then deleting it. """ with connection.schema_editor() as editor: # Create the table editor.create_model(Author) # The table is there list(Author.objects.all()) # Clean up that table editor.delete_model(Author) # No deferred SQL should be left over. self.assertEqual(editor.deferred_sql, []) # The table is gone with self.assertRaises(DatabaseError): list(Author.objects.all()) @skipUnlessDBFeature('supports_foreign_keys') def test_fk(self): "Creating tables out of FK order, then repointing, works" # Create the table with connection.schema_editor() as editor: editor.create_model(Book) editor.create_model(Author) editor.create_model(Tag) # Initial tables are there list(Author.objects.all()) list(Book.objects.all()) # Make sure the FK constraint is present with self.assertRaises(IntegrityError): Book.objects.create( author_id=1, title="Much Ado About Foreign Keys", pub_date=datetime.datetime.now(), ) # Repoint the FK constraint old_field = Book._meta.get_field("author") new_field = ForeignKey(Tag, CASCADE) new_field.set_attributes_from_name("author") with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) self.assertForeignKeyExists(Book, 'author_id', 'schema_tag') @skipUnlessDBFeature('can_create_inline_fk') def test_inline_fk(self): # Create some tables. with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) editor.create_model(Note) self.assertForeignKeyNotExists(Note, 'book_id', 'schema_book') # Add a foreign key from one to the other. with connection.schema_editor() as editor: new_field = ForeignKey(Book, CASCADE) new_field.set_attributes_from_name('book') editor.add_field(Note, new_field) self.assertForeignKeyExists(Note, 'book_id', 'schema_book') # Creating a FK field with a constraint uses a single statement without # a deferred ALTER TABLE. self.assertFalse([ sql for sql in (str(statement) for statement in editor.deferred_sql) if sql.startswith('ALTER TABLE') and 'ADD CONSTRAINT' in sql ]) @skipUnlessDBFeature('can_create_inline_fk') def test_add_inline_fk_update_data(self): with connection.schema_editor() as editor: editor.create_model(Node) # Add an inline foreign key and update data in the same transaction. new_field = ForeignKey(Node, CASCADE, related_name='new_fk', null=True) new_field.set_attributes_from_name('new_parent_fk') parent = Node.objects.create() with connection.schema_editor() as editor: editor.add_field(Node, new_field) editor.execute('UPDATE schema_node SET new_parent_fk_id = %s;', [parent.pk]) assertIndex = ( self.assertIn if connection.features.indexes_foreign_keys else self.assertNotIn ) assertIndex('new_parent_fk_id', self.get_indexes(Node._meta.db_table)) @skipUnlessDBFeature( 'can_create_inline_fk', 'allows_multiple_constraints_on_same_fields', ) @isolate_apps('schema') def test_add_inline_fk_index_update_data(self): class Node(Model): class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Node) # Add an inline foreign key, update data, and an index in the same # transaction. new_field = ForeignKey(Node, CASCADE, related_name='new_fk', null=True) new_field.set_attributes_from_name('new_parent_fk') parent = Node.objects.create() with connection.schema_editor() as editor: editor.add_field(Node, new_field) Node._meta.add_field(new_field) editor.execute('UPDATE schema_node SET new_parent_fk_id = %s;', [parent.pk]) editor.add_index(Node, Index(fields=['new_parent_fk'], name='new_parent_inline_fk_idx')) self.assertIn('new_parent_fk_id', self.get_indexes(Node._meta.db_table)) @skipUnlessDBFeature('supports_foreign_keys') def test_char_field_with_db_index_to_fk(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(AuthorCharFieldWithIndex) # Change CharField to FK old_field = AuthorCharFieldWithIndex._meta.get_field('char_field') new_field = ForeignKey(Author, CASCADE, blank=True) new_field.set_attributes_from_name('char_field') with connection.schema_editor() as editor: editor.alter_field(AuthorCharFieldWithIndex, old_field, new_field, strict=True) self.assertForeignKeyExists(AuthorCharFieldWithIndex, 'char_field_id', 'schema_author') @skipUnlessDBFeature('supports_foreign_keys') @skipUnlessDBFeature('supports_index_on_text_field') def test_text_field_with_db_index_to_fk(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(AuthorTextFieldWithIndex) # Change TextField to FK old_field = AuthorTextFieldWithIndex._meta.get_field('text_field') new_field = ForeignKey(Author, CASCADE, blank=True) new_field.set_attributes_from_name('text_field') with connection.schema_editor() as editor: editor.alter_field(AuthorTextFieldWithIndex, old_field, new_field, strict=True) self.assertForeignKeyExists(AuthorTextFieldWithIndex, 'text_field_id', 'schema_author') @isolate_apps('schema') def test_char_field_pk_to_auto_field(self): class Foo(Model): id = CharField(max_length=255, primary_key=True) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Foo) self.isolated_local_models = [Foo] old_field = Foo._meta.get_field('id') new_field = AutoField(primary_key=True) new_field.set_attributes_from_name('id') new_field.model = Foo with connection.schema_editor() as editor: editor.alter_field(Foo, old_field, new_field, strict=True) @skipUnlessDBFeature('supports_foreign_keys') def test_fk_to_proxy(self): "Creating a FK to a proxy model creates database constraints." class AuthorProxy(Author): class Meta: app_label = 'schema' apps = new_apps proxy = True class AuthorRef(Model): author = ForeignKey(AuthorProxy, on_delete=CASCADE) class Meta: app_label = 'schema' apps = new_apps self.local_models = [AuthorProxy, AuthorRef] # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(AuthorRef) self.assertForeignKeyExists(AuthorRef, 'author_id', 'schema_author') @skipUnlessDBFeature('supports_foreign_keys') def test_fk_db_constraint(self): "The db_constraint parameter is respected" # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) editor.create_model(Author) editor.create_model(BookWeak) # Initial tables are there list(Author.objects.all()) list(Tag.objects.all()) list(BookWeak.objects.all()) self.assertForeignKeyNotExists(BookWeak, 'author_id', 'schema_author') # Make a db_constraint=False FK new_field = ForeignKey(Tag, CASCADE, db_constraint=False) new_field.set_attributes_from_name("tag") with connection.schema_editor() as editor: editor.add_field(Author, new_field) self.assertForeignKeyNotExists(Author, 'tag_id', 'schema_tag') # Alter to one with a constraint new_field2 = ForeignKey(Tag, CASCADE) new_field2.set_attributes_from_name("tag") with connection.schema_editor() as editor: editor.alter_field(Author, new_field, new_field2, strict=True) self.assertForeignKeyExists(Author, 'tag_id', 'schema_tag') # Alter to one without a constraint again new_field2 = ForeignKey(Tag, CASCADE) new_field2.set_attributes_from_name("tag") with connection.schema_editor() as editor: editor.alter_field(Author, new_field2, new_field, strict=True) self.assertForeignKeyNotExists(Author, 'tag_id', 'schema_tag') @isolate_apps('schema') def test_no_db_constraint_added_during_primary_key_change(self): """ When a primary key that's pointed to by a ForeignKey with db_constraint=False is altered, a foreign key constraint isn't added. """ class Author(Model): class Meta: app_label = 'schema' class BookWeak(Model): author = ForeignKey(Author, CASCADE, db_constraint=False) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWeak) self.assertForeignKeyNotExists(BookWeak, 'author_id', 'schema_author') old_field = Author._meta.get_field('id') new_field = BigAutoField(primary_key=True) new_field.model = Author new_field.set_attributes_from_name('id') # @isolate_apps() and inner models are needed to have the model # relations populated, otherwise this doesn't act as a regression test. self.assertEqual(len(new_field.model._meta.related_objects), 1) with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertForeignKeyNotExists(BookWeak, 'author_id', 'schema_author') def _test_m2m_db_constraint(self, M2MFieldClass): class LocalAuthorWithM2M(Model): name = CharField(max_length=255) class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalAuthorWithM2M] # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) editor.create_model(LocalAuthorWithM2M) # Initial tables are there list(LocalAuthorWithM2M.objects.all()) list(Tag.objects.all()) # Make a db_constraint=False FK new_field = M2MFieldClass(Tag, related_name="authors", db_constraint=False) new_field.contribute_to_class(LocalAuthorWithM2M, "tags") # Add the field with connection.schema_editor() as editor: editor.add_field(LocalAuthorWithM2M, new_field) self.assertForeignKeyNotExists(new_field.remote_field.through, 'tag_id', 'schema_tag') @skipUnlessDBFeature('supports_foreign_keys') def test_m2m_db_constraint(self): self._test_m2m_db_constraint(ManyToManyField) @skipUnlessDBFeature('supports_foreign_keys') def test_m2m_db_constraint_custom(self): self._test_m2m_db_constraint(CustomManyToManyField) @skipUnlessDBFeature('supports_foreign_keys') def test_m2m_db_constraint_inherited(self): self._test_m2m_db_constraint(InheritedManyToManyField) def test_add_field(self): """ Tests adding fields to models """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no age field columns = self.column_classes(Author) self.assertNotIn("age", columns) # Add the new field new_field = IntegerField(null=True) new_field.set_attributes_from_name("age") with CaptureQueriesContext(connection) as ctx, connection.schema_editor() as editor: editor.add_field(Author, new_field) drop_default_sql = editor.sql_alter_column_no_default % { 'column': editor.quote_name(new_field.name), } self.assertFalse(any(drop_default_sql in query['sql'] for query in ctx.captured_queries)) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['age'][0], connection.features.introspected_field_types['IntegerField']) self.assertTrue(columns['age'][1][6]) def test_add_field_remove_field(self): """ Adding a field and removing it removes all deferred sql referring to it. """ with connection.schema_editor() as editor: # Create a table with a unique constraint on the slug field. editor.create_model(Tag) # Remove the slug column. editor.remove_field(Tag, Tag._meta.get_field('slug')) self.assertEqual(editor.deferred_sql, []) def test_add_field_temp_default(self): """ Tests adding fields to models with a temporary default """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no age field columns = self.column_classes(Author) self.assertNotIn("age", columns) # Add some rows of data Author.objects.create(name="Andrew", height=30) Author.objects.create(name="Andrea") # Add a not-null field new_field = CharField(max_length=30, default="Godwin") new_field.set_attributes_from_name("surname") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['surname'][0], connection.features.introspected_field_types['CharField']) self.assertEqual(columns['surname'][1][6], connection.features.interprets_empty_strings_as_nulls) def test_add_field_temp_default_boolean(self): """ Tests adding fields to models with a temporary default where the default is False. (#21783) """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no age field columns = self.column_classes(Author) self.assertNotIn("age", columns) # Add some rows of data Author.objects.create(name="Andrew", height=30) Author.objects.create(name="Andrea") # Add a not-null field new_field = BooleanField(default=False) new_field.set_attributes_from_name("awesome") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure the field is right afterwards columns = self.column_classes(Author) # BooleanField are stored as TINYINT(1) on MySQL. field_type = columns['awesome'][0] self.assertEqual(field_type, connection.features.introspected_field_types['BooleanField']) def test_add_field_default_transform(self): """ Tests adding fields to models with a default that is not directly valid in the database (#22581) """ class TestTransformField(IntegerField): # Weird field that saves the count of items in its value def get_default(self): return self.default def get_prep_value(self, value): if value is None: return 0 return len(value) # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Add some rows of data Author.objects.create(name="Andrew", height=30) Author.objects.create(name="Andrea") # Add the field with a default it needs to cast (to string in this case) new_field = TestTransformField(default={1: 2}) new_field.set_attributes_from_name("thing") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure the field is there columns = self.column_classes(Author) field_type, field_info = columns['thing'] self.assertEqual(field_type, connection.features.introspected_field_types['IntegerField']) # Make sure the values were transformed correctly self.assertEqual(Author.objects.extra(where=["thing = 1"]).count(), 2) def test_add_field_binary(self): """ Tests binary fields get a sane default (#22851) """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Add the new field new_field = BinaryField(blank=True) new_field.set_attributes_from_name("bits") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure the field is right afterwards columns = self.column_classes(Author) # MySQL annoyingly uses the same backend, so it'll come back as one of # these two types. self.assertIn(columns['bits'][0], ("BinaryField", "TextField")) @unittest.skipUnless(connection.vendor == 'mysql', "MySQL specific") def test_add_binaryfield_mediumblob(self): """ Test adding a custom-sized binary field on MySQL (#24846). """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Add the new field with default new_field = MediumBlobField(blank=True, default=b'123') new_field.set_attributes_from_name('bits') with connection.schema_editor() as editor: editor.add_field(Author, new_field) columns = self.column_classes(Author) # Introspection treats BLOBs as TextFields self.assertEqual(columns['bits'][0], "TextField") def test_alter(self): """ Tests simple altering of fields """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with columns = self.column_classes(Author) self.assertEqual(columns['name'][0], connection.features.introspected_field_types['CharField']) self.assertEqual(bool(columns['name'][1][6]), bool(connection.features.interprets_empty_strings_as_nulls)) # Alter the name field to a TextField old_field = Author._meta.get_field("name") new_field = TextField(null=True) new_field.set_attributes_from_name("name") with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['name'][0], "TextField") self.assertTrue(columns['name'][1][6]) # Change nullability again new_field2 = TextField(null=False) new_field2.set_attributes_from_name("name") with connection.schema_editor() as editor: editor.alter_field(Author, new_field, new_field2, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['name'][0], "TextField") self.assertEqual(bool(columns['name'][1][6]), bool(connection.features.interprets_empty_strings_as_nulls)) def test_alter_auto_field_to_integer_field(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Change AutoField to IntegerField old_field = Author._meta.get_field('id') new_field = IntegerField(primary_key=True) new_field.set_attributes_from_name('id') new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) # Now that ID is an IntegerField, the database raises an error if it # isn't provided. if not connection.features.supports_unspecified_pk: with self.assertRaises(DatabaseError): Author.objects.create() def test_alter_auto_field_to_char_field(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Change AutoField to CharField old_field = Author._meta.get_field('id') new_field = CharField(primary_key=True, max_length=50) new_field.set_attributes_from_name('id') new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) @isolate_apps('schema') def test_alter_auto_field_quoted_db_column(self): class Foo(Model): id = AutoField(primary_key=True, db_column='"quoted_id"') class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Foo) self.isolated_local_models = [Foo] old_field = Foo._meta.get_field('id') new_field = BigAutoField(primary_key=True) new_field.model = Foo new_field.db_column = '"quoted_id"' new_field.set_attributes_from_name('id') with connection.schema_editor() as editor: editor.alter_field(Foo, old_field, new_field, strict=True) Foo.objects.create() def test_alter_not_unique_field_to_primary_key(self): # Create the table. with connection.schema_editor() as editor: editor.create_model(Author) # Change UUIDField to primary key. old_field = Author._meta.get_field('uuid') new_field = UUIDField(primary_key=True) new_field.set_attributes_from_name('uuid') new_field.model = Author with connection.schema_editor() as editor: editor.remove_field(Author, Author._meta.get_field('id')) editor.alter_field(Author, old_field, new_field, strict=True) @isolate_apps('schema') def test_alter_primary_key_quoted_db_table(self): class Foo(Model): class Meta: app_label = 'schema' db_table = '"foo"' with connection.schema_editor() as editor: editor.create_model(Foo) self.isolated_local_models = [Foo] old_field = Foo._meta.get_field('id') new_field = BigAutoField(primary_key=True) new_field.model = Foo new_field.set_attributes_from_name('id') with connection.schema_editor() as editor: editor.alter_field(Foo, old_field, new_field, strict=True) Foo.objects.create() def test_alter_text_field(self): # Regression for "BLOB/TEXT column 'info' can't have a default value") # on MySQL. # Create the table with connection.schema_editor() as editor: editor.create_model(Note) old_field = Note._meta.get_field("info") new_field = TextField(blank=True) new_field.set_attributes_from_name("info") with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) def test_alter_text_field_to_not_null_with_default_value(self): with connection.schema_editor() as editor: editor.create_model(Note) old_field = Note._meta.get_field('address') new_field = TextField(blank=True, default='', null=False) new_field.set_attributes_from_name('address') with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) @skipUnlessDBFeature('can_defer_constraint_checks', 'can_rollback_ddl') def test_alter_fk_checks_deferred_constraints(self): """ #25492 - Altering a foreign key's structure and data in the same transaction. """ with connection.schema_editor() as editor: editor.create_model(Node) old_field = Node._meta.get_field('parent') new_field = ForeignKey(Node, CASCADE) new_field.set_attributes_from_name('parent') parent = Node.objects.create() with connection.schema_editor() as editor: # Update the parent FK to create a deferred constraint check. Node.objects.update(parent=parent) editor.alter_field(Node, old_field, new_field, strict=True) def test_alter_text_field_to_date_field(self): """ #25002 - Test conversion of text field to date field. """ with connection.schema_editor() as editor: editor.create_model(Note) Note.objects.create(info='1988-05-05') old_field = Note._meta.get_field('info') new_field = DateField(blank=True) new_field.set_attributes_from_name('info') with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) # Make sure the field isn't nullable columns = self.column_classes(Note) self.assertFalse(columns['info'][1][6]) def test_alter_text_field_to_datetime_field(self): """ #25002 - Test conversion of text field to datetime field. """ with connection.schema_editor() as editor: editor.create_model(Note) Note.objects.create(info='1988-05-05 3:16:17.4567') old_field = Note._meta.get_field('info') new_field = DateTimeField(blank=True) new_field.set_attributes_from_name('info') with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) # Make sure the field isn't nullable columns = self.column_classes(Note) self.assertFalse(columns['info'][1][6]) def test_alter_text_field_to_time_field(self): """ #25002 - Test conversion of text field to time field. """ with connection.schema_editor() as editor: editor.create_model(Note) Note.objects.create(info='3:16:17.4567') old_field = Note._meta.get_field('info') new_field = TimeField(blank=True) new_field.set_attributes_from_name('info') with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) # Make sure the field isn't nullable columns = self.column_classes(Note) self.assertFalse(columns['info'][1][6]) @skipIfDBFeature('interprets_empty_strings_as_nulls') def test_alter_textual_field_keep_null_status(self): """ Changing a field type shouldn't affect the not null status. """ with connection.schema_editor() as editor: editor.create_model(Note) with self.assertRaises(IntegrityError): Note.objects.create(info=None) old_field = Note._meta.get_field("info") new_field = CharField(max_length=50) new_field.set_attributes_from_name("info") with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) with self.assertRaises(IntegrityError): Note.objects.create(info=None) def test_alter_numeric_field_keep_null_status(self): """ Changing a field type shouldn't affect the not null status. """ with connection.schema_editor() as editor: editor.create_model(UniqueTest) with self.assertRaises(IntegrityError): UniqueTest.objects.create(year=None, slug='aaa') old_field = UniqueTest._meta.get_field("year") new_field = BigIntegerField() new_field.set_attributes_from_name("year") with connection.schema_editor() as editor: editor.alter_field(UniqueTest, old_field, new_field, strict=True) with self.assertRaises(IntegrityError): UniqueTest.objects.create(year=None, slug='bbb') def test_alter_null_to_not_null(self): """ #23609 - Tests handling of default values when altering from NULL to NOT NULL. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with columns = self.column_classes(Author) self.assertTrue(columns['height'][1][6]) # Create some test data Author.objects.create(name='Not null author', height=12) Author.objects.create(name='Null author') # Verify null value self.assertEqual(Author.objects.get(name='Not null author').height, 12) self.assertIsNone(Author.objects.get(name='Null author').height) # Alter the height field to NOT NULL with default old_field = Author._meta.get_field("height") new_field = PositiveIntegerField(default=42) new_field.set_attributes_from_name("height") with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertFalse(columns['height'][1][6]) # Verify default value self.assertEqual(Author.objects.get(name='Not null author').height, 12) self.assertEqual(Author.objects.get(name='Null author').height, 42) def test_alter_charfield_to_null(self): """ #24307 - Should skip an alter statement on databases with interprets_empty_strings_as_null when changing a CharField to null. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Change the CharField to null old_field = Author._meta.get_field('name') new_field = copy(old_field) new_field.null = True with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific') def test_alter_char_field_decrease_length(self): # Create the table. with connection.schema_editor() as editor: editor.create_model(Author) Author.objects.create(name='x' * 255) # Change max_length of CharField. old_field = Author._meta.get_field('name') new_field = CharField(max_length=254) new_field.set_attributes_from_name('name') with connection.schema_editor() as editor: msg = 'value too long for type character varying(254)' with self.assertRaisesMessage(DataError, msg): editor.alter_field(Author, old_field, new_field, strict=True) @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific') def test_alter_field_with_custom_db_type(self): from django.contrib.postgres.fields import ArrayField class Foo(Model): field = ArrayField(CharField(max_length=255)) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Foo) self.isolated_local_models = [Foo] old_field = Foo._meta.get_field('field') new_field = ArrayField(CharField(max_length=16)) new_field.set_attributes_from_name('field') new_field.model = Foo with connection.schema_editor() as editor: editor.alter_field(Foo, old_field, new_field, strict=True) @isolate_apps('schema') @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific') def test_alter_array_field_decrease_base_field_length(self): from django.contrib.postgres.fields import ArrayField class ArrayModel(Model): field = ArrayField(CharField(max_length=16)) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(ArrayModel) self.isolated_local_models = [ArrayModel] ArrayModel.objects.create(field=['x' * 16]) old_field = ArrayModel._meta.get_field('field') new_field = ArrayField(CharField(max_length=15)) new_field.set_attributes_from_name('field') new_field.model = ArrayModel with connection.schema_editor() as editor: msg = 'value too long for type character varying(15)' with self.assertRaisesMessage(DataError, msg): editor.alter_field(ArrayModel, old_field, new_field, strict=True) @isolate_apps('schema') @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific') def test_alter_array_field_decrease_nested_base_field_length(self): from django.contrib.postgres.fields import ArrayField class ArrayModel(Model): field = ArrayField(ArrayField(CharField(max_length=16))) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(ArrayModel) self.isolated_local_models = [ArrayModel] ArrayModel.objects.create(field=[['x' * 16]]) old_field = ArrayModel._meta.get_field('field') new_field = ArrayField(ArrayField(CharField(max_length=15))) new_field.set_attributes_from_name('field') new_field.model = ArrayModel with connection.schema_editor() as editor: msg = 'value too long for type character varying(15)' with self.assertRaisesMessage(DataError, msg): editor.alter_field(ArrayModel, old_field, new_field, strict=True) def test_alter_textfield_to_null(self): """ #24307 - Should skip an alter statement on databases with interprets_empty_strings_as_null when changing a TextField to null. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Note) # Change the TextField to null old_field = Note._meta.get_field('info') new_field = copy(old_field) new_field.null = True with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) @skipUnlessDBFeature('supports_combined_alters') def test_alter_null_to_not_null_keeping_default(self): """ #23738 - Can change a nullable field with default to non-nullable with the same default. """ # Create the table with connection.schema_editor() as editor: editor.create_model(AuthorWithDefaultHeight) # Ensure the field is right to begin with columns = self.column_classes(AuthorWithDefaultHeight) self.assertTrue(columns['height'][1][6]) # Alter the height field to NOT NULL keeping the previous default old_field = AuthorWithDefaultHeight._meta.get_field("height") new_field = PositiveIntegerField(default=42) new_field.set_attributes_from_name("height") with connection.schema_editor() as editor: editor.alter_field(AuthorWithDefaultHeight, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(AuthorWithDefaultHeight) self.assertFalse(columns['height'][1][6]) @skipUnlessDBFeature('supports_foreign_keys') def test_alter_fk(self): """ Tests altering of FKs """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the field is right to begin with columns = self.column_classes(Book) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) self.assertForeignKeyExists(Book, 'author_id', 'schema_author') # Alter the FK old_field = Book._meta.get_field("author") new_field = ForeignKey(Author, CASCADE, editable=False) new_field.set_attributes_from_name("author") with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Book) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) self.assertForeignKeyExists(Book, 'author_id', 'schema_author') @skipUnlessDBFeature('supports_foreign_keys') def test_alter_to_fk(self): """ #24447 - Tests adding a FK constraint for an existing column """ class LocalBook(Model): author = IntegerField() title = CharField(max_length=100, db_index=True) pub_date = DateTimeField() class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalBook] # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(LocalBook) # Ensure no FK constraint exists constraints = self.get_constraints(LocalBook._meta.db_table) for details in constraints.values(): if details['foreign_key']: self.fail('Found an unexpected FK constraint to %s' % details['columns']) old_field = LocalBook._meta.get_field("author") new_field = ForeignKey(Author, CASCADE) new_field.set_attributes_from_name("author") with connection.schema_editor() as editor: editor.alter_field(LocalBook, old_field, new_field, strict=True) self.assertForeignKeyExists(LocalBook, 'author_id', 'schema_author') @skipUnlessDBFeature('supports_foreign_keys') def test_alter_o2o_to_fk(self): """ #24163 - Tests altering of OneToOneField to ForeignKey """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithO2O) # Ensure the field is right to begin with columns = self.column_classes(BookWithO2O) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) # Ensure the field is unique author = Author.objects.create(name="Joe") BookWithO2O.objects.create(author=author, title="Django 1", pub_date=datetime.datetime.now()) with self.assertRaises(IntegrityError): BookWithO2O.objects.create(author=author, title="Django 2", pub_date=datetime.datetime.now()) BookWithO2O.objects.all().delete() self.assertForeignKeyExists(BookWithO2O, 'author_id', 'schema_author') # Alter the OneToOneField to ForeignKey old_field = BookWithO2O._meta.get_field("author") new_field = ForeignKey(Author, CASCADE) new_field.set_attributes_from_name("author") with connection.schema_editor() as editor: editor.alter_field(BookWithO2O, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Book) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) # Ensure the field is not unique anymore Book.objects.create(author=author, title="Django 1", pub_date=datetime.datetime.now()) Book.objects.create(author=author, title="Django 2", pub_date=datetime.datetime.now()) self.assertForeignKeyExists(Book, 'author_id', 'schema_author') @skipUnlessDBFeature('supports_foreign_keys') def test_alter_fk_to_o2o(self): """ #24163 - Tests altering of ForeignKey to OneToOneField """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the field is right to begin with columns = self.column_classes(Book) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) # Ensure the field is not unique author = Author.objects.create(name="Joe") Book.objects.create(author=author, title="Django 1", pub_date=datetime.datetime.now()) Book.objects.create(author=author, title="Django 2", pub_date=datetime.datetime.now()) Book.objects.all().delete() self.assertForeignKeyExists(Book, 'author_id', 'schema_author') # Alter the ForeignKey to OneToOneField old_field = Book._meta.get_field("author") new_field = OneToOneField(Author, CASCADE) new_field.set_attributes_from_name("author") with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(BookWithO2O) self.assertEqual(columns['author_id'][0], connection.features.introspected_field_types['IntegerField']) # Ensure the field is unique now BookWithO2O.objects.create(author=author, title="Django 1", pub_date=datetime.datetime.now()) with self.assertRaises(IntegrityError): BookWithO2O.objects.create(author=author, title="Django 2", pub_date=datetime.datetime.now()) self.assertForeignKeyExists(BookWithO2O, 'author_id', 'schema_author') def test_alter_field_fk_to_o2o(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) expected_fks = 1 if connection.features.supports_foreign_keys else 0 expected_indexes = 1 if connection.features.indexes_foreign_keys else 0 # Check the index is right to begin with. counts = self.get_constraints_count( Book._meta.db_table, Book._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) self.assertEqual( counts, {'fks': expected_fks, 'uniques': 0, 'indexes': expected_indexes}, ) old_field = Book._meta.get_field('author') new_field = OneToOneField(Author, CASCADE) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) counts = self.get_constraints_count( Book._meta.db_table, Book._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) # The index on ForeignKey is replaced with a unique constraint for OneToOneField. self.assertEqual(counts, {'fks': expected_fks, 'uniques': 1, 'indexes': 0}) def test_alter_field_fk_keeps_index(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) expected_fks = 1 if connection.features.supports_foreign_keys else 0 expected_indexes = 1 if connection.features.indexes_foreign_keys else 0 # Check the index is right to begin with. counts = self.get_constraints_count( Book._meta.db_table, Book._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) self.assertEqual( counts, {'fks': expected_fks, 'uniques': 0, 'indexes': expected_indexes}, ) old_field = Book._meta.get_field('author') # on_delete changed from CASCADE. new_field = ForeignKey(Author, PROTECT) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) counts = self.get_constraints_count( Book._meta.db_table, Book._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) # The index remains. self.assertEqual( counts, {'fks': expected_fks, 'uniques': 0, 'indexes': expected_indexes}, ) def test_alter_field_o2o_to_fk(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithO2O) expected_fks = 1 if connection.features.supports_foreign_keys else 0 # Check the unique constraint is right to begin with. counts = self.get_constraints_count( BookWithO2O._meta.db_table, BookWithO2O._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) self.assertEqual(counts, {'fks': expected_fks, 'uniques': 1, 'indexes': 0}) old_field = BookWithO2O._meta.get_field('author') new_field = ForeignKey(Author, CASCADE) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.alter_field(BookWithO2O, old_field, new_field, strict=True) counts = self.get_constraints_count( BookWithO2O._meta.db_table, BookWithO2O._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) # The unique constraint on OneToOneField is replaced with an index for ForeignKey. self.assertEqual(counts, {'fks': expected_fks, 'uniques': 0, 'indexes': 1}) def test_alter_field_o2o_keeps_unique(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithO2O) expected_fks = 1 if connection.features.supports_foreign_keys else 0 # Check the unique constraint is right to begin with. counts = self.get_constraints_count( BookWithO2O._meta.db_table, BookWithO2O._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) self.assertEqual(counts, {'fks': expected_fks, 'uniques': 1, 'indexes': 0}) old_field = BookWithO2O._meta.get_field('author') # on_delete changed from CASCADE. new_field = OneToOneField(Author, PROTECT) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.alter_field(BookWithO2O, old_field, new_field, strict=True) counts = self.get_constraints_count( BookWithO2O._meta.db_table, BookWithO2O._meta.get_field('author').column, (Author._meta.db_table, Author._meta.pk.column), ) # The unique constraint remains. self.assertEqual(counts, {'fks': expected_fks, 'uniques': 1, 'indexes': 0}) @skipUnlessDBFeature('ignores_table_name_case') def test_alter_db_table_case(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Alter the case of the table old_table_name = Author._meta.db_table with connection.schema_editor() as editor: editor.alter_db_table(Author, old_table_name, old_table_name.upper()) def test_alter_implicit_id_to_explicit(self): """ Should be able to convert an implicit "id" field to an explicit "id" primary key field. """ with connection.schema_editor() as editor: editor.create_model(Author) old_field = Author._meta.get_field("id") new_field = AutoField(primary_key=True) new_field.set_attributes_from_name("id") new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) # This will fail if DROP DEFAULT is inadvertently executed on this # field which drops the id sequence, at least on PostgreSQL. Author.objects.create(name='Foo') Author.objects.create(name='Bar') def test_alter_autofield_pk_to_bigautofield_pk_sequence_owner(self): """ Converting an implicit PK to BigAutoField(primary_key=True) should keep a sequence owner on PostgreSQL. """ with connection.schema_editor() as editor: editor.create_model(Author) old_field = Author._meta.get_field('id') new_field = BigAutoField(primary_key=True) new_field.set_attributes_from_name('id') new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) Author.objects.create(name='Foo', pk=1) with connection.cursor() as cursor: sequence_reset_sqls = connection.ops.sequence_reset_sql(no_style(), [Author]) if sequence_reset_sqls: cursor.execute(sequence_reset_sqls[0]) # Fail on PostgreSQL if sequence is missing an owner. self.assertIsNotNone(Author.objects.create(name='Bar')) def test_alter_autofield_pk_to_smallautofield_pk_sequence_owner(self): """ Converting an implicit PK to SmallAutoField(primary_key=True) should keep a sequence owner on PostgreSQL. """ with connection.schema_editor() as editor: editor.create_model(Author) old_field = Author._meta.get_field('id') new_field = SmallAutoField(primary_key=True) new_field.set_attributes_from_name('id') new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) Author.objects.create(name='Foo', pk=1) with connection.cursor() as cursor: sequence_reset_sqls = connection.ops.sequence_reset_sql(no_style(), [Author]) if sequence_reset_sqls: cursor.execute(sequence_reset_sqls[0]) # Fail on PostgreSQL if sequence is missing an owner. self.assertIsNotNone(Author.objects.create(name='Bar')) def test_alter_int_pk_to_autofield_pk(self): """ Should be able to rename an IntegerField(primary_key=True) to AutoField(primary_key=True). """ with connection.schema_editor() as editor: editor.create_model(IntegerPK) old_field = IntegerPK._meta.get_field('i') new_field = AutoField(primary_key=True) new_field.model = IntegerPK new_field.set_attributes_from_name('i') with connection.schema_editor() as editor: editor.alter_field(IntegerPK, old_field, new_field, strict=True) # A model representing the updated model. class IntegerPKToAutoField(Model): i = AutoField(primary_key=True) j = IntegerField(unique=True) class Meta: app_label = 'schema' apps = new_apps db_table = IntegerPK._meta.db_table # An id (i) is generated by the database. obj = IntegerPKToAutoField.objects.create(j=1) self.assertIsNotNone(obj.i) def test_alter_int_pk_to_bigautofield_pk(self): """ Should be able to rename an IntegerField(primary_key=True) to BigAutoField(primary_key=True). """ with connection.schema_editor() as editor: editor.create_model(IntegerPK) old_field = IntegerPK._meta.get_field('i') new_field = BigAutoField(primary_key=True) new_field.model = IntegerPK new_field.set_attributes_from_name('i') with connection.schema_editor() as editor: editor.alter_field(IntegerPK, old_field, new_field, strict=True) # A model representing the updated model. class IntegerPKToBigAutoField(Model): i = BigAutoField(primary_key=True) j = IntegerField(unique=True) class Meta: app_label = 'schema' apps = new_apps db_table = IntegerPK._meta.db_table # An id (i) is generated by the database. obj = IntegerPKToBigAutoField.objects.create(j=1) self.assertIsNotNone(obj.i) @isolate_apps('schema') def test_alter_smallint_pk_to_smallautofield_pk(self): """ Should be able to rename an SmallIntegerField(primary_key=True) to SmallAutoField(primary_key=True). """ class SmallIntegerPK(Model): i = SmallIntegerField(primary_key=True) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(SmallIntegerPK) self.isolated_local_models = [SmallIntegerPK] old_field = SmallIntegerPK._meta.get_field('i') new_field = SmallAutoField(primary_key=True) new_field.model = SmallIntegerPK new_field.set_attributes_from_name('i') with connection.schema_editor() as editor: editor.alter_field(SmallIntegerPK, old_field, new_field, strict=True) def test_alter_int_pk_to_int_unique(self): """ Should be able to rename an IntegerField(primary_key=True) to IntegerField(unique=True). """ with connection.schema_editor() as editor: editor.create_model(IntegerPK) # Delete the old PK old_field = IntegerPK._meta.get_field('i') new_field = IntegerField(unique=True) new_field.model = IntegerPK new_field.set_attributes_from_name('i') with connection.schema_editor() as editor: editor.alter_field(IntegerPK, old_field, new_field, strict=True) # The primary key constraint is gone. Result depends on database: # 'id' for SQLite, None for others (must not be 'i'). self.assertIn(self.get_primary_key(IntegerPK._meta.db_table), ('id', None)) # Set up a model class as it currently stands. The original IntegerPK # class is now out of date and some backends make use of the whole # model class when modifying a field (such as sqlite3 when remaking a # table) so an outdated model class leads to incorrect results. class Transitional(Model): i = IntegerField(unique=True) j = IntegerField(unique=True) class Meta: app_label = 'schema' apps = new_apps db_table = 'INTEGERPK' # model requires a new PK old_field = Transitional._meta.get_field('j') new_field = IntegerField(primary_key=True) new_field.model = Transitional new_field.set_attributes_from_name('j') with connection.schema_editor() as editor: editor.alter_field(Transitional, old_field, new_field, strict=True) # Create a model class representing the updated model. class IntegerUnique(Model): i = IntegerField(unique=True) j = IntegerField(primary_key=True) class Meta: app_label = 'schema' apps = new_apps db_table = 'INTEGERPK' # Ensure unique constraint works. IntegerUnique.objects.create(i=1, j=1) with self.assertRaises(IntegrityError): IntegerUnique.objects.create(i=1, j=2) def test_rename(self): """ Tests simple altering of fields """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the field is right to begin with columns = self.column_classes(Author) self.assertEqual(columns['name'][0], connection.features.introspected_field_types['CharField']) self.assertNotIn("display_name", columns) # Alter the name field's name old_field = Author._meta.get_field("name") new_field = CharField(max_length=254) new_field.set_attributes_from_name("display_name") with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) # Ensure the field is right afterwards columns = self.column_classes(Author) self.assertEqual(columns['display_name'][0], connection.features.introspected_field_types['CharField']) self.assertNotIn("name", columns) @isolate_apps('schema') def test_rename_referenced_field(self): class Author(Model): name = CharField(max_length=255, unique=True) class Meta: app_label = 'schema' class Book(Model): author = ForeignKey(Author, CASCADE, to_field='name') class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) new_field = CharField(max_length=255, unique=True) new_field.set_attributes_from_name('renamed') with connection.schema_editor(atomic=connection.features.supports_atomic_references_rename) as editor: editor.alter_field(Author, Author._meta.get_field('name'), new_field) # Ensure the foreign key reference was updated. self.assertForeignKeyExists(Book, 'author_id', 'schema_author', 'renamed') @skipIfDBFeature('interprets_empty_strings_as_nulls') def test_rename_keep_null_status(self): """ Renaming a field shouldn't affect the not null status. """ with connection.schema_editor() as editor: editor.create_model(Note) with self.assertRaises(IntegrityError): Note.objects.create(info=None) old_field = Note._meta.get_field("info") new_field = TextField() new_field.set_attributes_from_name("detail_info") with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) columns = self.column_classes(Note) self.assertEqual(columns['detail_info'][0], "TextField") self.assertNotIn("info", columns) with self.assertRaises(IntegrityError): NoteRename.objects.create(detail_info=None) def _test_m2m_create(self, M2MFieldClass): """ Tests M2M fields on models during creation """ class LocalBookWithM2M(Model): author = ForeignKey(Author, CASCADE) title = CharField(max_length=100, db_index=True) pub_date = DateTimeField() tags = M2MFieldClass("TagM2MTest", related_name="books") class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalBookWithM2M] # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(TagM2MTest) editor.create_model(LocalBookWithM2M) # Ensure there is now an m2m table there columns = self.column_classes(LocalBookWithM2M._meta.get_field("tags").remote_field.through) self.assertEqual(columns['tagm2mtest_id'][0], connection.features.introspected_field_types['IntegerField']) def test_m2m_create(self): self._test_m2m_create(ManyToManyField) def test_m2m_create_custom(self): self._test_m2m_create(CustomManyToManyField) def test_m2m_create_inherited(self): self._test_m2m_create(InheritedManyToManyField) def _test_m2m_create_through(self, M2MFieldClass): """ Tests M2M fields on models during creation with through models """ class LocalTagThrough(Model): book = ForeignKey("schema.LocalBookWithM2MThrough", CASCADE) tag = ForeignKey("schema.TagM2MTest", CASCADE) class Meta: app_label = 'schema' apps = new_apps class LocalBookWithM2MThrough(Model): tags = M2MFieldClass("TagM2MTest", related_name="books", through=LocalTagThrough) class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalTagThrough, LocalBookWithM2MThrough] # Create the tables with connection.schema_editor() as editor: editor.create_model(LocalTagThrough) editor.create_model(TagM2MTest) editor.create_model(LocalBookWithM2MThrough) # Ensure there is now an m2m table there columns = self.column_classes(LocalTagThrough) self.assertEqual(columns['book_id'][0], connection.features.introspected_field_types['IntegerField']) self.assertEqual(columns['tag_id'][0], connection.features.introspected_field_types['IntegerField']) def test_m2m_create_through(self): self._test_m2m_create_through(ManyToManyField) def test_m2m_create_through_custom(self): self._test_m2m_create_through(CustomManyToManyField) def test_m2m_create_through_inherited(self): self._test_m2m_create_through(InheritedManyToManyField) def _test_m2m(self, M2MFieldClass): """ Tests adding/removing M2M fields on models """ class LocalAuthorWithM2M(Model): name = CharField(max_length=255) class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalAuthorWithM2M] # Create the tables with connection.schema_editor() as editor: editor.create_model(LocalAuthorWithM2M) editor.create_model(TagM2MTest) # Create an M2M field new_field = M2MFieldClass("schema.TagM2MTest", related_name="authors") new_field.contribute_to_class(LocalAuthorWithM2M, "tags") # Ensure there's no m2m table there with self.assertRaises(DatabaseError): self.column_classes(new_field.remote_field.through) # Add the field with connection.schema_editor() as editor: editor.add_field(LocalAuthorWithM2M, new_field) # Ensure there is now an m2m table there columns = self.column_classes(new_field.remote_field.through) self.assertEqual(columns['tagm2mtest_id'][0], connection.features.introspected_field_types['IntegerField']) # "Alter" the field. This should not rename the DB table to itself. with connection.schema_editor() as editor: editor.alter_field(LocalAuthorWithM2M, new_field, new_field, strict=True) # Remove the M2M table again with connection.schema_editor() as editor: editor.remove_field(LocalAuthorWithM2M, new_field) # Ensure there's no m2m table there with self.assertRaises(DatabaseError): self.column_classes(new_field.remote_field.through) # Make sure the model state is coherent with the table one now that # we've removed the tags field. opts = LocalAuthorWithM2M._meta opts.local_many_to_many.remove(new_field) del new_apps.all_models['schema'][new_field.remote_field.through._meta.model_name] opts._expire_cache() def test_m2m(self): self._test_m2m(ManyToManyField) def test_m2m_custom(self): self._test_m2m(CustomManyToManyField) def test_m2m_inherited(self): self._test_m2m(InheritedManyToManyField) def _test_m2m_through_alter(self, M2MFieldClass): """ Tests altering M2Ms with explicit through models (should no-op) """ class LocalAuthorTag(Model): author = ForeignKey("schema.LocalAuthorWithM2MThrough", CASCADE) tag = ForeignKey("schema.TagM2MTest", CASCADE) class Meta: app_label = 'schema' apps = new_apps class LocalAuthorWithM2MThrough(Model): name = CharField(max_length=255) tags = M2MFieldClass("schema.TagM2MTest", related_name="authors", through=LocalAuthorTag) class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalAuthorTag, LocalAuthorWithM2MThrough] # Create the tables with connection.schema_editor() as editor: editor.create_model(LocalAuthorTag) editor.create_model(LocalAuthorWithM2MThrough) editor.create_model(TagM2MTest) # Ensure the m2m table is there self.assertEqual(len(self.column_classes(LocalAuthorTag)), 3) # "Alter" the field's blankness. This should not actually do anything. old_field = LocalAuthorWithM2MThrough._meta.get_field("tags") new_field = M2MFieldClass("schema.TagM2MTest", related_name="authors", through=LocalAuthorTag) new_field.contribute_to_class(LocalAuthorWithM2MThrough, "tags") with connection.schema_editor() as editor: editor.alter_field(LocalAuthorWithM2MThrough, old_field, new_field, strict=True) # Ensure the m2m table is still there self.assertEqual(len(self.column_classes(LocalAuthorTag)), 3) def test_m2m_through_alter(self): self._test_m2m_through_alter(ManyToManyField) def test_m2m_through_alter_custom(self): self._test_m2m_through_alter(CustomManyToManyField) def test_m2m_through_alter_inherited(self): self._test_m2m_through_alter(InheritedManyToManyField) def _test_m2m_repoint(self, M2MFieldClass): """ Tests repointing M2M fields """ class LocalBookWithM2M(Model): author = ForeignKey(Author, CASCADE) title = CharField(max_length=100, db_index=True) pub_date = DateTimeField() tags = M2MFieldClass("TagM2MTest", related_name="books") class Meta: app_label = 'schema' apps = new_apps self.local_models = [LocalBookWithM2M] # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(LocalBookWithM2M) editor.create_model(TagM2MTest) editor.create_model(UniqueTest) # Ensure the M2M exists and points to TagM2MTest if connection.features.supports_foreign_keys: self.assertForeignKeyExists( LocalBookWithM2M._meta.get_field("tags").remote_field.through, 'tagm2mtest_id', 'schema_tagm2mtest', ) # Repoint the M2M old_field = LocalBookWithM2M._meta.get_field("tags") new_field = M2MFieldClass(UniqueTest) new_field.contribute_to_class(LocalBookWithM2M, "uniques") with connection.schema_editor() as editor: editor.alter_field(LocalBookWithM2M, old_field, new_field, strict=True) # Ensure old M2M is gone with self.assertRaises(DatabaseError): self.column_classes(LocalBookWithM2M._meta.get_field("tags").remote_field.through) # This model looks like the new model and is used for teardown. opts = LocalBookWithM2M._meta opts.local_many_to_many.remove(old_field) # Ensure the new M2M exists and points to UniqueTest if connection.features.supports_foreign_keys: self.assertForeignKeyExists(new_field.remote_field.through, 'uniquetest_id', 'schema_uniquetest') def test_m2m_repoint(self): self._test_m2m_repoint(ManyToManyField) def test_m2m_repoint_custom(self): self._test_m2m_repoint(CustomManyToManyField) def test_m2m_repoint_inherited(self): self._test_m2m_repoint(InheritedManyToManyField) @isolate_apps('schema') def test_m2m_rename_field_in_target_model(self): class LocalTagM2MTest(Model): title = CharField(max_length=255) class Meta: app_label = 'schema' class LocalM2M(Model): tags = ManyToManyField(LocalTagM2MTest) class Meta: app_label = 'schema' # Create the tables. with connection.schema_editor() as editor: editor.create_model(LocalM2M) editor.create_model(LocalTagM2MTest) self.isolated_local_models = [LocalM2M, LocalTagM2MTest] # Ensure the m2m table is there. self.assertEqual(len(self.column_classes(LocalM2M)), 1) # Alter a field in LocalTagM2MTest. old_field = LocalTagM2MTest._meta.get_field('title') new_field = CharField(max_length=254) new_field.contribute_to_class(LocalTagM2MTest, 'title1') # @isolate_apps() and inner models are needed to have the model # relations populated, otherwise this doesn't act as a regression test. self.assertEqual(len(new_field.model._meta.related_objects), 1) with connection.schema_editor() as editor: editor.alter_field(LocalTagM2MTest, old_field, new_field, strict=True) # Ensure the m2m table is still there. self.assertEqual(len(self.column_classes(LocalM2M)), 1) @skipUnlessDBFeature('supports_column_check_constraints', 'can_introspect_check_constraints') def test_check_constraints(self): """ Tests creating/deleting CHECK constraints """ # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the constraint exists constraints = self.get_constraints(Author._meta.db_table) if not any(details['columns'] == ['height'] and details['check'] for details in constraints.values()): self.fail("No check constraint for height found") # Alter the column to remove it old_field = Author._meta.get_field("height") new_field = IntegerField(null=True, blank=True) new_field.set_attributes_from_name("height") with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) constraints = self.get_constraints(Author._meta.db_table) for details in constraints.values(): if details['columns'] == ["height"] and details['check']: self.fail("Check constraint for height found") # Alter the column to re-add it new_field2 = Author._meta.get_field("height") with connection.schema_editor() as editor: editor.alter_field(Author, new_field, new_field2, strict=True) constraints = self.get_constraints(Author._meta.db_table) if not any(details['columns'] == ['height'] and details['check'] for details in constraints.values()): self.fail("No check constraint for height found") @skipUnlessDBFeature('supports_column_check_constraints', 'can_introspect_check_constraints') def test_remove_field_check_does_not_remove_meta_constraints(self): with connection.schema_editor() as editor: editor.create_model(Author) # Add the custom check constraint constraint = CheckConstraint(check=Q(height__gte=0), name='author_height_gte_0_check') custom_constraint_name = constraint.name Author._meta.constraints = [constraint] with connection.schema_editor() as editor: editor.add_constraint(Author, constraint) # Ensure the constraints exist constraints = self.get_constraints(Author._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['height'] and details['check'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Alter the column to remove field check old_field = Author._meta.get_field('height') new_field = IntegerField(null=True, blank=True) new_field.set_attributes_from_name('height') with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) constraints = self.get_constraints(Author._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['height'] and details['check'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 0) # Alter the column to re-add field check new_field2 = Author._meta.get_field('height') with connection.schema_editor() as editor: editor.alter_field(Author, new_field, new_field2, strict=True) constraints = self.get_constraints(Author._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['height'] and details['check'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Drop the check constraint with connection.schema_editor() as editor: Author._meta.constraints = [] editor.remove_constraint(Author, constraint) def test_unique(self): """ Tests removing and adding unique constraints to a single column. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure the field is unique to begin with Tag.objects.create(title="foo", slug="foo") with self.assertRaises(IntegrityError): Tag.objects.create(title="bar", slug="foo") Tag.objects.all().delete() # Alter the slug field to be non-unique old_field = Tag._meta.get_field("slug") new_field = SlugField(unique=False) new_field.set_attributes_from_name("slug") with connection.schema_editor() as editor: editor.alter_field(Tag, old_field, new_field, strict=True) # Ensure the field is no longer unique Tag.objects.create(title="foo", slug="foo") Tag.objects.create(title="bar", slug="foo") Tag.objects.all().delete() # Alter the slug field to be unique new_field2 = SlugField(unique=True) new_field2.set_attributes_from_name("slug") with connection.schema_editor() as editor: editor.alter_field(Tag, new_field, new_field2, strict=True) # Ensure the field is unique again Tag.objects.create(title="foo", slug="foo") with self.assertRaises(IntegrityError): Tag.objects.create(title="bar", slug="foo") Tag.objects.all().delete() # Rename the field new_field3 = SlugField(unique=True) new_field3.set_attributes_from_name("slug2") with connection.schema_editor() as editor: editor.alter_field(Tag, new_field2, new_field3, strict=True) # Ensure the field is still unique TagUniqueRename.objects.create(title="foo", slug2="foo") with self.assertRaises(IntegrityError): TagUniqueRename.objects.create(title="bar", slug2="foo") Tag.objects.all().delete() def test_unique_name_quoting(self): old_table_name = TagUniqueRename._meta.db_table try: with connection.schema_editor() as editor: editor.create_model(TagUniqueRename) editor.alter_db_table(TagUniqueRename, old_table_name, 'unique-table') TagUniqueRename._meta.db_table = 'unique-table' # This fails if the unique index name isn't quoted. editor.alter_unique_together(TagUniqueRename, [], (('title', 'slug2'),)) finally: TagUniqueRename._meta.db_table = old_table_name @isolate_apps('schema') @skipUnlessDBFeature('supports_foreign_keys') def test_unique_no_unnecessary_fk_drops(self): """ If AlterField isn't selective about dropping foreign key constraints when modifying a field with a unique constraint, the AlterField incorrectly drops and recreates the Book.author foreign key even though it doesn't restrict the field being changed (#29193). """ class Author(Model): name = CharField(max_length=254, unique=True) class Meta: app_label = 'schema' class Book(Model): author = ForeignKey(Author, CASCADE) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) new_field = CharField(max_length=255, unique=True) new_field.model = Author new_field.set_attributes_from_name('name') with self.assertLogs('django.db.backends.schema', 'DEBUG') as cm: with connection.schema_editor() as editor: editor.alter_field(Author, Author._meta.get_field('name'), new_field) # One SQL statement is executed to alter the field. self.assertEqual(len(cm.records), 1) @isolate_apps('schema') def test_unique_and_reverse_m2m(self): """ AlterField can modify a unique field when there's a reverse M2M relation on the model. """ class Tag(Model): title = CharField(max_length=255) slug = SlugField(unique=True) class Meta: app_label = 'schema' class Book(Model): tags = ManyToManyField(Tag, related_name='books') class Meta: app_label = 'schema' self.isolated_local_models = [Book._meta.get_field('tags').remote_field.through] with connection.schema_editor() as editor: editor.create_model(Tag) editor.create_model(Book) new_field = SlugField(max_length=75, unique=True) new_field.model = Tag new_field.set_attributes_from_name('slug') with self.assertLogs('django.db.backends.schema', 'DEBUG') as cm: with connection.schema_editor() as editor: editor.alter_field(Tag, Tag._meta.get_field('slug'), new_field) # One SQL statement is executed to alter the field. self.assertEqual(len(cm.records), 1) # Ensure that the field is still unique. Tag.objects.create(title='foo', slug='foo') with self.assertRaises(IntegrityError): Tag.objects.create(title='bar', slug='foo') @skipUnlessDBFeature('allows_multiple_constraints_on_same_fields') def test_remove_field_unique_does_not_remove_meta_constraints(self): with connection.schema_editor() as editor: editor.create_model(AuthorWithUniqueName) # Add the custom unique constraint constraint = UniqueConstraint(fields=['name'], name='author_name_uniq') custom_constraint_name = constraint.name AuthorWithUniqueName._meta.constraints = [constraint] with connection.schema_editor() as editor: editor.add_constraint(AuthorWithUniqueName, constraint) # Ensure the constraints exist constraints = self.get_constraints(AuthorWithUniqueName._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Alter the column to remove field uniqueness old_field = AuthorWithUniqueName._meta.get_field('name') new_field = CharField(max_length=255) new_field.set_attributes_from_name('name') with connection.schema_editor() as editor: editor.alter_field(AuthorWithUniqueName, old_field, new_field, strict=True) constraints = self.get_constraints(AuthorWithUniqueName._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 0) # Alter the column to re-add field uniqueness new_field2 = AuthorWithUniqueName._meta.get_field('name') with connection.schema_editor() as editor: editor.alter_field(AuthorWithUniqueName, new_field, new_field2, strict=True) constraints = self.get_constraints(AuthorWithUniqueName._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Drop the unique constraint with connection.schema_editor() as editor: AuthorWithUniqueName._meta.constraints = [] editor.remove_constraint(AuthorWithUniqueName, constraint) def test_unique_together(self): """ Tests removing and adding unique_together constraints on a model. """ # Create the table with connection.schema_editor() as editor: editor.create_model(UniqueTest) # Ensure the fields are unique to begin with UniqueTest.objects.create(year=2012, slug="foo") UniqueTest.objects.create(year=2011, slug="foo") UniqueTest.objects.create(year=2011, slug="bar") with self.assertRaises(IntegrityError): UniqueTest.objects.create(year=2012, slug="foo") UniqueTest.objects.all().delete() # Alter the model to its non-unique-together companion with connection.schema_editor() as editor: editor.alter_unique_together(UniqueTest, UniqueTest._meta.unique_together, []) # Ensure the fields are no longer unique UniqueTest.objects.create(year=2012, slug="foo") UniqueTest.objects.create(year=2012, slug="foo") UniqueTest.objects.all().delete() # Alter it back new_field2 = SlugField(unique=True) new_field2.set_attributes_from_name("slug") with connection.schema_editor() as editor: editor.alter_unique_together(UniqueTest, [], UniqueTest._meta.unique_together) # Ensure the fields are unique again UniqueTest.objects.create(year=2012, slug="foo") with self.assertRaises(IntegrityError): UniqueTest.objects.create(year=2012, slug="foo") UniqueTest.objects.all().delete() def test_unique_together_with_fk(self): """ Tests removing and adding unique_together constraints that include a foreign key. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the fields are unique to begin with self.assertEqual(Book._meta.unique_together, ()) # Add the unique_together constraint with connection.schema_editor() as editor: editor.alter_unique_together(Book, [], [['author', 'title']]) # Alter it back with connection.schema_editor() as editor: editor.alter_unique_together(Book, [['author', 'title']], []) def test_unique_together_with_fk_with_existing_index(self): """ Tests removing and adding unique_together constraints that include a foreign key, where the foreign key is added after the model is created. """ # Create the tables with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithoutAuthor) new_field = ForeignKey(Author, CASCADE) new_field.set_attributes_from_name('author') editor.add_field(BookWithoutAuthor, new_field) # Ensure the fields aren't unique to begin with self.assertEqual(Book._meta.unique_together, ()) # Add the unique_together constraint with connection.schema_editor() as editor: editor.alter_unique_together(Book, [], [['author', 'title']]) # Alter it back with connection.schema_editor() as editor: editor.alter_unique_together(Book, [['author', 'title']], []) @skipUnlessDBFeature('allows_multiple_constraints_on_same_fields') def test_remove_unique_together_does_not_remove_meta_constraints(self): with connection.schema_editor() as editor: editor.create_model(AuthorWithUniqueNameAndBirthday) # Add the custom unique constraint constraint = UniqueConstraint(fields=['name', 'birthday'], name='author_name_birthday_uniq') custom_constraint_name = constraint.name AuthorWithUniqueNameAndBirthday._meta.constraints = [constraint] with connection.schema_editor() as editor: editor.add_constraint(AuthorWithUniqueNameAndBirthday, constraint) # Ensure the constraints exist constraints = self.get_constraints(AuthorWithUniqueNameAndBirthday._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Remove unique together unique_together = AuthorWithUniqueNameAndBirthday._meta.unique_together with connection.schema_editor() as editor: editor.alter_unique_together(AuthorWithUniqueNameAndBirthday, unique_together, []) constraints = self.get_constraints(AuthorWithUniqueNameAndBirthday._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 0) # Re-add unique together with connection.schema_editor() as editor: editor.alter_unique_together(AuthorWithUniqueNameAndBirthday, [], unique_together) constraints = self.get_constraints(AuthorWithUniqueNameAndBirthday._meta.db_table) self.assertIn(custom_constraint_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['unique'] and name != custom_constraint_name ] self.assertEqual(len(other_constraints), 1) # Drop the unique constraint with connection.schema_editor() as editor: AuthorWithUniqueNameAndBirthday._meta.constraints = [] editor.remove_constraint(AuthorWithUniqueNameAndBirthday, constraint) def test_index_together(self): """ Tests removing and adding index_together constraints on a model. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure there's no index on the year/slug columns first self.assertIs( any( c["index"] for c in self.get_constraints("schema_tag").values() if c['columns'] == ["slug", "title"] ), False, ) # Alter the model to add an index with connection.schema_editor() as editor: editor.alter_index_together(Tag, [], [("slug", "title")]) # Ensure there is now an index self.assertIs( any( c["index"] for c in self.get_constraints("schema_tag").values() if c['columns'] == ["slug", "title"] ), True, ) # Alter it back new_field2 = SlugField(unique=True) new_field2.set_attributes_from_name("slug") with connection.schema_editor() as editor: editor.alter_index_together(Tag, [("slug", "title")], []) # Ensure there's no index self.assertIs( any( c["index"] for c in self.get_constraints("schema_tag").values() if c['columns'] == ["slug", "title"] ), False, ) def test_index_together_with_fk(self): """ Tests removing and adding index_together constraints that include a foreign key. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the fields are unique to begin with self.assertEqual(Book._meta.index_together, ()) # Add the unique_together constraint with connection.schema_editor() as editor: editor.alter_index_together(Book, [], [['author', 'title']]) # Alter it back with connection.schema_editor() as editor: editor.alter_index_together(Book, [['author', 'title']], []) def test_create_index_together(self): """ Tests creating models with index_together already defined """ # Create the table with connection.schema_editor() as editor: editor.create_model(TagIndexed) # Ensure there is an index self.assertIs( any( c["index"] for c in self.get_constraints("schema_tagindexed").values() if c['columns'] == ["slug", "title"] ), True, ) @skipUnlessDBFeature('allows_multiple_constraints_on_same_fields') def test_remove_index_together_does_not_remove_meta_indexes(self): with connection.schema_editor() as editor: editor.create_model(AuthorWithIndexedNameAndBirthday) # Add the custom index index = Index(fields=['name', 'birthday'], name='author_name_birthday_idx') custom_index_name = index.name AuthorWithIndexedNameAndBirthday._meta.indexes = [index] with connection.schema_editor() as editor: editor.add_index(AuthorWithIndexedNameAndBirthday, index) # Ensure the indexes exist constraints = self.get_constraints(AuthorWithIndexedNameAndBirthday._meta.db_table) self.assertIn(custom_index_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['index'] and name != custom_index_name ] self.assertEqual(len(other_constraints), 1) # Remove index together index_together = AuthorWithIndexedNameAndBirthday._meta.index_together with connection.schema_editor() as editor: editor.alter_index_together(AuthorWithIndexedNameAndBirthday, index_together, []) constraints = self.get_constraints(AuthorWithIndexedNameAndBirthday._meta.db_table) self.assertIn(custom_index_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['index'] and name != custom_index_name ] self.assertEqual(len(other_constraints), 0) # Re-add index together with connection.schema_editor() as editor: editor.alter_index_together(AuthorWithIndexedNameAndBirthday, [], index_together) constraints = self.get_constraints(AuthorWithIndexedNameAndBirthday._meta.db_table) self.assertIn(custom_index_name, constraints) other_constraints = [ name for name, details in constraints.items() if details['columns'] == ['name', 'birthday'] and details['index'] and name != custom_index_name ] self.assertEqual(len(other_constraints), 1) # Drop the index with connection.schema_editor() as editor: AuthorWithIndexedNameAndBirthday._meta.indexes = [] editor.remove_index(AuthorWithIndexedNameAndBirthday, index) @isolate_apps('schema') def test_db_table(self): """ Tests renaming of the table """ class Author(Model): name = CharField(max_length=255) class Meta: app_label = 'schema' class Book(Model): author = ForeignKey(Author, CASCADE) class Meta: app_label = 'schema' # Create the table and one referring it. with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the table is there to begin with columns = self.column_classes(Author) self.assertEqual(columns['name'][0], connection.features.introspected_field_types['CharField']) # Alter the table with connection.schema_editor(atomic=connection.features.supports_atomic_references_rename) as editor: editor.alter_db_table(Author, "schema_author", "schema_otherauthor") # Ensure the table is there afterwards Author._meta.db_table = "schema_otherauthor" columns = self.column_classes(Author) self.assertEqual(columns['name'][0], connection.features.introspected_field_types['CharField']) # Ensure the foreign key reference was updated self.assertForeignKeyExists(Book, "author_id", "schema_otherauthor") # Alter the table again with connection.schema_editor(atomic=connection.features.supports_atomic_references_rename) as editor: editor.alter_db_table(Author, "schema_otherauthor", "schema_author") # Ensure the table is still there Author._meta.db_table = "schema_author" columns = self.column_classes(Author) self.assertEqual(columns['name'][0], connection.features.introspected_field_types['CharField']) def test_add_remove_index(self): """ Tests index addition and removal """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure the table is there and has no index self.assertNotIn('title', self.get_indexes(Author._meta.db_table)) # Add the index index = Index(fields=['name'], name='author_title_idx') with connection.schema_editor() as editor: editor.add_index(Author, index) self.assertIn('name', self.get_indexes(Author._meta.db_table)) # Drop the index with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn('name', self.get_indexes(Author._meta.db_table)) def test_remove_db_index_doesnt_remove_custom_indexes(self): """ Changing db_index to False doesn't remove indexes from Meta.indexes. """ with connection.schema_editor() as editor: editor.create_model(AuthorWithIndexedName) # Ensure the table has its index self.assertIn('name', self.get_indexes(AuthorWithIndexedName._meta.db_table)) # Add the custom index index = Index(fields=['-name'], name='author_name_idx') author_index_name = index.name with connection.schema_editor() as editor: db_index_name = editor._create_index_name( table_name=AuthorWithIndexedName._meta.db_table, column_names=('name',), ) try: AuthorWithIndexedName._meta.indexes = [index] with connection.schema_editor() as editor: editor.add_index(AuthorWithIndexedName, index) old_constraints = self.get_constraints(AuthorWithIndexedName._meta.db_table) self.assertIn(author_index_name, old_constraints) self.assertIn(db_index_name, old_constraints) # Change name field to db_index=False old_field = AuthorWithIndexedName._meta.get_field('name') new_field = CharField(max_length=255) new_field.set_attributes_from_name('name') with connection.schema_editor() as editor: editor.alter_field(AuthorWithIndexedName, old_field, new_field, strict=True) new_constraints = self.get_constraints(AuthorWithIndexedName._meta.db_table) self.assertNotIn(db_index_name, new_constraints) # The index from Meta.indexes is still in the database. self.assertIn(author_index_name, new_constraints) # Drop the index with connection.schema_editor() as editor: editor.remove_index(AuthorWithIndexedName, index) finally: AuthorWithIndexedName._meta.indexes = [] def test_order_index(self): """ Indexes defined with ordering (ASC/DESC) defined on column """ with connection.schema_editor() as editor: editor.create_model(Author) # The table doesn't have an index self.assertNotIn('title', self.get_indexes(Author._meta.db_table)) index_name = 'author_name_idx' # Add the index index = Index(fields=['name', '-weight'], name=index_name) with connection.schema_editor() as editor: editor.add_index(Author, index) if connection.features.supports_index_column_ordering: self.assertIndexOrder(Author._meta.db_table, index_name, ['ASC', 'DESC']) # Drop the index with connection.schema_editor() as editor: editor.remove_index(Author, index) def test_indexes(self): """ Tests creation/altering of indexes """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) # Ensure the table is there and has the right index self.assertIn( "title", self.get_indexes(Book._meta.db_table), ) # Alter to remove the index old_field = Book._meta.get_field("title") new_field = CharField(max_length=100, db_index=False) new_field.set_attributes_from_name("title") with connection.schema_editor() as editor: editor.alter_field(Book, old_field, new_field, strict=True) # Ensure the table is there and has no index self.assertNotIn( "title", self.get_indexes(Book._meta.db_table), ) # Alter to re-add the index new_field2 = Book._meta.get_field("title") with connection.schema_editor() as editor: editor.alter_field(Book, new_field, new_field2, strict=True) # Ensure the table is there and has the index again self.assertIn( "title", self.get_indexes(Book._meta.db_table), ) # Add a unique column, verify that creates an implicit index new_field3 = BookWithSlug._meta.get_field("slug") with connection.schema_editor() as editor: editor.add_field(Book, new_field3) self.assertIn( "slug", self.get_uniques(Book._meta.db_table), ) # Remove the unique, check the index goes with it new_field4 = CharField(max_length=20, unique=False) new_field4.set_attributes_from_name("slug") with connection.schema_editor() as editor: editor.alter_field(BookWithSlug, new_field3, new_field4, strict=True) self.assertNotIn( "slug", self.get_uniques(Book._meta.db_table), ) def test_text_field_with_db_index(self): with connection.schema_editor() as editor: editor.create_model(AuthorTextFieldWithIndex) # The text_field index is present if the database supports it. assertion = self.assertIn if connection.features.supports_index_on_text_field else self.assertNotIn assertion('text_field', self.get_indexes(AuthorTextFieldWithIndex._meta.db_table)) def _index_expressions_wrappers(self): index_expression = IndexExpression() index_expression.set_wrapper_classes(connection) return ', '.join([ wrapper_cls.__qualname__ for wrapper_cls in index_expression.wrapper_classes ]) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_multiple_wrapper_references(self): index = Index(OrderBy(F('name').desc(), descending=True), name='name') msg = ( "Multiple references to %s can't be used in an indexed expression." % self._index_expressions_wrappers() ) with connection.schema_editor() as editor: with self.assertRaisesMessage(ValueError, msg): editor.add_index(Author, index) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_invalid_topmost_expressions(self): index = Index(Upper(F('name').desc()), name='name') msg = ( '%s must be topmost expressions in an indexed expression.' % self._index_expressions_wrappers() ) with connection.schema_editor() as editor: with self.assertRaisesMessage(ValueError, msg): editor.add_index(Author, index) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index(self): with connection.schema_editor() as editor: editor.create_model(Author) index = Index(Lower('name').desc(), name='func_lower_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table if connection.features.supports_index_column_ordering: self.assertIndexOrder(table, index.name, ['DESC']) # SQL contains a database function. self.assertIs(sql.references_column(table, 'name'), True) self.assertIn('LOWER(%s)' % editor.quote_name('name'), str(sql)) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_f(self): with connection.schema_editor() as editor: editor.create_model(Tag) index = Index('slug', F('title').desc(), name='func_f_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Tag, index) sql = index.create_sql(Tag, editor) table = Tag._meta.db_table self.assertIn(index.name, self.get_constraints(table)) if connection.features.supports_index_column_ordering: self.assertIndexOrder(Tag._meta.db_table, index.name, ['ASC', 'DESC']) # SQL contains columns. self.assertIs(sql.references_column(table, 'slug'), True) self.assertIs(sql.references_column(table, 'title'), True) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Tag, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_lookups(self): with connection.schema_editor() as editor: editor.create_model(Author) with register_lookup(CharField, Lower), register_lookup(IntegerField, Abs): index = Index( F('name__lower'), F('weight__abs'), name='func_lower_abs_lookup_idx', ) # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table self.assertIn(index.name, self.get_constraints(table)) # SQL contains columns. self.assertIs(sql.references_column(table, 'name'), True) self.assertIs(sql.references_column(table, 'weight'), True) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_composite_func_index(self): with connection.schema_editor() as editor: editor.create_model(Author) index = Index(Lower('name'), Upper('name'), name='func_lower_upper_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table self.assertIn(index.name, self.get_constraints(table)) # SQL contains database functions. self.assertIs(sql.references_column(table, 'name'), True) sql = str(sql) self.assertIn('LOWER(%s)' % editor.quote_name('name'), sql) self.assertIn('UPPER(%s)' % editor.quote_name('name'), sql) self.assertLess(sql.index('LOWER'), sql.index('UPPER')) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_composite_func_index_field_and_expression(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) index = Index( F('author').desc(), Lower('title').asc(), 'pub_date', name='func_f_lower_field_idx', ) # Add index. with connection.schema_editor() as editor: editor.add_index(Book, index) sql = index.create_sql(Book, editor) table = Book._meta.db_table constraints = self.get_constraints(table) if connection.features.supports_index_column_ordering: self.assertIndexOrder(table, index.name, ['DESC', 'ASC', 'ASC']) self.assertEqual(len(constraints[index.name]['columns']), 3) self.assertEqual(constraints[index.name]['columns'][2], 'pub_date') # SQL contains database functions and columns. self.assertIs(sql.references_column(table, 'author_id'), True) self.assertIs(sql.references_column(table, 'title'), True) self.assertIs(sql.references_column(table, 'pub_date'), True) self.assertIn('LOWER(%s)' % editor.quote_name('title'), str(sql)) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Book, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') @isolate_apps('schema') def test_func_index_f_decimalfield(self): class Node(Model): value = DecimalField(max_digits=5, decimal_places=2) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Node) index = Index(F('value'), name='func_f_decimalfield_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Node, index) sql = index.create_sql(Node, editor) table = Node._meta.db_table self.assertIn(index.name, self.get_constraints(table)) self.assertIs(sql.references_column(table, 'value'), True) # SQL doesn't contain casting. self.assertNotIn('CAST', str(sql)) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Node, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_cast(self): with connection.schema_editor() as editor: editor.create_model(Author) index = Index(Cast('weight', FloatField()), name='func_cast_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table self.assertIn(index.name, self.get_constraints(table)) self.assertIs(sql.references_column(table, 'weight'), True) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_collate(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest( 'This backend does not support case-insensitive collations.' ) with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(BookWithSlug) index = Index( Collate(F('title'), collation=collation).desc(), Collate('slug', collation=collation), name='func_collate_idx', ) # Add index. with connection.schema_editor() as editor: editor.add_index(BookWithSlug, index) sql = index.create_sql(BookWithSlug, editor) table = Book._meta.db_table self.assertIn(index.name, self.get_constraints(table)) if connection.features.supports_index_column_ordering: self.assertIndexOrder(table, index.name, ['DESC', 'ASC']) # SQL contains columns and a collation. self.assertIs(sql.references_column(table, 'title'), True) self.assertIs(sql.references_column(table, 'slug'), True) self.assertIn('COLLATE %s' % editor.quote_name(collation), str(sql)) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Book, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') @skipIfDBFeature('collate_as_index_expression') def test_func_index_collate_f_ordered(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest( 'This backend does not support case-insensitive collations.' ) with connection.schema_editor() as editor: editor.create_model(Author) index = Index( Collate(F('name').desc(), collation=collation), name='func_collate_f_desc_idx', ) # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table self.assertIn(index.name, self.get_constraints(table)) if connection.features.supports_index_column_ordering: self.assertIndexOrder(table, index.name, ['DESC']) # SQL contains columns and a collation. self.assertIs(sql.references_column(table, 'name'), True) self.assertIn('COLLATE %s' % editor.quote_name(collation), str(sql)) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_calc(self): with connection.schema_editor() as editor: editor.create_model(Author) index = Index(F('height') / (F('weight') + Value(5)), name='func_calc_idx') # Add index. with connection.schema_editor() as editor: editor.add_index(Author, index) sql = index.create_sql(Author, editor) table = Author._meta.db_table self.assertIn(index.name, self.get_constraints(table)) # SQL contains columns and expressions. self.assertIs(sql.references_column(table, 'height'), True) self.assertIs(sql.references_column(table, 'weight'), True) sql = str(sql) self.assertIs( sql.index(editor.quote_name('height')) < sql.index('/') < sql.index(editor.quote_name('weight')) < sql.index('+') < sql.index('5'), True, ) # Remove index. with connection.schema_editor() as editor: editor.remove_index(Author, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes', 'supports_json_field') @isolate_apps('schema') def test_func_index_json_key_transform(self): class JSONModel(Model): field = JSONField() class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(JSONModel) self.isolated_local_models = [JSONModel] index = Index('field__some_key', name='func_json_key_idx') with connection.schema_editor() as editor: editor.add_index(JSONModel, index) sql = index.create_sql(JSONModel, editor) table = JSONModel._meta.db_table self.assertIn(index.name, self.get_constraints(table)) self.assertIs(sql.references_column(table, 'field'), True) with connection.schema_editor() as editor: editor.remove_index(JSONModel, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipUnlessDBFeature('supports_expression_indexes', 'supports_json_field') @isolate_apps('schema') def test_func_index_json_key_transform_cast(self): class JSONModel(Model): field = JSONField() class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(JSONModel) self.isolated_local_models = [JSONModel] index = Index( Cast(KeyTextTransform('some_key', 'field'), IntegerField()), name='func_json_key_cast_idx', ) with connection.schema_editor() as editor: editor.add_index(JSONModel, index) sql = index.create_sql(JSONModel, editor) table = JSONModel._meta.db_table self.assertIn(index.name, self.get_constraints(table)) self.assertIs(sql.references_column(table, 'field'), True) with connection.schema_editor() as editor: editor.remove_index(JSONModel, index) self.assertNotIn(index.name, self.get_constraints(table)) @skipIfDBFeature('supports_expression_indexes') def test_func_index_unsupported(self): # Index is ignored on databases that don't support indexes on # expressions. with connection.schema_editor() as editor: editor.create_model(Author) index = Index(F('name'), name='random_idx') with connection.schema_editor() as editor, self.assertNumQueries(0): self.assertIsNone(editor.add_index(Author, index)) self.assertIsNone(editor.remove_index(Author, index)) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_nonexistent_field(self): index = Index(Lower('nonexistent'), name='func_nonexistent_idx') msg = ( "Cannot resolve keyword 'nonexistent' into field. Choices are: " "height, id, name, uuid, weight" ) with self.assertRaisesMessage(FieldError, msg): with connection.schema_editor() as editor: editor.add_index(Author, index) @skipUnlessDBFeature('supports_expression_indexes') def test_func_index_nondeterministic(self): with connection.schema_editor() as editor: editor.create_model(Author) index = Index(Random(), name='func_random_idx') with connection.schema_editor() as editor: with self.assertRaises(DatabaseError): editor.add_index(Author, index) def test_primary_key(self): """ Tests altering of the primary key """ # Create the table with connection.schema_editor() as editor: editor.create_model(Tag) # Ensure the table is there and has the right PK self.assertEqual(self.get_primary_key(Tag._meta.db_table), 'id') # Alter to change the PK id_field = Tag._meta.get_field("id") old_field = Tag._meta.get_field("slug") new_field = SlugField(primary_key=True) new_field.set_attributes_from_name("slug") new_field.model = Tag with connection.schema_editor() as editor: editor.remove_field(Tag, id_field) editor.alter_field(Tag, old_field, new_field) # Ensure the PK changed self.assertNotIn( 'id', self.get_indexes(Tag._meta.db_table), ) self.assertEqual(self.get_primary_key(Tag._meta.db_table), 'slug') def test_context_manager_exit(self): """ Ensures transaction is correctly closed when an error occurs inside a SchemaEditor context. """ class SomeError(Exception): pass try: with connection.schema_editor(): raise SomeError except SomeError: self.assertFalse(connection.in_atomic_block) @skipIfDBFeature('can_rollback_ddl') def test_unsupported_transactional_ddl_disallowed(self): message = ( "Executing DDL statements while in a transaction on databases " "that can't perform a rollback is prohibited." ) with atomic(), connection.schema_editor() as editor: with self.assertRaisesMessage(TransactionManagementError, message): editor.execute(editor.sql_create_table % {'table': 'foo', 'definition': ''}) @skipUnlessDBFeature('supports_foreign_keys', 'indexes_foreign_keys') def test_foreign_key_index_long_names_regression(self): """ Regression test for #21497. Only affects databases that supports foreign keys. """ # Create the table with connection.schema_editor() as editor: editor.create_model(AuthorWithEvenLongerName) editor.create_model(BookWithLongName) # Find the properly shortened column name column_name = connection.ops.quote_name("author_foreign_key_with_really_long_field_name_id") column_name = column_name[1:-1].lower() # unquote, and, for Oracle, un-upcase # Ensure the table is there and has an index on the column self.assertIn( column_name, self.get_indexes(BookWithLongName._meta.db_table), ) @skipUnlessDBFeature('supports_foreign_keys') def test_add_foreign_key_long_names(self): """ Regression test for #23009. Only affects databases that supports foreign keys. """ # Create the initial tables with connection.schema_editor() as editor: editor.create_model(AuthorWithEvenLongerName) editor.create_model(BookWithLongName) # Add a second FK, this would fail due to long ref name before the fix new_field = ForeignKey(AuthorWithEvenLongerName, CASCADE, related_name="something") new_field.set_attributes_from_name("author_other_really_long_named_i_mean_so_long_fk") with connection.schema_editor() as editor: editor.add_field(BookWithLongName, new_field) @isolate_apps('schema') @skipUnlessDBFeature('supports_foreign_keys') def test_add_foreign_key_quoted_db_table(self): class Author(Model): class Meta: db_table = '"table_author_double_quoted"' app_label = 'schema' class Book(Model): author = ForeignKey(Author, CASCADE) class Meta: app_label = 'schema' with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) if connection.vendor == 'mysql': self.assertForeignKeyExists(Book, 'author_id', '"table_author_double_quoted"') else: self.assertForeignKeyExists(Book, 'author_id', 'table_author_double_quoted') def test_add_foreign_object(self): with connection.schema_editor() as editor: editor.create_model(BookForeignObj) new_field = ForeignObject(Author, on_delete=CASCADE, from_fields=['author_id'], to_fields=['id']) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.add_field(BookForeignObj, new_field) def test_creation_deletion_reserved_names(self): """ Tries creating a model's table, and then deleting it when it has a SQL reserved name. """ # Create the table with connection.schema_editor() as editor: try: editor.create_model(Thing) except OperationalError as e: self.fail("Errors when applying initial migration for a model " "with a table named after an SQL reserved word: %s" % e) # The table is there list(Thing.objects.all()) # Clean up that table with connection.schema_editor() as editor: editor.delete_model(Thing) # The table is gone with self.assertRaises(DatabaseError): list(Thing.objects.all()) def test_remove_constraints_capital_letters(self): """ #23065 - Constraint names must be quoted if they contain capital letters. """ def get_field(*args, field_class=IntegerField, **kwargs): kwargs['db_column'] = "CamelCase" field = field_class(*args, **kwargs) field.set_attributes_from_name("CamelCase") return field model = Author field = get_field() table = model._meta.db_table column = field.column identifier_converter = connection.introspection.identifier_converter with connection.schema_editor() as editor: editor.create_model(model) editor.add_field(model, field) constraint_name = 'CamelCaseIndex' expected_constraint_name = identifier_converter(constraint_name) editor.execute( editor.sql_create_index % { "table": editor.quote_name(table), "name": editor.quote_name(constraint_name), "using": "", "columns": editor.quote_name(column), "extra": "", "condition": "", "include": "", } ) self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) editor.alter_field(model, get_field(db_index=True), field, strict=True) self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) constraint_name = 'CamelCaseUniqConstraint' expected_constraint_name = identifier_converter(constraint_name) editor.execute(editor._create_unique_sql(model, [field.column], constraint_name)) self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) editor.alter_field(model, get_field(unique=True), field, strict=True) self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) if editor.sql_create_fk: constraint_name = 'CamelCaseFKConstraint' expected_constraint_name = identifier_converter(constraint_name) editor.execute( editor.sql_create_fk % { "table": editor.quote_name(table), "name": editor.quote_name(constraint_name), "column": editor.quote_name(column), "to_table": editor.quote_name(table), "to_column": editor.quote_name(model._meta.auto_field.column), "deferrable": connection.ops.deferrable_sql(), } ) self.assertIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) editor.alter_field(model, get_field(Author, CASCADE, field_class=ForeignKey), field, strict=True) self.assertNotIn(expected_constraint_name, self.get_constraints(model._meta.db_table)) def test_add_field_use_effective_default(self): """ #23987 - effective_default() should be used as the field default when adding a new field. """ # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no surname field columns = self.column_classes(Author) self.assertNotIn("surname", columns) # Create a row Author.objects.create(name='Anonymous1') # Add new CharField to ensure default will be used from effective_default new_field = CharField(max_length=15, blank=True) new_field.set_attributes_from_name("surname") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure field was added with the right default with connection.cursor() as cursor: cursor.execute("SELECT surname FROM schema_author;") item = cursor.fetchall()[0] self.assertEqual(item[0], None if connection.features.interprets_empty_strings_as_nulls else '') def test_add_field_default_dropped(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Ensure there's no surname field columns = self.column_classes(Author) self.assertNotIn("surname", columns) # Create a row Author.objects.create(name='Anonymous1') # Add new CharField with a default new_field = CharField(max_length=15, blank=True, default='surname default') new_field.set_attributes_from_name("surname") with connection.schema_editor() as editor: editor.add_field(Author, new_field) # Ensure field was added with the right default with connection.cursor() as cursor: cursor.execute("SELECT surname FROM schema_author;") item = cursor.fetchall()[0] self.assertEqual(item[0], 'surname default') # And that the default is no longer set in the database. field = next( f for f in connection.introspection.get_table_description(cursor, "schema_author") if f.name == "surname" ) if connection.features.can_introspect_default: self.assertIsNone(field.default) def test_add_field_default_nullable(self): with connection.schema_editor() as editor: editor.create_model(Author) # Add new nullable CharField with a default. new_field = CharField(max_length=15, blank=True, null=True, default='surname') new_field.set_attributes_from_name('surname') with connection.schema_editor() as editor: editor.add_field(Author, new_field) Author.objects.create(name='Anonymous1') with connection.cursor() as cursor: cursor.execute('SELECT surname FROM schema_author;') item = cursor.fetchall()[0] self.assertIsNone(item[0]) field = next( f for f in connection.introspection.get_table_description( cursor, 'schema_author', ) if f.name == 'surname' ) # Field is still nullable. self.assertTrue(field.null_ok) # The database default is no longer set. if connection.features.can_introspect_default: self.assertIn(field.default, ['NULL', None]) def test_add_textfield_default_nullable(self): with connection.schema_editor() as editor: editor.create_model(Author) # Add new nullable TextField with a default. new_field = TextField(blank=True, null=True, default='text') new_field.set_attributes_from_name('description') with connection.schema_editor() as editor: editor.add_field(Author, new_field) Author.objects.create(name='Anonymous1') with connection.cursor() as cursor: cursor.execute('SELECT description FROM schema_author;') item = cursor.fetchall()[0] self.assertIsNone(item[0]) field = next( f for f in connection.introspection.get_table_description( cursor, 'schema_author', ) if f.name == 'description' ) # Field is still nullable. self.assertTrue(field.null_ok) # The database default is no longer set. if connection.features.can_introspect_default: self.assertIn(field.default, ['NULL', None]) def test_alter_field_default_dropped(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Create a row Author.objects.create(name='Anonymous1') self.assertIsNone(Author.objects.get().height) old_field = Author._meta.get_field('height') # The default from the new field is used in updating existing rows. new_field = IntegerField(blank=True, default=42) new_field.set_attributes_from_name('height') with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertEqual(Author.objects.get().height, 42) # The database default should be removed. with connection.cursor() as cursor: field = next( f for f in connection.introspection.get_table_description(cursor, "schema_author") if f.name == "height" ) if connection.features.can_introspect_default: self.assertIsNone(field.default) def test_alter_field_default_doesnt_perform_queries(self): """ No queries are performed if a field default changes and the field's not changing from null to non-null. """ with connection.schema_editor() as editor: editor.create_model(AuthorWithDefaultHeight) old_field = AuthorWithDefaultHeight._meta.get_field('height') new_default = old_field.default * 2 new_field = PositiveIntegerField(null=True, blank=True, default=new_default) new_field.set_attributes_from_name('height') with connection.schema_editor() as editor, self.assertNumQueries(0): editor.alter_field(AuthorWithDefaultHeight, old_field, new_field, strict=True) @skipUnlessDBFeature('supports_foreign_keys') def test_alter_field_fk_attributes_noop(self): """ No queries are performed when changing field attributes that don't affect the schema. """ with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) old_field = Book._meta.get_field('author') new_field = ForeignKey( Author, blank=True, editable=False, error_messages={'invalid': 'error message'}, help_text='help text', limit_choices_to={'limit': 'choice'}, on_delete=PROTECT, related_name='related_name', related_query_name='related_query_name', validators=[lambda x: x], verbose_name='verbose name', ) new_field.set_attributes_from_name('author') with connection.schema_editor() as editor, self.assertNumQueries(0): editor.alter_field(Book, old_field, new_field, strict=True) with connection.schema_editor() as editor, self.assertNumQueries(0): editor.alter_field(Book, new_field, old_field, strict=True) def test_add_textfield_unhashable_default(self): # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Create a row Author.objects.create(name='Anonymous1') # Create a field that has an unhashable default new_field = TextField(default={}) new_field.set_attributes_from_name("info") with connection.schema_editor() as editor: editor.add_field(Author, new_field) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_add_indexed_charfield(self): field = CharField(max_length=255, db_index=True) field.set_attributes_from_name('nom_de_plume') with connection.schema_editor() as editor: editor.create_model(Author) editor.add_field(Author, field) # Should create two indexes; one for like operator. self.assertEqual( self.get_constraints_for_column(Author, 'nom_de_plume'), ['schema_author_nom_de_plume_7570a851', 'schema_author_nom_de_plume_7570a851_like'], ) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_add_unique_charfield(self): field = CharField(max_length=255, unique=True) field.set_attributes_from_name('nom_de_plume') with connection.schema_editor() as editor: editor.create_model(Author) editor.add_field(Author, field) # Should create two indexes; one for like operator. self.assertEqual( self.get_constraints_for_column(Author, 'nom_de_plume'), ['schema_author_nom_de_plume_7570a851_like', 'schema_author_nom_de_plume_key'] ) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_add_index_to_charfield(self): # Create the table and verify no initial indexes. with connection.schema_editor() as editor: editor.create_model(Author) self.assertEqual(self.get_constraints_for_column(Author, 'name'), []) # Alter to add db_index=True and create 2 indexes. old_field = Author._meta.get_field('name') new_field = CharField(max_length=255, db_index=True) new_field.set_attributes_from_name('name') with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(Author, 'name'), ['schema_author_name_1fbc5617', 'schema_author_name_1fbc5617_like'] ) # Remove db_index=True to drop both indexes. with connection.schema_editor() as editor: editor.alter_field(Author, new_field, old_field, strict=True) self.assertEqual(self.get_constraints_for_column(Author, 'name'), []) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_add_unique_to_charfield(self): # Create the table and verify no initial indexes. with connection.schema_editor() as editor: editor.create_model(Author) self.assertEqual(self.get_constraints_for_column(Author, 'name'), []) # Alter to add unique=True and create 2 indexes. old_field = Author._meta.get_field('name') new_field = CharField(max_length=255, unique=True) new_field.set_attributes_from_name('name') with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(Author, 'name'), ['schema_author_name_1fbc5617_like', 'schema_author_name_1fbc5617_uniq'] ) # Remove unique=True to drop both indexes. with connection.schema_editor() as editor: editor.alter_field(Author, new_field, old_field, strict=True) self.assertEqual(self.get_constraints_for_column(Author, 'name'), []) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_add_index_to_textfield(self): # Create the table and verify no initial indexes. with connection.schema_editor() as editor: editor.create_model(Note) self.assertEqual(self.get_constraints_for_column(Note, 'info'), []) # Alter to add db_index=True and create 2 indexes. old_field = Note._meta.get_field('info') new_field = TextField(db_index=True) new_field.set_attributes_from_name('info') with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(Note, 'info'), ['schema_note_info_4b0ea695', 'schema_note_info_4b0ea695_like'] ) # Remove db_index=True to drop both indexes. with connection.schema_editor() as editor: editor.alter_field(Note, new_field, old_field, strict=True) self.assertEqual(self.get_constraints_for_column(Note, 'info'), []) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_add_unique_to_charfield_with_db_index(self): # Create the table and verify initial indexes. with connection.schema_editor() as editor: editor.create_model(BookWithoutAuthor) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff', 'schema_book_title_2dfb2dff_like'] ) # Alter to add unique=True (should replace the index) old_field = BookWithoutAuthor._meta.get_field('title') new_field = CharField(max_length=100, db_index=True, unique=True) new_field.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq'] ) # Alter to remove unique=True (should drop unique index) new_field2 = CharField(max_length=100, db_index=True) new_field2.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, new_field, new_field2, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff', 'schema_book_title_2dfb2dff_like'] ) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_remove_unique_and_db_index_from_charfield(self): # Create the table and verify initial indexes. with connection.schema_editor() as editor: editor.create_model(BookWithoutAuthor) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff', 'schema_book_title_2dfb2dff_like'] ) # Alter to add unique=True (should replace the index) old_field = BookWithoutAuthor._meta.get_field('title') new_field = CharField(max_length=100, db_index=True, unique=True) new_field.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq'] ) # Alter to remove both unique=True and db_index=True (should drop all indexes) new_field2 = CharField(max_length=100) new_field2.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, new_field, new_field2, strict=True) self.assertEqual(self.get_constraints_for_column(BookWithoutAuthor, 'title'), []) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_swap_unique_and_db_index_with_charfield(self): # Create the table and verify initial indexes. with connection.schema_editor() as editor: editor.create_model(BookWithoutAuthor) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff', 'schema_book_title_2dfb2dff_like'] ) # Alter to set unique=True and remove db_index=True (should replace the index) old_field = BookWithoutAuthor._meta.get_field('title') new_field = CharField(max_length=100, unique=True) new_field.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq'] ) # Alter to set db_index=True and remove unique=True (should restore index) new_field2 = CharField(max_length=100, db_index=True) new_field2.set_attributes_from_name('title') with connection.schema_editor() as editor: editor.alter_field(BookWithoutAuthor, new_field, new_field2, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_title_2dfb2dff', 'schema_book_title_2dfb2dff_like'] ) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") def test_alter_field_add_db_index_to_charfield_with_unique(self): # Create the table and verify initial indexes. with connection.schema_editor() as editor: editor.create_model(Tag) self.assertEqual( self.get_constraints_for_column(Tag, 'slug'), ['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key'] ) # Alter to add db_index=True old_field = Tag._meta.get_field('slug') new_field = SlugField(db_index=True, unique=True) new_field.set_attributes_from_name('slug') with connection.schema_editor() as editor: editor.alter_field(Tag, old_field, new_field, strict=True) self.assertEqual( self.get_constraints_for_column(Tag, 'slug'), ['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key'] ) # Alter to remove db_index=True new_field2 = SlugField(unique=True) new_field2.set_attributes_from_name('slug') with connection.schema_editor() as editor: editor.alter_field(Tag, new_field, new_field2, strict=True) self.assertEqual( self.get_constraints_for_column(Tag, 'slug'), ['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key'] ) def test_alter_field_add_index_to_integerfield(self): # Create the table and verify no initial indexes. with connection.schema_editor() as editor: editor.create_model(Author) self.assertEqual(self.get_constraints_for_column(Author, 'weight'), []) # Alter to add db_index=True and create index. old_field = Author._meta.get_field('weight') new_field = IntegerField(null=True, db_index=True) new_field.set_attributes_from_name('weight') with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertEqual(self.get_constraints_for_column(Author, 'weight'), ['schema_author_weight_587740f9']) # Remove db_index=True to drop index. with connection.schema_editor() as editor: editor.alter_field(Author, new_field, old_field, strict=True) self.assertEqual(self.get_constraints_for_column(Author, 'weight'), []) def test_alter_pk_with_self_referential_field(self): """ Changing the primary key field name of a model with a self-referential foreign key (#26384). """ with connection.schema_editor() as editor: editor.create_model(Node) old_field = Node._meta.get_field('node_id') new_field = AutoField(primary_key=True) new_field.set_attributes_from_name('id') with connection.schema_editor() as editor: editor.alter_field(Node, old_field, new_field, strict=True) self.assertForeignKeyExists(Node, 'parent_id', Node._meta.db_table) @mock.patch('django.db.backends.base.schema.datetime') @mock.patch('django.db.backends.base.schema.timezone') def test_add_datefield_and_datetimefield_use_effective_default(self, mocked_datetime, mocked_tz): """ effective_default() should be used for DateField, DateTimeField, and TimeField if auto_now or auto_now_add is set (#25005). """ now = datetime.datetime(month=1, day=1, year=2000, hour=1, minute=1) now_tz = datetime.datetime(month=1, day=1, year=2000, hour=1, minute=1, tzinfo=timezone.utc) mocked_datetime.now = mock.MagicMock(return_value=now) mocked_tz.now = mock.MagicMock(return_value=now_tz) # Create the table with connection.schema_editor() as editor: editor.create_model(Author) # Check auto_now/auto_now_add attributes are not defined columns = self.column_classes(Author) self.assertNotIn("dob_auto_now", columns) self.assertNotIn("dob_auto_now_add", columns) self.assertNotIn("dtob_auto_now", columns) self.assertNotIn("dtob_auto_now_add", columns) self.assertNotIn("tob_auto_now", columns) self.assertNotIn("tob_auto_now_add", columns) # Create a row Author.objects.create(name='Anonymous1') # Ensure fields were added with the correct defaults dob_auto_now = DateField(auto_now=True) dob_auto_now.set_attributes_from_name('dob_auto_now') self.check_added_field_default( editor, Author, dob_auto_now, 'dob_auto_now', now.date(), cast_function=lambda x: x.date(), ) dob_auto_now_add = DateField(auto_now_add=True) dob_auto_now_add.set_attributes_from_name('dob_auto_now_add') self.check_added_field_default( editor, Author, dob_auto_now_add, 'dob_auto_now_add', now.date(), cast_function=lambda x: x.date(), ) dtob_auto_now = DateTimeField(auto_now=True) dtob_auto_now.set_attributes_from_name('dtob_auto_now') self.check_added_field_default( editor, Author, dtob_auto_now, 'dtob_auto_now', now, ) dt_tm_of_birth_auto_now_add = DateTimeField(auto_now_add=True) dt_tm_of_birth_auto_now_add.set_attributes_from_name('dtob_auto_now_add') self.check_added_field_default( editor, Author, dt_tm_of_birth_auto_now_add, 'dtob_auto_now_add', now, ) tob_auto_now = TimeField(auto_now=True) tob_auto_now.set_attributes_from_name('tob_auto_now') self.check_added_field_default( editor, Author, tob_auto_now, 'tob_auto_now', now.time(), cast_function=lambda x: x.time(), ) tob_auto_now_add = TimeField(auto_now_add=True) tob_auto_now_add.set_attributes_from_name('tob_auto_now_add') self.check_added_field_default( editor, Author, tob_auto_now_add, 'tob_auto_now_add', now.time(), cast_function=lambda x: x.time(), ) def test_namespaced_db_table_create_index_name(self): """ Table names are stripped of their namespace/schema before being used to generate index names. """ with connection.schema_editor() as editor: max_name_length = connection.ops.max_name_length() or 200 namespace = 'n' * max_name_length table_name = 't' * max_name_length namespaced_table_name = '"%s"."%s"' % (namespace, table_name) self.assertEqual( editor._create_index_name(table_name, []), editor._create_index_name(namespaced_table_name, []), ) @unittest.skipUnless(connection.vendor == 'oracle', 'Oracle specific db_table syntax') def test_creation_with_db_table_double_quotes(self): oracle_user = connection.creation._test_database_user() class Student(Model): name = CharField(max_length=30) class Meta: app_label = 'schema' apps = new_apps db_table = '"%s"."DJANGO_STUDENT_TABLE"' % oracle_user class Document(Model): name = CharField(max_length=30) students = ManyToManyField(Student) class Meta: app_label = 'schema' apps = new_apps db_table = '"%s"."DJANGO_DOCUMENT_TABLE"' % oracle_user self.local_models = [Student, Document] with connection.schema_editor() as editor: editor.create_model(Student) editor.create_model(Document) doc = Document.objects.create(name='Test Name') student = Student.objects.create(name='Some man') doc.students.add(student) @isolate_apps('schema') @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL specific db_table syntax.') def test_namespaced_db_table_foreign_key_reference(self): with connection.cursor() as cursor: cursor.execute('CREATE SCHEMA django_schema_tests') def delete_schema(): with connection.cursor() as cursor: cursor.execute('DROP SCHEMA django_schema_tests CASCADE') self.addCleanup(delete_schema) class Author(Model): class Meta: app_label = 'schema' class Book(Model): class Meta: app_label = 'schema' db_table = '"django_schema_tests"."schema_book"' author = ForeignKey(Author, CASCADE) author.set_attributes_from_name('author') with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) editor.add_field(Book, author) def test_rename_table_renames_deferred_sql_references(self): atomic_rename = connection.features.supports_atomic_references_rename with connection.schema_editor(atomic=atomic_rename) as editor: editor.create_model(Author) editor.create_model(Book) editor.alter_db_table(Author, 'schema_author', 'schema_renamed_author') editor.alter_db_table(Author, 'schema_book', 'schema_renamed_book') self.assertGreater(len(editor.deferred_sql), 0) for statement in editor.deferred_sql: self.assertIs(statement.references_table('schema_author'), False) self.assertIs(statement.references_table('schema_book'), False) def test_rename_column_renames_deferred_sql_references(self): with connection.schema_editor() as editor: editor.create_model(Author) editor.create_model(Book) old_title = Book._meta.get_field('title') new_title = CharField(max_length=100, db_index=True) new_title.set_attributes_from_name('renamed_title') editor.alter_field(Book, old_title, new_title) old_author = Book._meta.get_field('author') new_author = ForeignKey(Author, CASCADE) new_author.set_attributes_from_name('renamed_author') editor.alter_field(Book, old_author, new_author) self.assertGreater(len(editor.deferred_sql), 0) for statement in editor.deferred_sql: self.assertIs(statement.references_column('book', 'title'), False) self.assertIs(statement.references_column('book', 'author_id'), False) @isolate_apps('schema') def test_referenced_field_without_constraint_rename_inside_atomic_block(self): """ Foreign keys without database level constraint don't prevent the field they reference from being renamed in an atomic block. """ class Foo(Model): field = CharField(max_length=255, unique=True) class Meta: app_label = 'schema' class Bar(Model): foo = ForeignKey(Foo, CASCADE, to_field='field', db_constraint=False) class Meta: app_label = 'schema' self.isolated_local_models = [Foo, Bar] with connection.schema_editor() as editor: editor.create_model(Foo) editor.create_model(Bar) new_field = CharField(max_length=255, unique=True) new_field.set_attributes_from_name('renamed') with connection.schema_editor(atomic=True) as editor: editor.alter_field(Foo, Foo._meta.get_field('field'), new_field) @isolate_apps('schema') def test_referenced_table_without_constraint_rename_inside_atomic_block(self): """ Foreign keys without database level constraint don't prevent the table they reference from being renamed in an atomic block. """ class Foo(Model): field = CharField(max_length=255, unique=True) class Meta: app_label = 'schema' class Bar(Model): foo = ForeignKey(Foo, CASCADE, to_field='field', db_constraint=False) class Meta: app_label = 'schema' self.isolated_local_models = [Foo, Bar] with connection.schema_editor() as editor: editor.create_model(Foo) editor.create_model(Bar) new_field = CharField(max_length=255, unique=True) new_field.set_attributes_from_name('renamed') with connection.schema_editor(atomic=True) as editor: editor.alter_db_table(Foo, Foo._meta.db_table, 'renamed_table') Foo._meta.db_table = 'renamed_table' @isolate_apps('schema') @skipUnlessDBFeature('supports_collation_on_charfield') def test_db_collation_charfield(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest('Language collations are not supported.') class Foo(Model): field = CharField(max_length=255, db_collation=collation) class Meta: app_label = 'schema' self.isolated_local_models = [Foo] with connection.schema_editor() as editor: editor.create_model(Foo) self.assertEqual( self.get_column_collation(Foo._meta.db_table, 'field'), collation, ) @isolate_apps('schema') @skipUnlessDBFeature('supports_collation_on_textfield') def test_db_collation_textfield(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest('Language collations are not supported.') class Foo(Model): field = TextField(db_collation=collation) class Meta: app_label = 'schema' self.isolated_local_models = [Foo] with connection.schema_editor() as editor: editor.create_model(Foo) self.assertEqual( self.get_column_collation(Foo._meta.db_table, 'field'), collation, ) @skipUnlessDBFeature('supports_collation_on_charfield') def test_add_field_db_collation(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest('Language collations are not supported.') with connection.schema_editor() as editor: editor.create_model(Author) new_field = CharField(max_length=255, db_collation=collation) new_field.set_attributes_from_name('alias') with connection.schema_editor() as editor: editor.add_field(Author, new_field) columns = self.column_classes(Author) self.assertEqual( columns['alias'][0], connection.features.introspected_field_types['CharField'], ) self.assertEqual(columns['alias'][1][8], collation) @skipUnlessDBFeature('supports_collation_on_charfield') def test_alter_field_db_collation(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest('Language collations are not supported.') with connection.schema_editor() as editor: editor.create_model(Author) old_field = Author._meta.get_field('name') new_field = CharField(max_length=255, db_collation=collation) new_field.set_attributes_from_name('name') new_field.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field, strict=True) self.assertEqual( self.get_column_collation(Author._meta.db_table, 'name'), collation, ) with connection.schema_editor() as editor: editor.alter_field(Author, new_field, old_field, strict=True) self.assertIsNone(self.get_column_collation(Author._meta.db_table, 'name')) @skipUnlessDBFeature('supports_collation_on_charfield') def test_alter_field_type_and_db_collation(self): collation = connection.features.test_collations.get('non_default') if not collation: self.skipTest('Language collations are not supported.') with connection.schema_editor() as editor: editor.create_model(Note) old_field = Note._meta.get_field('info') new_field = CharField(max_length=255, db_collation=collation) new_field.set_attributes_from_name('info') new_field.model = Note with connection.schema_editor() as editor: editor.alter_field(Note, old_field, new_field, strict=True) columns = self.column_classes(Note) self.assertEqual( columns['info'][0], connection.features.introspected_field_types['CharField'], ) self.assertEqual(columns['info'][1][8], collation) with connection.schema_editor() as editor: editor.alter_field(Note, new_field, old_field, strict=True) columns = self.column_classes(Note) self.assertEqual(columns['info'][0], 'TextField') self.assertIsNone(columns['info'][1][8]) @skipUnlessDBFeature( 'supports_collation_on_charfield', 'supports_non_deterministic_collations', ) def test_ci_cs_db_collation(self): cs_collation = connection.features.test_collations.get('cs') ci_collation = connection.features.test_collations.get('ci') try: if connection.vendor == 'mysql': cs_collation = 'latin1_general_cs' elif connection.vendor == 'postgresql': cs_collation = 'en-x-icu' with connection.cursor() as cursor: cursor.execute( "CREATE COLLATION IF NOT EXISTS case_insensitive " "(provider = icu, locale = 'und-u-ks-level2', " "deterministic = false)" ) ci_collation = 'case_insensitive' # Create the table. with connection.schema_editor() as editor: editor.create_model(Author) # Case-insensitive collation. old_field = Author._meta.get_field('name') new_field_ci = CharField(max_length=255, db_collation=ci_collation) new_field_ci.set_attributes_from_name('name') new_field_ci.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, old_field, new_field_ci, strict=True) Author.objects.create(name='ANDREW') self.assertIs(Author.objects.filter(name='Andrew').exists(), True) # Case-sensitive collation. new_field_cs = CharField(max_length=255, db_collation=cs_collation) new_field_cs.set_attributes_from_name('name') new_field_cs.model = Author with connection.schema_editor() as editor: editor.alter_field(Author, new_field_ci, new_field_cs, strict=True) self.assertIs(Author.objects.filter(name='Andrew').exists(), False) finally: if connection.vendor == 'postgresql': with connection.cursor() as cursor: cursor.execute('DROP COLLATION IF EXISTS case_insensitive')
bsd-3-clause
[ 646, 2197, 199, 646, 7975, 199, 646, 2882, 199, 504, 1331, 492, 1331, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 949, 63, 2487, 199, 504, 1639, 14, 697, 492, 334, 272, 27728, 12, 3918, 547, 12, 26864, 12, 6654, 6279, 547, 12, 1950, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 492, 334, 272, 27751, 9947, 12, 3611, 52, 3582, 12, 9195, 792, 12, 13123, 4378, 12, 13123, 3901, 12, 14161, 792, 12, 272, 9411, 792, 12, 12064, 12, 2670, 8463, 12, 30997, 12, 31637, 12, 272, 6345, 792, 12, 481, 12, 11140, 792, 12, 12718, 12, 481, 2692, 1692, 12, 5499, 12, 272, 26141, 12, 4840, 792, 12, 28409, 12, 5822, 12, 7309, 13216, 12, 9240, 2175, 12, 272, 30245, 3901, 12, 1413, 12, 428, 32047, 792, 12, 23704, 4378, 12, 23704, 3901, 12, 272, 4516, 792, 12, 4703, 792, 12, 18276, 8463, 12, 11134, 792, 12, 1594, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 1001, 492, 2606, 1872, 6939, 199, 504, 1639, 14, 697, 14, 992, 14, 5777, 492, 20319, 12, 445, 1810, 12, 3626, 750, 12, 29893, 12, 9571, 12, 4949, 529, 199, 504, 1639, 14, 697, 14, 992, 14, 10116, 492, 5499, 9093, 199, 504, 1639, 14, 697, 14, 5945, 492, 18244, 14552, 547, 12, 15374, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 1208, 492, 334, 272, 29828, 13611, 2998, 12, 365, 16288, 63, 5181, 12, 2274, 63, 3892, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 7137, 199, 199, 504, 1275, 955, 492, 334, 272, 8388, 7624, 12, 1010, 8829, 7624, 12, 3194, 12980, 16799, 792, 12, 199, 9, 199, 504, 1275, 992, 492, 334, 272, 6529, 12, 6529, 2183, 3007, 2681, 12, 6529, 6254, 3007, 2681, 12, 272, 6529, 3007, 2698, 8436, 12, 6529, 3007, 29704, 31253, 836, 985, 12, 6529, 3007, 19067, 985, 12, 272, 6529, 3007, 19067, 985, 3325, 29229, 2977, 12, 6529, 3007, 11427, 985, 12, 272, 6529, 3007, 11427, 985, 3325, 29229, 2977, 12, 8944, 12, 8944, 20931, 5665, 12, 8944, 18889, 12, 272, 8944, 3007, 9551, 985, 12, 8944, 3007, 47, 18, 47, 12, 8944, 12450, 5949, 12, 8944, 3007, 15554, 12, 7225, 8884, 12, 272, 5013, 12, 3390, 12, 3390, 16843, 12, 8053, 12, 8053, 19067, 12, 8053, 45, 18, 45, 774, 12, 8053, 11427, 16843, 12, 272, 3868, 316, 12, 18276, 774, 12, 892, 63, 5181, 12, 199, 9, 421, 199, 533, 13268, 2925, 8, 10161, 1746, 304, 272, 408, 272, 6496, 367, 314, 4177, 13, 279, 5388, 1233, 14, 339, 6423, 20381, 626, 3520, 2295, 787, 1655, 1212, 461, 2419, 4750, 370, 3055, 2058, 12, 272, 465, 15026, 314, 1233, 370, 1104, 340, 282, 511, 965, 26731, 365, 18871, 465, 6114, 272, 465, 314, 1233, 652, 365, 5343, 14, 272, 408, 339, 2808, 63, 5181, 275, 942, 339, 1709, 275, 359, 267, 6529, 12, 6529, 2183, 3007, 2681, 12, 6529, 6254, 3007, 2681, 12, 267, 6529, 3007, 2698, 8436, 12, 6529, 3007, 29704, 31253, 836, 985, 12, 8944, 12, 8944, 18889, 12, 267, 8944, 3007, 9551, 985, 12, 8944, 3007, 47, 18, 47, 12, 8944, 3007, 15554, 12, 7225, 8884, 12, 5013, 12, 3390, 12, 267, 8053, 12, 8053, 19067, 12, 8053, 45, 18, 45, 774, 12, 8053, 11427, 16843, 12, 3868, 316, 12, 18276, 774, 12, 272, 1622, 339, 327, 20511, 3423, 339, 347, 3613, 8, 277, 304, 267, 327, 2257, 63, 992, 1077, 1395, 511, 11410, 1402, 3992, 626, 911, 506, 267, 327, 5847, 4829, 687, 314, 1145, 2581, 641, 511, 1565, 285, 3224, 14, 267, 291, 14, 1832, 63, 992, 275, 942, 267, 327, 23348, 63, 1832, 63, 992, 3509, 1709, 626, 787, 315, 511, 3102, 267, 327, 16225, 543, 768, 31188, 63, 5181, 14, 267, 291, 14, 21748, 63, 1832, 63, 992, 275, 942, 339, 347, 6766, 8, 277, 304, 267, 327, 8496, 1263, 6716, 6326, 367, 4154, 1709, 267, 291, 14, 1807, 63, 5987, 342, 267, 892, 63, 5181, 14, 3584, 63, 1637, 342, 267, 367, 1402, 315, 892, 63, 5181, 14, 362, 63, 992, 837, 288, 1402, 423, 2024, 423, 14691, 63, 1637, 342, 267, 340, 283, 3629, 7, 315, 892, 63, 5181, 14, 452, 63, 992, 26, 288, 367, 1402, 315, 291, 14, 1832, 63, 992, 26, 355, 367, 5002, 63, 475, 63, 3479, 315, 1402, 423, 2024, 14, 3479, 63, 475, 63, 3479, 26, 490, 4012, 275, 5002, 63, 475, 63, 3479, 14, 3846, 63, 698, 14, 8304, 490, 340, 4012, 436, 4012, 423, 2024, 14, 2495, 63, 3966, 26, 717, 2150, 892, 63, 5181, 14, 452, 63, 992, 459, 3629, 3488, 8304, 423, 2024, 14, 1238, 63, 354, 61, 355, 2150, 892, 63, 5181, 14, 452, 63, 992, 459, 3629, 3488, 1238, 423, 2024, 14, 1238, 63, 354, 61, 267, 340, 291, 14, 21748, 63, 1832, 63, 992, 26, 288, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 355, 367, 1402, 315, 291, 14, 21748, 63, 1832, 63, 992, 26, 490, 8823, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 3145, 63, 5987, 8, 277, 304, 267, 298, 26372, 1006, 1402, 6716, 367, 4154, 1709, 367, 282, 3633, 511, 3734, 2, 267, 11109, 275, 1950, 14, 21627, 14, 5364, 63, 11256, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 1950, 14, 5993, 63, 5631, 63, 19527, 342, 288, 1817, 63, 1247, 275, 1950, 14, 21627, 14, 1224, 63, 1247, 342, 288, 340, 1950, 14, 3179, 14, 11050, 470, 63, 1224, 63, 354, 63, 2546, 26, 355, 1817, 63, 1247, 275, 359, 1224, 63, 354, 14, 2325, 342, 367, 1817, 63, 354, 315, 1817, 63, 1247, 61, 288, 367, 1402, 315, 7975, 14, 4429, 8, 6700, 2925, 14, 992, 12, 291, 14, 1832, 63, 992, 304, 355, 19049, 275, 11109, 8, 1238, 423, 2024, 14, 697, 63, 1224, 9, 355, 340, 1950, 14, 3179, 14, 11050, 470, 63, 1224, 63, 354, 63, 2546, 26, 490, 19049, 275, 19049 ]
[ 2197, 199, 646, 7975, 199, 646, 2882, 199, 504, 1331, 492, 1331, 199, 504, 2882, 492, 1683, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 27691, 199, 504, 1639, 14, 1018, 14, 8110, 14, 2326, 492, 949, 63, 2487, 199, 504, 1639, 14, 697, 492, 334, 272, 27728, 12, 3918, 547, 12, 26864, 12, 6654, 6279, 547, 12, 1950, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 492, 334, 272, 27751, 9947, 12, 3611, 52, 3582, 12, 9195, 792, 12, 13123, 4378, 12, 13123, 3901, 12, 14161, 792, 12, 272, 9411, 792, 12, 12064, 12, 2670, 8463, 12, 30997, 12, 31637, 12, 272, 6345, 792, 12, 481, 12, 11140, 792, 12, 12718, 12, 481, 2692, 1692, 12, 5499, 12, 272, 26141, 12, 4840, 792, 12, 28409, 12, 5822, 12, 7309, 13216, 12, 9240, 2175, 12, 272, 30245, 3901, 12, 1413, 12, 428, 32047, 792, 12, 23704, 4378, 12, 23704, 3901, 12, 272, 4516, 792, 12, 4703, 792, 12, 18276, 8463, 12, 11134, 792, 12, 1594, 12, 199, 9, 199, 504, 1639, 14, 697, 14, 992, 14, 955, 14, 1001, 492, 2606, 1872, 6939, 199, 504, 1639, 14, 697, 14, 992, 14, 5777, 492, 20319, 12, 445, 1810, 12, 3626, 750, 12, 29893, 12, 9571, 12, 4949, 529, 199, 504, 1639, 14, 697, 14, 992, 14, 10116, 492, 5499, 9093, 199, 504, 1639, 14, 697, 14, 5945, 492, 18244, 14552, 547, 12, 15374, 199, 504, 1639, 14, 396, 492, 334, 272, 18244, 1746, 12, 3372, 3917, 18093, 12, 3372, 5524, 18093, 12, 199, 9, 199, 504, 1639, 14, 396, 14, 1208, 492, 334, 272, 29828, 13611, 2998, 12, 365, 16288, 63, 5181, 12, 2274, 63, 3892, 12, 199, 9, 199, 504, 1639, 14, 1208, 492, 7137, 199, 199, 504, 1275, 955, 492, 334, 272, 8388, 7624, 12, 1010, 8829, 7624, 12, 3194, 12980, 16799, 792, 12, 199, 9, 199, 504, 1275, 992, 492, 334, 272, 6529, 12, 6529, 2183, 3007, 2681, 12, 6529, 6254, 3007, 2681, 12, 272, 6529, 3007, 2698, 8436, 12, 6529, 3007, 29704, 31253, 836, 985, 12, 6529, 3007, 19067, 985, 12, 272, 6529, 3007, 19067, 985, 3325, 29229, 2977, 12, 6529, 3007, 11427, 985, 12, 272, 6529, 3007, 11427, 985, 3325, 29229, 2977, 12, 8944, 12, 8944, 20931, 5665, 12, 8944, 18889, 12, 272, 8944, 3007, 9551, 985, 12, 8944, 3007, 47, 18, 47, 12, 8944, 12450, 5949, 12, 8944, 3007, 15554, 12, 7225, 8884, 12, 272, 5013, 12, 3390, 12, 3390, 16843, 12, 8053, 12, 8053, 19067, 12, 8053, 45, 18, 45, 774, 12, 8053, 11427, 16843, 12, 272, 3868, 316, 12, 18276, 774, 12, 892, 63, 5181, 12, 199, 9, 421, 199, 533, 13268, 2925, 8, 10161, 1746, 304, 272, 408, 272, 6496, 367, 314, 4177, 13, 279, 5388, 1233, 14, 339, 6423, 20381, 626, 3520, 2295, 787, 1655, 1212, 461, 2419, 4750, 370, 3055, 2058, 12, 272, 465, 15026, 314, 1233, 370, 1104, 340, 282, 511, 965, 26731, 365, 18871, 465, 6114, 272, 465, 314, 1233, 652, 365, 5343, 14, 272, 408, 339, 2808, 63, 5181, 275, 942, 339, 1709, 275, 359, 267, 6529, 12, 6529, 2183, 3007, 2681, 12, 6529, 6254, 3007, 2681, 12, 267, 6529, 3007, 2698, 8436, 12, 6529, 3007, 29704, 31253, 836, 985, 12, 8944, 12, 8944, 18889, 12, 267, 8944, 3007, 9551, 985, 12, 8944, 3007, 47, 18, 47, 12, 8944, 3007, 15554, 12, 7225, 8884, 12, 5013, 12, 3390, 12, 267, 8053, 12, 8053, 19067, 12, 8053, 45, 18, 45, 774, 12, 8053, 11427, 16843, 12, 3868, 316, 12, 18276, 774, 12, 272, 1622, 339, 327, 20511, 3423, 339, 347, 3613, 8, 277, 304, 267, 327, 2257, 63, 992, 1077, 1395, 511, 11410, 1402, 3992, 626, 911, 506, 267, 327, 5847, 4829, 687, 314, 1145, 2581, 641, 511, 1565, 285, 3224, 14, 267, 291, 14, 1832, 63, 992, 275, 942, 267, 327, 23348, 63, 1832, 63, 992, 3509, 1709, 626, 787, 315, 511, 3102, 267, 327, 16225, 543, 768, 31188, 63, 5181, 14, 267, 291, 14, 21748, 63, 1832, 63, 992, 275, 942, 339, 347, 6766, 8, 277, 304, 267, 327, 8496, 1263, 6716, 6326, 367, 4154, 1709, 267, 291, 14, 1807, 63, 5987, 342, 267, 892, 63, 5181, 14, 3584, 63, 1637, 342, 267, 367, 1402, 315, 892, 63, 5181, 14, 362, 63, 992, 837, 288, 1402, 423, 2024, 423, 14691, 63, 1637, 342, 267, 340, 283, 3629, 7, 315, 892, 63, 5181, 14, 452, 63, 992, 26, 288, 367, 1402, 315, 291, 14, 1832, 63, 992, 26, 355, 367, 5002, 63, 475, 63, 3479, 315, 1402, 423, 2024, 14, 3479, 63, 475, 63, 3479, 26, 490, 4012, 275, 5002, 63, 475, 63, 3479, 14, 3846, 63, 698, 14, 8304, 490, 340, 4012, 436, 4012, 423, 2024, 14, 2495, 63, 3966, 26, 717, 2150, 892, 63, 5181, 14, 452, 63, 992, 459, 3629, 3488, 8304, 423, 2024, 14, 1238, 63, 354, 61, 355, 2150, 892, 63, 5181, 14, 452, 63, 992, 459, 3629, 3488, 1238, 423, 2024, 14, 1238, 63, 354, 61, 267, 340, 291, 14, 21748, 63, 1832, 63, 992, 26, 288, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 355, 367, 1402, 315, 291, 14, 21748, 63, 1832, 63, 992, 26, 490, 8823, 14, 1807, 63, 1238, 8, 1238, 9, 339, 347, 3145, 63, 5987, 8, 277, 304, 267, 298, 26372, 1006, 1402, 6716, 367, 4154, 1709, 367, 282, 3633, 511, 3734, 2, 267, 11109, 275, 1950, 14, 21627, 14, 5364, 63, 11256, 267, 543, 1950, 14, 3629, 63, 7515, 342, 465, 8823, 26, 288, 1950, 14, 5993, 63, 5631, 63, 19527, 342, 288, 1817, 63, 1247, 275, 1950, 14, 21627, 14, 1224, 63, 1247, 342, 288, 340, 1950, 14, 3179, 14, 11050, 470, 63, 1224, 63, 354, 63, 2546, 26, 355, 1817, 63, 1247, 275, 359, 1224, 63, 354, 14, 2325, 342, 367, 1817, 63, 354, 315, 1817, 63, 1247, 61, 288, 367, 1402, 315, 7975, 14, 4429, 8, 6700, 2925, 14, 992, 12, 291, 14, 1832, 63, 992, 304, 355, 19049, 275, 11109, 8, 1238, 423, 2024, 14, 697, 63, 1224, 9, 355, 340, 1950, 14, 3179, 14, 11050, 470, 63, 1224, 63, 354, 63, 2546, 26, 490, 19049, 275, 19049, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
bpgc-cte/python2017
Week 7/django/lib/python3.6/site-packages/django/template/response.py
50
5594
from django.http import HttpResponse from django.utils import six from .loader import get_template, select_template class ContentNotRenderedError(Exception): pass class SimpleTemplateResponse(HttpResponse): rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks'] def __init__(self, template, context=None, content_type=None, status=None, charset=None, using=None): # It would seem obvious to call these next two members 'template' and # 'context', but those names are reserved as part of the test Client # API. To avoid the name collision, we use different names. self.template_name = template self.context_data = context self.using = using self._post_render_callbacks = [] # _request stores the current request object in subclasses that know # about requests, like TemplateResponse. It's defined in the base class # to minimize code duplication. # It's called self._request because self.request gets overwritten by # django.test.client.Client. Unlike template_name and context_data, # _request should not be considered part of the public API. self._request = None # content argument doesn't make sense here because it will be replaced # with rendered template so we always pass empty string in order to # prevent errors and provide shorter signature. super(SimpleTemplateResponse, self).__init__('', content_type, status, charset=charset) # _is_rendered tracks whether the template and context has been baked # into a final response. # Super __init__ doesn't know any better than to set self.content to # the empty string we just gave it, which wrongly sets _is_rendered # True, so we initialize it to False after the call to super __init__. self._is_rendered = False def __getstate__(self): """ Raise an exception if trying to pickle an unrendered response. Pickle only rendered data, not the data used to construct the response. """ obj_dict = self.__dict__.copy() if not self._is_rendered: raise ContentNotRenderedError('The response content must be ' 'rendered before it can be pickled.') for attr in self.rendering_attrs: if attr in obj_dict: del obj_dict[attr] return obj_dict def resolve_template(self, template): "Accepts a template object, path-to-template or list of paths" if isinstance(template, (list, tuple)): return select_template(template, using=self.using) elif isinstance(template, six.string_types): return get_template(template, using=self.using) else: return template def resolve_context(self, context): return context @property def rendered_content(self): """Returns the freshly rendered content for the template and context described by the TemplateResponse. This *does not* set the final content of the response. To set the response content, you must either call render(), or set the content explicitly using the value of this property. """ template = self.resolve_template(self.template_name) context = self.resolve_context(self.context_data) content = template.render(context, self._request) return content def add_post_render_callback(self, callback): """Adds a new post-rendering callback. If the response has already been rendered, invoke the callback immediately. """ if self._is_rendered: callback(self) else: self._post_render_callbacks.append(callback) def render(self): """Renders (thereby finalizing) the content of the response. If the content has already been rendered, this is a no-op. Returns the baked response instance. """ retval = self if not self._is_rendered: self.content = self.rendered_content for post_callback in self._post_render_callbacks: newretval = post_callback(retval) if newretval is not None: retval = newretval return retval @property def is_rendered(self): return self._is_rendered def __iter__(self): if not self._is_rendered: raise ContentNotRenderedError( 'The response content must be rendered before it can be iterated over.' ) return super(SimpleTemplateResponse, self).__iter__() @property def content(self): if not self._is_rendered: raise ContentNotRenderedError( 'The response content must be rendered before it can be accessed.' ) return super(SimpleTemplateResponse, self).content @content.setter def content(self, value): """Sets the content for the response """ HttpResponse.content.fset(self, value) self._is_rendered = True class TemplateResponse(SimpleTemplateResponse): rendering_attrs = SimpleTemplateResponse.rendering_attrs + ['_request'] def __init__(self, request, template, context=None, content_type=None, status=None, charset=None, using=None): super(TemplateResponse, self).__init__( template, context, content_type, status, charset, using) self._request = request
mit
[ 504, 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 3422, 492, 664, 63, 1160, 12, 3504, 63, 1160, 421, 199, 533, 6646, 1763, 5349, 2995, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 5870, 31036, 8, 16287, 304, 272, 14066, 63, 3288, 275, 788, 1160, 63, 354, 297, 283, 1100, 63, 576, 297, 2513, 1932, 63, 3352, 63, 11948, 418, 339, 347, 636, 826, 721, 277, 12, 1978, 12, 1067, 29, 403, 12, 1564, 63, 466, 29, 403, 12, 2004, 29, 403, 12, 326, 5960, 29, 403, 12, 1808, 29, 403, 304, 267, 327, 2779, 3955, 17021, 25259, 370, 1240, 3520, 2163, 2877, 7556, 283, 1160, 7, 436, 267, 327, 283, 1100, 297, 1325, 5204, 1561, 787, 4644, 465, 1777, 402, 314, 511, 6810, 267, 327, 3261, 14, 4005, 5126, 314, 536, 25061, 12, 781, 675, 3365, 1561, 14, 267, 291, 14, 1160, 63, 354, 275, 1978, 267, 291, 14, 1100, 63, 576, 275, 1067, 398, 291, 14, 4941, 275, 1808, 398, 291, 423, 1932, 63, 3352, 63, 11948, 275, 942, 398, 327, 485, 1069, 14086, 314, 1453, 1056, 909, 315, 9180, 626, 5715, 267, 327, 3595, 4145, 12, 2839, 29264, 14, 2779, 1159, 3247, 315, 314, 1300, 1021, 267, 327, 370, 24720, 1233, 11866, 1863, 14, 267, 327, 2779, 1159, 2797, 291, 423, 1069, 2952, 291, 14, 1069, 7545, 20200, 701, 267, 327, 1639, 14, 396, 14, 1258, 14, 3041, 14, 25059, 1978, 63, 354, 436, 1067, 63, 576, 12, 267, 327, 485, 1069, 1077, 440, 506, 8652, 1777, 402, 314, 4575, 3261, 14, 267, 291, 423, 1069, 275, 488, 398, 327, 1564, 1423, 3181, 1133, 1852, 12249, 2348, 2952, 652, 911, 506, 8717, 267, 327, 543, 8018, 1978, 880, 781, 3544, 986, 2701, 1059, 315, 1865, 370, 267, 327, 7981, 2552, 436, 5647, 18299, 4955, 14, 267, 1613, 8, 3184, 31036, 12, 291, 2843, 826, 363, 8594, 1564, 63, 466, 12, 2004, 12, 5960, 29, 6043, 9, 398, 327, 485, 374, 63, 16841, 18917, 3775, 314, 1978, 436, 1067, 965, 2757, 330, 16702, 267, 327, 1901, 282, 4242, 1177, 14, 267, 327, 17897, 636, 826, 363, 3181, 1133, 5715, 1263, 8034, 2419, 370, 663, 291, 14, 1317, 370, 267, 327, 314, 2701, 1059, 781, 2951, 486, 811, 652, 12, 1314, 6835, 590, 5951, 485, 374, 63, 16841, 267, 327, 715, 12, 880, 781, 8265, 652, 370, 756, 2410, 314, 1240, 370, 1613, 636, 826, 4343, 267, 291, 423, 374, 63, 16841, 275, 756, 339, 347, 636, 16011, 721, 277, 304, 267, 408, 267, 14771, 376, 1919, 340, 9936, 370, 5927, 376, 625, 16841, 1177, 14, 31732, 267, 1454, 8018, 666, 12, 440, 314, 666, 1202, 370, 6982, 314, 1177, 14, 267, 408, 267, 1559, 63, 807, 275, 291, 855, 807, 4343, 1574, 342, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 360, 1918, 1177, 1564, 1471, 506, 283, 5101, 283, 16841, 2544, 652, 883, 506, 18731, 2659, 267, 367, 1921, 315, 291, 14, 28228, 63, 3288, 26, 288, 340, 1921, 315, 1559, 63, 807, 26, 355, 2150, 1559, 63, 807, 59, 962, 61, 398, 372, 1559, 63, 807, 339, 347, 7512, 63, 1160, 8, 277, 12, 1978, 304, 267, 298, 8422, 83, 282, 1978, 909, 12, 931, 13, 475, 13, 1160, 503, 769, 402, 3792, 2, 267, 340, 1228, 8, 1160, 12, 334, 513, 12, 2008, 2298, 288, 372, 3504, 63, 1160, 8, 1160, 12, 1808, 29, 277, 14, 4941, 9, 267, 916, 1228, 8, 1160, 12, 3816, 14, 875, 63, 1313, 304, 288, 372, 664, 63, 1160, 8, 1160, 12, 1808, 29, 277, 14, 4941, 9, 267, 587, 26, 288, 372, 1978, 339, 347, 7512, 63, 1100, 8, 277, 12, 1067, 304, 267, 372, 1067, 339, 768, 1829, 272, 347, 8018, 63, 1317, 8, 277, 304, 267, 408, 3407, 314, 17480, 590, 8018, 1564, 367, 314, 1978, 436, 1067, 267, 11736, 701, 314, 29264, 14, 398, 961, 627, 9105, 440, 10, 663, 314, 4242, 1564, 402, 314, 1177, 14, 4005, 663, 314, 267, 1177, 1564, 12, 1265, 1471, 1902, 1240, 3795, 1062, 503, 663, 314, 267, 1564, 7662, 1808, 314, 574, 402, 642, 3324, 14, 267, 408, 267, 1978, 275, 291, 14, 6983, 63, 1160, 8, 277, 14, 1160, 63, 354, 9, 267, 1067, 275, 291, 14, 6983, 63, 1100, 8, 277, 14, 1100, 63, 576, 9, 267, 1564, 275, 1978, 14, 3352, 8, 1100, 12, 291, 423, 1069, 9, 267, 372, 1564, 339, 347, 1050, 63, 1932, 63, 3352, 63, 3058, 8, 277, 12, 3233, 304, 267, 408, 14995, 282, 892, 2963, 13, 28228, 3233, 14, 398, 982, 314, 1177, 965, 2575, 2757, 8018, 12, 267, 12677, 314, 3233, 9939, 14, 267, 408, 267, 340, 291, 423, 374, 63, 16841, 26, 288, 3233, 8, 277, 9, 267, 587, 26, 288, 291, 423, 1932, 63, 3352, 63, 11948, 14, 740, 8, 3058, 9, 339, 347, 3795, 8, 277, 304, 267, 408, 5349, 7735, 334, 16990, 991, 4242, 9147, 9, 314, 1564, 402, 314, 1177, 14, 398, 982, 314, 1564, 965, 2575, 2757, 8018, 12, 642, 365, 282, 949, 13, 411, 14, 398, 1803, 314, 330, 16702, 1177, 1256, 14, 267, 408, 267, 9151, 275, 291, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 291, 14, 1317, 275, 291, 14, 16841, 63, 1317, 288, 367, 2963, 63, 3058, 315, 291, 423, 1932, 63, 3352, 63, 11948, 26, 355, 892, 18476, 275, 2963, 63, 3058, 8, 18476, 9, 355, 340, 892, 18476, 365, 440, 488, 26, 490, 9151, 275, 892, 18476, 267, 372, 9151, 339, 768, 1829, 272, 347, 365, 63, 16841, 8, 277, 304, 267, 372, 291, 423, 374, 63, 16841, 339, 347, 636, 1661, 721, 277, 304, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 8, 355, 283, 1918, 1177, 1564, 1471, 506, 8018, 2544, 652, 883, 506, 27924, 1806, 3530, 288, 776, 267, 372, 1613, 8, 3184, 31036, 12, 291, 2843, 1661, 4533, 339, 768, 1829, 272, 347, 1564, 8, 277, 304, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 8, 355, 283, 1918, 1177 ]
[ 1639, 14, 1014, 492, 6183, 199, 504, 1639, 14, 1208, 492, 3816, 199, 199, 504, 1275, 3422, 492, 664, 63, 1160, 12, 3504, 63, 1160, 421, 199, 533, 6646, 1763, 5349, 2995, 547, 8, 1726, 304, 272, 986, 421, 199, 533, 5870, 31036, 8, 16287, 304, 272, 14066, 63, 3288, 275, 788, 1160, 63, 354, 297, 283, 1100, 63, 576, 297, 2513, 1932, 63, 3352, 63, 11948, 418, 339, 347, 636, 826, 721, 277, 12, 1978, 12, 1067, 29, 403, 12, 1564, 63, 466, 29, 403, 12, 2004, 29, 403, 12, 326, 5960, 29, 403, 12, 1808, 29, 403, 304, 267, 327, 2779, 3955, 17021, 25259, 370, 1240, 3520, 2163, 2877, 7556, 283, 1160, 7, 436, 267, 327, 283, 1100, 297, 1325, 5204, 1561, 787, 4644, 465, 1777, 402, 314, 511, 6810, 267, 327, 3261, 14, 4005, 5126, 314, 536, 25061, 12, 781, 675, 3365, 1561, 14, 267, 291, 14, 1160, 63, 354, 275, 1978, 267, 291, 14, 1100, 63, 576, 275, 1067, 398, 291, 14, 4941, 275, 1808, 398, 291, 423, 1932, 63, 3352, 63, 11948, 275, 942, 398, 327, 485, 1069, 14086, 314, 1453, 1056, 909, 315, 9180, 626, 5715, 267, 327, 3595, 4145, 12, 2839, 29264, 14, 2779, 1159, 3247, 315, 314, 1300, 1021, 267, 327, 370, 24720, 1233, 11866, 1863, 14, 267, 327, 2779, 1159, 2797, 291, 423, 1069, 2952, 291, 14, 1069, 7545, 20200, 701, 267, 327, 1639, 14, 396, 14, 1258, 14, 3041, 14, 25059, 1978, 63, 354, 436, 1067, 63, 576, 12, 267, 327, 485, 1069, 1077, 440, 506, 8652, 1777, 402, 314, 4575, 3261, 14, 267, 291, 423, 1069, 275, 488, 398, 327, 1564, 1423, 3181, 1133, 1852, 12249, 2348, 2952, 652, 911, 506, 8717, 267, 327, 543, 8018, 1978, 880, 781, 3544, 986, 2701, 1059, 315, 1865, 370, 267, 327, 7981, 2552, 436, 5647, 18299, 4955, 14, 267, 1613, 8, 3184, 31036, 12, 291, 2843, 826, 363, 8594, 1564, 63, 466, 12, 2004, 12, 5960, 29, 6043, 9, 398, 327, 485, 374, 63, 16841, 18917, 3775, 314, 1978, 436, 1067, 965, 2757, 330, 16702, 267, 327, 1901, 282, 4242, 1177, 14, 267, 327, 17897, 636, 826, 363, 3181, 1133, 5715, 1263, 8034, 2419, 370, 663, 291, 14, 1317, 370, 267, 327, 314, 2701, 1059, 781, 2951, 486, 811, 652, 12, 1314, 6835, 590, 5951, 485, 374, 63, 16841, 267, 327, 715, 12, 880, 781, 8265, 652, 370, 756, 2410, 314, 1240, 370, 1613, 636, 826, 4343, 267, 291, 423, 374, 63, 16841, 275, 756, 339, 347, 636, 16011, 721, 277, 304, 267, 408, 267, 14771, 376, 1919, 340, 9936, 370, 5927, 376, 625, 16841, 1177, 14, 31732, 267, 1454, 8018, 666, 12, 440, 314, 666, 1202, 370, 6982, 314, 1177, 14, 267, 408, 267, 1559, 63, 807, 275, 291, 855, 807, 4343, 1574, 342, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 360, 1918, 1177, 1564, 1471, 506, 283, 5101, 283, 16841, 2544, 652, 883, 506, 18731, 2659, 267, 367, 1921, 315, 291, 14, 28228, 63, 3288, 26, 288, 340, 1921, 315, 1559, 63, 807, 26, 355, 2150, 1559, 63, 807, 59, 962, 61, 398, 372, 1559, 63, 807, 339, 347, 7512, 63, 1160, 8, 277, 12, 1978, 304, 267, 298, 8422, 83, 282, 1978, 909, 12, 931, 13, 475, 13, 1160, 503, 769, 402, 3792, 2, 267, 340, 1228, 8, 1160, 12, 334, 513, 12, 2008, 2298, 288, 372, 3504, 63, 1160, 8, 1160, 12, 1808, 29, 277, 14, 4941, 9, 267, 916, 1228, 8, 1160, 12, 3816, 14, 875, 63, 1313, 304, 288, 372, 664, 63, 1160, 8, 1160, 12, 1808, 29, 277, 14, 4941, 9, 267, 587, 26, 288, 372, 1978, 339, 347, 7512, 63, 1100, 8, 277, 12, 1067, 304, 267, 372, 1067, 339, 768, 1829, 272, 347, 8018, 63, 1317, 8, 277, 304, 267, 408, 3407, 314, 17480, 590, 8018, 1564, 367, 314, 1978, 436, 1067, 267, 11736, 701, 314, 29264, 14, 398, 961, 627, 9105, 440, 10, 663, 314, 4242, 1564, 402, 314, 1177, 14, 4005, 663, 314, 267, 1177, 1564, 12, 1265, 1471, 1902, 1240, 3795, 1062, 503, 663, 314, 267, 1564, 7662, 1808, 314, 574, 402, 642, 3324, 14, 267, 408, 267, 1978, 275, 291, 14, 6983, 63, 1160, 8, 277, 14, 1160, 63, 354, 9, 267, 1067, 275, 291, 14, 6983, 63, 1100, 8, 277, 14, 1100, 63, 576, 9, 267, 1564, 275, 1978, 14, 3352, 8, 1100, 12, 291, 423, 1069, 9, 267, 372, 1564, 339, 347, 1050, 63, 1932, 63, 3352, 63, 3058, 8, 277, 12, 3233, 304, 267, 408, 14995, 282, 892, 2963, 13, 28228, 3233, 14, 398, 982, 314, 1177, 965, 2575, 2757, 8018, 12, 267, 12677, 314, 3233, 9939, 14, 267, 408, 267, 340, 291, 423, 374, 63, 16841, 26, 288, 3233, 8, 277, 9, 267, 587, 26, 288, 291, 423, 1932, 63, 3352, 63, 11948, 14, 740, 8, 3058, 9, 339, 347, 3795, 8, 277, 304, 267, 408, 5349, 7735, 334, 16990, 991, 4242, 9147, 9, 314, 1564, 402, 314, 1177, 14, 398, 982, 314, 1564, 965, 2575, 2757, 8018, 12, 642, 365, 282, 949, 13, 411, 14, 398, 1803, 314, 330, 16702, 1177, 1256, 14, 267, 408, 267, 9151, 275, 291, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 291, 14, 1317, 275, 291, 14, 16841, 63, 1317, 288, 367, 2963, 63, 3058, 315, 291, 423, 1932, 63, 3352, 63, 11948, 26, 355, 892, 18476, 275, 2963, 63, 3058, 8, 18476, 9, 355, 340, 892, 18476, 365, 440, 488, 26, 490, 9151, 275, 892, 18476, 267, 372, 9151, 339, 768, 1829, 272, 347, 365, 63, 16841, 8, 277, 304, 267, 372, 291, 423, 374, 63, 16841, 339, 347, 636, 1661, 721, 277, 304, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 8, 355, 283, 1918, 1177, 1564, 1471, 506, 8018, 2544, 652, 883, 506, 27924, 1806, 3530, 288, 776, 267, 372, 1613, 8, 3184, 31036, 12, 291, 2843, 1661, 4533, 339, 768, 1829, 272, 347, 1564, 8, 277, 304, 267, 340, 440, 291, 423, 374, 63, 16841, 26, 288, 746, 6646, 1763, 5349, 2995, 547, 8, 355, 283, 1918, 1177, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
muntasirsyed/intellij-community
python/lib/Lib/site-packages/django/contrib/localflavor/es/es_provinces.py
436
1482
# -*- coding: utf-8 -*- from django.utils.translation import ugettext_lazy as _ PROVINCE_CHOICES = ( ('01', _('Arava')), ('02', _('Albacete')), ('03', _('Alacant')), ('04', _('Almeria')), ('05', _('Avila')), ('06', _('Badajoz')), ('07', _('Illes Balears')), ('08', _('Barcelona')), ('09', _('Burgos')), ('10', _('Caceres')), ('11', _('Cadiz')), ('12', _('Castello')), ('13', _('Ciudad Real')), ('14', _('Cordoba')), ('15', _('A Coruna')), ('16', _('Cuenca')), ('17', _('Girona')), ('18', _('Granada')), ('19', _('Guadalajara')), ('20', _('Guipuzkoa')), ('21', _('Huelva')), ('22', _('Huesca')), ('23', _('Jaen')), ('24', _('Leon')), ('25', _('Lleida')), ('26', _('La Rioja')), ('27', _('Lugo')), ('28', _('Madrid')), ('29', _('Malaga')), ('30', _('Murcia')), ('31', _('Navarre')), ('32', _('Ourense')), ('33', _('Asturias')), ('34', _('Palencia')), ('35', _('Las Palmas')), ('36', _('Pontevedra')), ('37', _('Salamanca')), ('38', _('Santa Cruz de Tenerife')), ('39', _('Cantabria')), ('40', _('Segovia')), ('41', _('Seville')), ('42', _('Soria')), ('43', _('Tarragona')), ('44', _('Teruel')), ('45', _('Toledo')), ('46', _('Valencia')), ('47', _('Valladolid')), ('48', _('Bizkaia')), ('49', _('Zamora')), ('50', _('Zaragoza')), ('51', _('Ceuta')), ('52', _('Melilla')), )
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 614, 297, 4018, 33, 345, 3042, 3855, 272, 661, 996, 297, 4018, 2439, 2470, 301, 266, 3855, 272, 661, 1644, 297, 4018, 33, 416, 67, 867, 3855, 272, 661, 966, 297, 4018, 2439, 278, 23714, 3855, 272, 661, 1717, 297, 4018, 6651, 25330, 3855, 272, 661, 1690, 297, 4018, 5725, 65, 743, 90, 3855, 272, 661, 1780, 297, 4018, 27965, 2978, 699, 1895, 4291, 3855, 272, 661, 2036, 297, 4018, 5281, 301, 5298, 65, 3855, 272, 661, 1643, 297, 4018, 34, 17629, 736, 3855, 272, 661, 709, 297, 4018, 3630, 301, 470, 3855, 272, 661, 845, 297, 4018, 3630, 328, 90, 3855, 272, 661, 713, 297, 4018, 35, 9209, 76, 320, 3855, 272, 661, 969, 297, 4018, 28665, 1181, 350, 14849, 3855, 272, 661, 1079, 297, 4018, 8380, 1117, 2470, 3855, 272, 661, 1046, 297, 4018, 33, 7499, 31627, 3855, 272, 661, 975, 297, 4018, 35, 85, 287, 696, 3855, 272, 661, 1196, 297, 4018, 39, 26789, 65, 3855, 272, 661, 1085, 297, 4018, 39, 1312, 10641, 3855, 272, 661, 1167, 297, 4018, 39, 8346, 14774, 7338, 65, 3855, 272, 661, 1165, 297, 4018, 11548, 711, 9494, 7697, 65, 3855, 272, 661, 2025, 297, 4018, 40, 13086, 3042, 3855, 272, 661, 1081, 297, 4018, 40, 310, 7101, 3855, 272, 661, 1789, 297, 4018, 42, 65, 287, 3855, 272, 661, 1194, 297, 4018, 2553, 265, 3855, 272, 661, 821, 297, 4018, 44, 274, 29132, 3855, 272, 661, 1479, 297, 4018, 7833, 820, 2308, 3387, 3855, 272, 661, 1465, 297, 4018, 44, 1518, 79, 3855, 272, 661, 1651, 297, 4018, 45, 350, 1677, 3855, 272, 661, 1398, 297, 4018, 31147, 643, 65, 3855, 272, 661, 1216, 297, 4018, 45, 300, 16521, 3855, 272, 661, 2192, 297, 4018, 31488, 285, 264, 3855, 272, 661, 708, 297, 4018, 47, 608, 19315, 3855, 272, 661, 1153, 297, 4018, 33, 270, 300, 2241, 3855, 272, 661, 1082, 297, 4018, 4232, 552, 16521, 3855, 272, 661, 1276, 297, 4018, 44, 305, 510, 279, 5892, 3855, 272, 661, 1344, 297, 4018, 48, 265, 266, 1354, 345, 3855, 272, 661, 1401, 297, 4018, 27177, 455, 290, 696, 3855, 272, 661, 1703, 297, 4018, 23906, 502, 445, 6558, 90, 477, 377, 727, 16839, 3855, 272, 661, 1355, 297, 4018, 35, 867, 371, 23714, 3855, 272, 661, 2167, 297, 4018, 1513, 1939, 12897, 3855, 272, 661, 2953, 297, 4018, 1513, 86, 17142, 3855, 272, 661, 2260, 297, 4018, 51, 269, 4674, 3855, 272, 661, 2824, 297, 4018, 24818, 2527, 265, 65, 3855, 272, 661, 1602, 297, 4018, 8600, 13086, 3855, 272, 661, 2322, 297, 4018, 1378, 274, 1117, 3855, 272, 661, 2466, 297, 4018, 54, 20634, 16521, 3855, 272, 661, 2417, 297, 4018, 54, 452, 5129, 7401, 3855, 272, 661, 2006, 297, 4018, 34, 565, 7351, 4674, 3855, 272, 661, 1887, 297, 4018, 58, 455, 11131, 3855, 272, 661, 1400, 297, 4018, 58, 285, 14315, 8076, 3855, 272, 661, 2869, 297, 4018, 24417, 337, 65, 3855, 272, 661, 2528, 297, 4018, 1352, 317, 76, 416, 3855, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 1639, 14, 1208, 14, 6893, 492, 10366, 63, 6395, 465, 485, 199, 199, 2514, 54, 568, 2089, 63, 16236, 275, 334, 272, 661, 614, 297, 4018, 33, 345, 3042, 3855, 272, 661, 996, 297, 4018, 2439, 2470, 301, 266, 3855, 272, 661, 1644, 297, 4018, 33, 416, 67, 867, 3855, 272, 661, 966, 297, 4018, 2439, 278, 23714, 3855, 272, 661, 1717, 297, 4018, 6651, 25330, 3855, 272, 661, 1690, 297, 4018, 5725, 65, 743, 90, 3855, 272, 661, 1780, 297, 4018, 27965, 2978, 699, 1895, 4291, 3855, 272, 661, 2036, 297, 4018, 5281, 301, 5298, 65, 3855, 272, 661, 1643, 297, 4018, 34, 17629, 736, 3855, 272, 661, 709, 297, 4018, 3630, 301, 470, 3855, 272, 661, 845, 297, 4018, 3630, 328, 90, 3855, 272, 661, 713, 297, 4018, 35, 9209, 76, 320, 3855, 272, 661, 969, 297, 4018, 28665, 1181, 350, 14849, 3855, 272, 661, 1079, 297, 4018, 8380, 1117, 2470, 3855, 272, 661, 1046, 297, 4018, 33, 7499, 31627, 3855, 272, 661, 975, 297, 4018, 35, 85, 287, 696, 3855, 272, 661, 1196, 297, 4018, 39, 26789, 65, 3855, 272, 661, 1085, 297, 4018, 39, 1312, 10641, 3855, 272, 661, 1167, 297, 4018, 39, 8346, 14774, 7338, 65, 3855, 272, 661, 1165, 297, 4018, 11548, 711, 9494, 7697, 65, 3855, 272, 661, 2025, 297, 4018, 40, 13086, 3042, 3855, 272, 661, 1081, 297, 4018, 40, 310, 7101, 3855, 272, 661, 1789, 297, 4018, 42, 65, 287, 3855, 272, 661, 1194, 297, 4018, 2553, 265, 3855, 272, 661, 821, 297, 4018, 44, 274, 29132, 3855, 272, 661, 1479, 297, 4018, 7833, 820, 2308, 3387, 3855, 272, 661, 1465, 297, 4018, 44, 1518, 79, 3855, 272, 661, 1651, 297, 4018, 45, 350, 1677, 3855, 272, 661, 1398, 297, 4018, 31147, 643, 65, 3855, 272, 661, 1216, 297, 4018, 45, 300, 16521, 3855, 272, 661, 2192, 297, 4018, 31488, 285, 264, 3855, 272, 661, 708, 297, 4018, 47, 608, 19315, 3855, 272, 661, 1153, 297, 4018, 33, 270, 300, 2241, 3855, 272, 661, 1082, 297, 4018, 4232, 552, 16521, 3855, 272, 661, 1276, 297, 4018, 44, 305, 510, 279, 5892, 3855, 272, 661, 1344, 297, 4018, 48, 265, 266, 1354, 345, 3855, 272, 661, 1401, 297, 4018, 27177, 455, 290, 696, 3855, 272, 661, 1703, 297, 4018, 23906, 502, 445, 6558, 90, 477, 377, 727, 16839, 3855, 272, 661, 1355, 297, 4018, 35, 867, 371, 23714, 3855, 272, 661, 2167, 297, 4018, 1513, 1939, 12897, 3855, 272, 661, 2953, 297, 4018, 1513, 86, 17142, 3855, 272, 661, 2260, 297, 4018, 51, 269, 4674, 3855, 272, 661, 2824, 297, 4018, 24818, 2527, 265, 65, 3855, 272, 661, 1602, 297, 4018, 8600, 13086, 3855, 272, 661, 2322, 297, 4018, 1378, 274, 1117, 3855, 272, 661, 2466, 297, 4018, 54, 20634, 16521, 3855, 272, 661, 2417, 297, 4018, 54, 452, 5129, 7401, 3855, 272, 661, 2006, 297, 4018, 34, 565, 7351, 4674, 3855, 272, 661, 1887, 297, 4018, 58, 455, 11131, 3855, 272, 661, 1400, 297, 4018, 58, 285, 14315, 8076, 3855, 272, 661, 2869, 297, 4018, 24417, 337, 65, 3855, 272, 661, 2528, 297, 4018, 1352, 317, 76, 416, 3855, 199, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
coldeasy/python-driver
example_mapper.py
1
4657
#!/usr/bin/env python # Copyright 2013-2017 DataStax, 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. # silence warnings just for demo -- applications would typically not do this import os os.environ['CQLENG_ALLOW_SCHEMA_MANAGEMENT'] = '1' import logging log = logging.getLogger() log.setLevel('INFO') handler = logging.StreamHandler() handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")) log.addHandler(handler) from uuid import uuid4 from cassandra.cqlengine import columns from cassandra.cqlengine import connection from cassandra.cqlengine import management from cassandra.cqlengine import ValidationError from cassandra.cqlengine.models import Model from cassandra.cqlengine.query import BatchQuery, LWTException KEYSPACE = "testkeyspace" class FamilyMembers(Model): __keyspace__ = KEYSPACE id = columns.UUID(primary_key=True, default=uuid4) surname = columns.Text(primary_key=True) name = columns.Text(primary_key=True) birth_year = columns.Integer() sex = columns.Text(min_length=1, max_length=1) def validate(self): super(FamilyMembers, self).validate() if self.sex and self.sex not in 'mf': raise ValidationError("FamilyMember.sex must be one of ['m', 'f']") if self.birth_year and self.sex == 'f': raise ValidationError("FamilyMember.birth_year is set, and 'a lady never tells'") def main(): connection.default() # Management functions would normally be used in development, and possibly for deployments. # They are typically not part of a core application. log.info("### creating keyspace...") management.create_keyspace_simple(KEYSPACE, 1) log.info("### syncing model...") management.sync_table(FamilyMembers) # default uuid is assigned simmons = FamilyMembers.create(surname='Simmons', name='Gene', birth_year=1949, sex='m') # add members to his family later FamilyMembers.create(id=simmons.id, surname='Simmons', name='Nick', birth_year=1989, sex='m') sophie = FamilyMembers.create(id=simmons.id, surname='Simmons', name='Sophie', sex='f') nick = FamilyMembers.objects(id=simmons.id, surname='Simmons', name='Nick') try: nick.iff(birth_year=1988).update(birth_year=1989) except LWTException: print "precondition not met" log.info("### setting individual column to NULL by updating it to None") nick.update(birth_year=None) # showing validation try: FamilyMembers.create(id=simmons.id, surname='Tweed', name='Shannon', birth_year=1957, sex='f') except ValidationError: log.exception('INTENTIONAL VALIDATION EXCEPTION; Failed creating instance:') FamilyMembers.create(id=simmons.id, surname='Tweed', name='Shannon', sex='f') log.info("### add multiple as part of a batch") # If creating many at one time, can use a batch to minimize round-trips hogan_id = uuid4() with BatchQuery() as b: FamilyMembers.batch(b).create(id=hogan_id, surname='Hogan', name='Hulk', sex='m') FamilyMembers.batch(b).create(id=hogan_id, surname='Hogan', name='Linda', sex='f') FamilyMembers.batch(b).create(id=hogan_id, surname='Hogan', name='Nick', sex='m') FamilyMembers.batch(b).create(id=hogan_id, surname='Hogan', name='Brooke', sex='f') log.info("### All members") for m in FamilyMembers.all(): print m, m.birth_year, m.sex log.info("### Select by partition key") for m in FamilyMembers.objects(id=simmons.id): print m, m.birth_year, m.sex log.info("### Constrain on clustering key") for m in FamilyMembers.objects(id=simmons.id, surname=simmons.surname): print m, m.birth_year, m.sex log.info("### Constrain on clustering key") kids = FamilyMembers.objects(id=simmons.id, surname=simmons.surname, name__in=['Nick', 'Sophie']) log.info("### Delete a record") FamilyMembers(id=hogan_id, surname='Hogan', name='Linda').delete() for m in FamilyMembers.objects(id=hogan_id): print m, m.birth_year, m.sex management.drop_keyspace(KEYSPACE) if __name__ == "__main__": main()
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6171, 13, 10680, 3918, 3391, 88, 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, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 9767, 21225, 3598, 2951, 367, 14779, 1553, 13103, 3955, 13609, 440, 886, 642, 199, 646, 747, 199, 736, 14, 2314, 459, 35, 2940, 742, 39, 63, 12231, 63, 10926, 63, 20600, 9591, 418, 275, 283, 17, 7, 199, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 342, 199, 793, 14, 13548, 360, 4531, 358, 199, 2232, 275, 2050, 14, 22482, 342, 199, 2232, 14, 26076, 8, 4806, 14, 7772, 480, 2840, 18331, 9, 83, 359, 2840, 20056, 9, 83, 61, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 2237, 199, 793, 14, 18826, 8, 2232, 9, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 4362, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 1950, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 10041, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 8505, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 992, 492, 5822, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 1131, 492, 17206, 3227, 12, 491, 21283, 1726, 199, 199, 3078, 11658, 275, 298, 396, 16365, 2, 421, 199, 533, 481, 4632, 23056, 8, 1685, 304, 272, 636, 16365, 363, 275, 9301, 11658, 272, 1305, 275, 4362, 14, 8757, 8, 3327, 63, 498, 29, 549, 12, 849, 29, 2580, 20, 9, 272, 308, 21121, 275, 4362, 14, 1872, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 4362, 14, 1872, 8, 3327, 63, 498, 29, 549, 9, 272, 21036, 63, 3403, 275, 4362, 14, 2674, 342, 272, 542, 88, 275, 4362, 14, 1872, 8, 827, 63, 1267, 29, 17, 12, 1390, 63, 1267, 29, 17, 9, 339, 347, 4107, 8, 277, 304, 267, 1613, 8, 16345, 23056, 12, 291, 680, 3502, 342, 267, 340, 291, 14, 20160, 436, 291, 14, 20160, 440, 315, 283, 11821, 356, 288, 746, 8505, 480, 16345, 7021, 14, 20160, 1471, 506, 1373, 402, 788, 77, 297, 283, 70, 32266, 398, 340, 291, 14, 10907, 63, 3403, 436, 291, 14, 20160, 508, 283, 70, 356, 288, 746, 8505, 480, 16345, 7021, 14, 10907, 63, 3403, 365, 663, 12, 436, 283, 65, 634, 350, 89, 7078, 26544, 9859, 421, 199, 318, 2446, 837, 272, 1950, 14, 885, 342, 339, 327, 8259, 3423, 3955, 12252, 506, 1202, 315, 16367, 12, 436, 12570, 367, 12287, 1470, 14, 272, 327, 9322, 787, 13609, 440, 1777, 402, 282, 6170, 4223, 14, 272, 943, 14, 815, 480, 5680, 6425, 27710, 12594, 272, 10041, 14, 981, 63, 16365, 63, 4129, 8, 3078, 11658, 12, 413, 9, 272, 943, 14, 815, 480, 5680, 7604, 316, 1402, 12594, 272, 10041, 14, 5186, 63, 1224, 8, 16345, 23056, 9, 339, 327, 849, 5377, 365, 7943, 272, 13877, 596, 4654, 275, 481, 4632, 23056, 14, 981, 8, 30959, 534, 18934, 596, 4654, 297, 536, 534, 39, 6349, 297, 21036, 63, 3403, 29, 1167, 1887, 12, 542, 88, 534, 77, 358, 339, 327, 1050, 7556, 370, 17049, 9614, 2945, 272, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 32172, 297, 21036, 63, 3403, 29, 1167, 1407, 12, 542, 88, 534, 77, 358, 272, 308, 24316, 1873, 275, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 51, 24316, 1873, 297, 542, 88, 534, 70, 358, 339, 14900, 275, 481, 4632, 23056, 14, 1462, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 32172, 358, 272, 862, 26, 267, 14900, 14, 15126, 8, 10907, 63, 3403, 29, 29313, 680, 873, 8, 10907, 63, 3403, 29, 1167, 1407, 9, 272, 871, 491, 21283, 1726, 26, 267, 870, 298, 657, 5394, 440, 7647, 2, 339, 943, 14, 815, 480, 5680, 4260, 8212, 2763, 370, 5962, 701, 12928, 652, 370, 488, 531, 272, 14900, 14, 873, 8, 10907, 63, 3403, 29, 403, 9, 339, 327, 21207, 6411, 272, 862, 26, 267, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 52, 1129, 379, 297, 536, 534, 2662, 1189, 265, 297, 21036, 63, 3403, 29, 1167, 1641, 12, 542, 88, 534, 70, 358, 272, 871, 8505, 26, 267, 943, 14, 1971, 360, 2919, 1309, 21518, 22049, 2594, 3651, 7177, 1075, 27, 16277, 6425, 1256, 10993, 267, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 52, 1129, 379, 297, 536, 534, 2662, 1189, 265, 297, 542, 88, 534, 70, 358, 339, 943, 14, 815, 480, 5680, 1050, 3663, 465, 1777, 402, 282, 3522, 531, 272, 327, 982, 6425, 5002, 737, 1373, 900, 12, 883, 675, 282, 3522, 370, 24720, 6168, 13, 599, 1190, 272, 394, 974, 290, 63, 344, 275, 5377, 20, 342, 272, 543, 17206, 3227, 342, 465, 330, 26, 267, 481, 4632, 23056, 14, 2912, 8, 66, 680, 981, 8, 344, 29, 526, 24975, 63, 344, 12, 308, 21121, 534, 40, 974, 290, 297, 536, 534, 40, 6368, 297, 542, 88, 534, 77, 358, 267, 481, 4632, 23056, 14, 2912, 8, 66, 680, 981, 8, 344, 29, 526, 24975, 63, 344, 12, 308, 21121, 534, 40, 974, 290, 297 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 6171, 13, 10680, 3918, 3391, 88, 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, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 3, 9767, 21225, 3598, 2951, 367, 14779, 1553, 13103, 3955, 13609, 440, 886, 642, 199, 646, 747, 199, 736, 14, 2314, 459, 35, 2940, 742, 39, 63, 12231, 63, 10926, 63, 20600, 9591, 418, 275, 283, 17, 7, 199, 199, 646, 2050, 199, 199, 793, 275, 2050, 14, 5572, 342, 199, 793, 14, 13548, 360, 4531, 358, 199, 2232, 275, 2050, 14, 22482, 342, 199, 2232, 14, 26076, 8, 4806, 14, 7772, 480, 2840, 18331, 9, 83, 359, 2840, 20056, 9, 83, 61, 2818, 354, 9, 83, 26, 2818, 1188, 9, 83, 2237, 199, 793, 14, 18826, 8, 2232, 9, 199, 199, 504, 5377, 492, 5377, 20, 199, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 4362, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 1950, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 10041, 199, 504, 286, 22388, 14, 26853, 552, 2598, 492, 8505, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 992, 492, 5822, 199, 504, 286, 22388, 14, 26853, 552, 2598, 14, 1131, 492, 17206, 3227, 12, 491, 21283, 1726, 199, 199, 3078, 11658, 275, 298, 396, 16365, 2, 421, 199, 533, 481, 4632, 23056, 8, 1685, 304, 272, 636, 16365, 363, 275, 9301, 11658, 272, 1305, 275, 4362, 14, 8757, 8, 3327, 63, 498, 29, 549, 12, 849, 29, 2580, 20, 9, 272, 308, 21121, 275, 4362, 14, 1872, 8, 3327, 63, 498, 29, 549, 9, 272, 536, 275, 4362, 14, 1872, 8, 3327, 63, 498, 29, 549, 9, 272, 21036, 63, 3403, 275, 4362, 14, 2674, 342, 272, 542, 88, 275, 4362, 14, 1872, 8, 827, 63, 1267, 29, 17, 12, 1390, 63, 1267, 29, 17, 9, 339, 347, 4107, 8, 277, 304, 267, 1613, 8, 16345, 23056, 12, 291, 680, 3502, 342, 267, 340, 291, 14, 20160, 436, 291, 14, 20160, 440, 315, 283, 11821, 356, 288, 746, 8505, 480, 16345, 7021, 14, 20160, 1471, 506, 1373, 402, 788, 77, 297, 283, 70, 32266, 398, 340, 291, 14, 10907, 63, 3403, 436, 291, 14, 20160, 508, 283, 70, 356, 288, 746, 8505, 480, 16345, 7021, 14, 10907, 63, 3403, 365, 663, 12, 436, 283, 65, 634, 350, 89, 7078, 26544, 9859, 421, 199, 318, 2446, 837, 272, 1950, 14, 885, 342, 339, 327, 8259, 3423, 3955, 12252, 506, 1202, 315, 16367, 12, 436, 12570, 367, 12287, 1470, 14, 272, 327, 9322, 787, 13609, 440, 1777, 402, 282, 6170, 4223, 14, 272, 943, 14, 815, 480, 5680, 6425, 27710, 12594, 272, 10041, 14, 981, 63, 16365, 63, 4129, 8, 3078, 11658, 12, 413, 9, 272, 943, 14, 815, 480, 5680, 7604, 316, 1402, 12594, 272, 10041, 14, 5186, 63, 1224, 8, 16345, 23056, 9, 339, 327, 849, 5377, 365, 7943, 272, 13877, 596, 4654, 275, 481, 4632, 23056, 14, 981, 8, 30959, 534, 18934, 596, 4654, 297, 536, 534, 39, 6349, 297, 21036, 63, 3403, 29, 1167, 1887, 12, 542, 88, 534, 77, 358, 339, 327, 1050, 7556, 370, 17049, 9614, 2945, 272, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 32172, 297, 21036, 63, 3403, 29, 1167, 1407, 12, 542, 88, 534, 77, 358, 272, 308, 24316, 1873, 275, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 51, 24316, 1873, 297, 542, 88, 534, 70, 358, 339, 14900, 275, 481, 4632, 23056, 14, 1462, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 18934, 596, 4654, 297, 536, 534, 32172, 358, 272, 862, 26, 267, 14900, 14, 15126, 8, 10907, 63, 3403, 29, 29313, 680, 873, 8, 10907, 63, 3403, 29, 1167, 1407, 9, 272, 871, 491, 21283, 1726, 26, 267, 870, 298, 657, 5394, 440, 7647, 2, 339, 943, 14, 815, 480, 5680, 4260, 8212, 2763, 370, 5962, 701, 12928, 652, 370, 488, 531, 272, 14900, 14, 873, 8, 10907, 63, 3403, 29, 403, 9, 339, 327, 21207, 6411, 272, 862, 26, 267, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 52, 1129, 379, 297, 536, 534, 2662, 1189, 265, 297, 21036, 63, 3403, 29, 1167, 1641, 12, 542, 88, 534, 70, 358, 272, 871, 8505, 26, 267, 943, 14, 1971, 360, 2919, 1309, 21518, 22049, 2594, 3651, 7177, 1075, 27, 16277, 6425, 1256, 10993, 267, 481, 4632, 23056, 14, 981, 8, 344, 29, 338, 596, 4654, 14, 344, 12, 308, 21121, 534, 52, 1129, 379, 297, 536, 534, 2662, 1189, 265, 297, 542, 88, 534, 70, 358, 339, 943, 14, 815, 480, 5680, 1050, 3663, 465, 1777, 402, 282, 3522, 531, 272, 327, 982, 6425, 5002, 737, 1373, 900, 12, 883, 675, 282, 3522, 370, 24720, 6168, 13, 599, 1190, 272, 394, 974, 290, 63, 344, 275, 5377, 20, 342, 272, 543, 17206, 3227, 342, 465, 330, 26, 267, 481, 4632, 23056, 14, 2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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
atsushieno/cerbero
test/test_cerbero_build_filesprovider.py
4
4885
# cerbero - a multi-platform build system for Open Source software # Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. import shutil import unittest import tempfile from cerbero.build import filesprovider from cerbero.config import Platform, License from test.test_build_common import add_files from test.test_common import DummyConfig class Config(DummyConfig): def __init__(self, tmp, platform): self.prefix = tmp self.target_platform = platform class FilesProvider(filesprovider.FilesProvider): files_misc = ['README', 'libexec/gstreamer-0.10/pluginsloader%(bext)s'] files_libs = ['libgstreamer-0.10'] files_bins = ['gst-launch'] files_devel = ['include/gstreamer.h'] licenses_devel = [License.LGPL] platform_files_bins = { Platform.WINDOWS: ['windows'], Platform.LINUX: ['linux']} platform_files_libs = { Platform.WINDOWS: ['libgstreamer-win32'], Platform.LINUX: ['libgstreamer-x11']} class PackageTest(unittest.TestCase): def setUp(self): self.tmp = tempfile.mkdtemp() win32config = Config(self.tmp, Platform.WINDOWS) linuxconfig = Config(self.tmp, Platform.LINUX) self.win32recipe = FilesProvider(win32config) self.linuxrecipe = FilesProvider(linuxconfig) self.winbin = ['bin/gst-launch.exe', 'bin/windows.exe'] self.linuxbin = ['bin/gst-launch', 'bin/linux'] self.winlib = ['bin/libgstreamer-0.10.dll', 'bin/libgstreamer-win32.dll'] self.linuxlib = ['lib/libgstreamer-0.10.so.1', 'lib/libgstreamer-x11.so.1'] self.winmisc = ['README', 'libexec/gstreamer-0.10/pluginsloader.exe'] self.linuxmisc = ['README', 'libexec/gstreamer-0.10/pluginsloader'] devfiles = ['include/gstreamer.h', 'lib/libgstreamer-0.10.a', 'lib/libgstreamer-0.10.la'] self.windevfiles = devfiles + ['lib/libgstreamer-win32.a', 'lib/libgstreamer-win32.la', 'lib/libgstreamer-win32.dll.a', 'lib/libgstreamer-win32.def', 'lib/gstreamer-win32.lib', 'lib/libgstreamer-0.10.dll.a', 'lib/libgstreamer-0.10.def', 'lib/gstreamer-0.10.lib'] self.lindevfiles = devfiles + ['lib/libgstreamer-0.10.so', 'lib/libgstreamer-x11.a', 'lib/libgstreamer-x11.la', 'lib/libgstreamer-x11.so'] def tearDown(self): shutil.rmtree(self.tmp) def testFilesCategories(self): self.assertEqual(sorted(['bins', 'libs', 'misc', 'devel']), self.win32recipe._files_categories()) def testListBinaries(self): self.assertEqual(self.win32recipe.files_list_by_category('bins'), sorted(self.winbin)) self.assertEqual(self.linuxrecipe.files_list_by_category('bins'), sorted(self.linuxbin)) def testListLibraries(self): add_files(self.tmp) self.assertEqual(self.win32recipe.files_list_by_category('libs'), sorted(self.winlib)) self.assertEqual(self.linuxrecipe.files_list_by_category('libs'), sorted(self.linuxlib)) def testDevelFiles(self): add_files(self.tmp) self.assertEqual(self.win32recipe.devel_files_list(), sorted(self.windevfiles)) self.assertEqual(self.linuxrecipe.devel_files_list(), sorted(self.lindevfiles)) def testDistFiles(self): win32files = self.winlib + self.winbin + self.winmisc linuxfiles = self.linuxlib + self.linuxbin + self.linuxmisc add_files(self.tmp) self.assertEqual(self.win32recipe.dist_files_list(), sorted(win32files)) self.assertEqual(self.linuxrecipe.dist_files_list(), sorted(linuxfiles)) def testGetAllFiles(self): win32files = self.winlib + self.winbin + self.winmisc + self.windevfiles linuxfiles = self.linuxlib + self.linuxbin + self.linuxmisc + self.lindevfiles add_files(self.tmp) self.assertEqual(self.win32recipe.files_list(), sorted(win32files)) self.assertEqual(self.linuxrecipe.files_list(), sorted(linuxfiles))
lgpl-2.1
[ 3, 3361, 605, 79, 446, 282, 3510, 13, 3246, 1900, 2656, 367, 3232, 5800, 2032, 199, 3, 1898, 334, 35, 9, 6029, 6061, 265, 73, 603, 269, 7098, 437, 2019, 431, 89, 665, 89, 4452, 85, 11552, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 199, 3, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 646, 5145, 199, 646, 2882, 199, 646, 5549, 199, 199, 504, 3361, 605, 79, 14, 1506, 492, 1584, 3780, 199, 504, 3361, 605, 79, 14, 888, 492, 16078, 12, 844, 199, 504, 511, 14, 396, 63, 1506, 63, 2330, 492, 1050, 63, 1725, 199, 504, 511, 14, 396, 63, 2330, 492, 9762, 2028, 421, 199, 533, 4094, 8, 11324, 2028, 304, 339, 347, 636, 826, 721, 277, 12, 3529, 12, 4298, 304, 267, 291, 14, 1861, 275, 3529, 267, 291, 14, 1375, 63, 3246, 275, 4298, 421, 199, 533, 16920, 6663, 8, 1725, 3780, 14, 5535, 6663, 304, 339, 1584, 63, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 2840, 66, 832, 9, 83, 418, 272, 1584, 63, 8450, 275, 788, 773, 23908, 24362, 13, 16, 14, 709, 418, 272, 1584, 63, 11329, 275, 788, 23908, 13, 9850, 418, 272, 1584, 63, 27870, 275, 788, 2613, 15, 23908, 24362, 14, 72, 418, 272, 12378, 63, 27870, 275, 359, 3761, 14, 44, 12006, 61, 272, 4298, 63, 1725, 63, 11329, 275, 469, 288, 16078, 14, 20509, 26, 788, 8258, 995, 288, 16078, 14, 26030, 26, 788, 5135, 12074, 272, 4298, 63, 1725, 63, 8450, 275, 469, 288, 16078, 14, 20509, 26, 788, 773, 23908, 24362, 13, 2676, 708, 995, 288, 16078, 14, 26030, 26, 788, 773, 23908, 24362, 13, 88, 845, 12074, 421, 199, 533, 15665, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2791, 275, 5549, 14, 11983, 342, 267, 4747, 708, 888, 275, 4094, 8, 277, 14, 2791, 12, 16078, 14, 20509, 9, 267, 18369, 888, 275, 4094, 8, 277, 14, 2791, 12, 16078, 14, 26030, 9, 267, 291, 14, 2676, 708, 13191, 275, 16920, 6663, 8, 2676, 708, 888, 9, 267, 291, 14, 5135, 13191, 275, 16920, 6663, 8, 5135, 888, 9, 398, 291, 14, 2676, 1393, 275, 788, 1393, 15, 23908, 13, 9850, 14, 5803, 297, 283, 1393, 15, 8258, 14, 5803, 418, 267, 291, 14, 5135, 1393, 275, 788, 1393, 15, 23908, 13, 9850, 297, 283, 1393, 15, 5135, 418, 267, 291, 14, 2676, 773, 275, 788, 1393, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 9259, 297, 283, 1393, 15, 773, 23908, 24362, 13, 2676, 708, 14, 9259, 418, 267, 291, 14, 5135, 773, 275, 788, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 1152, 14, 17, 297, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 1152, 14, 17, 418, 267, 291, 14, 2676, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 14, 5803, 418, 267, 291, 14, 5135, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 418, 267, 4866, 1725, 275, 788, 2613, 15, 23908, 24362, 14, 72, 297, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 65, 297, 490, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 416, 418, 398, 291, 14, 2676, 2374, 1725, 275, 4866, 1725, 435, 788, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 65, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 416, 297, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 9259, 14, 65, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 318, 297, 283, 773, 15, 23908, 24362, 13, 2676, 708, 14, 773, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 9259, 14, 65, 297, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 318, 297, 355, 283, 773, 15, 23908, 24362, 13, 16, 14, 709, 14, 773, 418, 267, 291, 14, 472, 2374, 1725, 275, 4866, 1725, 435, 788, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 1152, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 65, 297, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 416, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 1152, 418, 339, 347, 6766, 8, 277, 304, 267, 5145, 14, 9242, 8, 277, 14, 2791, 9, 339, 347, 511, 5535, 28731, 8, 277, 304, 267, 291, 14, 629, 8, 5917, 2941, 11329, 297, 283, 8450, 297, 283, 9923, 297, 283, 27870, 3815, 355, 291, 14, 2676, 708, 13191, 423, 1725, 63, 8906, 1012, 339, 347, 511, 1296, 13394, 3433, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 2676, 708, 13191, 14, 1725, 63, 513, 63, 991, 63, 3710, 360, 11329, 659, 355, 3355, 8, 277, 14, 2676, 1393, 430, 267, 291, 14, 629, 8, 277, 14, 5135, 13191, 14, 1725, 63, 513, 63, 991, 63, 3710, 360, 11329, 659, 355, 3355, 8, 277, 14, 5135, 1393, 430, 339, 347, 511, 1296, 23624, 8, 277, 304, 267, 1050, 63, 1725 ]
[ 3361, 605, 79, 446, 282, 3510, 13, 3246, 1900, 2656, 367, 3232, 5800, 2032, 199, 3, 1898, 334, 35, 9, 6029, 6061, 265, 73, 603, 269, 7098, 437, 2019, 431, 89, 665, 89, 4452, 85, 11552, 32, 6799, 14, 957, 30, 199, 3, 199, 3, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 1015, 499, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 11243, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 11243, 1696, 1684, 199, 3, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 199, 3, 2868, 2290, 2752, 12, 3277, 2020, 8155, 15630, 10902, 446, 14453, 13540, 12, 199, 3, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 646, 5145, 199, 646, 2882, 199, 646, 5549, 199, 199, 504, 3361, 605, 79, 14, 1506, 492, 1584, 3780, 199, 504, 3361, 605, 79, 14, 888, 492, 16078, 12, 844, 199, 504, 511, 14, 396, 63, 1506, 63, 2330, 492, 1050, 63, 1725, 199, 504, 511, 14, 396, 63, 2330, 492, 9762, 2028, 421, 199, 533, 4094, 8, 11324, 2028, 304, 339, 347, 636, 826, 721, 277, 12, 3529, 12, 4298, 304, 267, 291, 14, 1861, 275, 3529, 267, 291, 14, 1375, 63, 3246, 275, 4298, 421, 199, 533, 16920, 6663, 8, 1725, 3780, 14, 5535, 6663, 304, 339, 1584, 63, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 2840, 66, 832, 9, 83, 418, 272, 1584, 63, 8450, 275, 788, 773, 23908, 24362, 13, 16, 14, 709, 418, 272, 1584, 63, 11329, 275, 788, 23908, 13, 9850, 418, 272, 1584, 63, 27870, 275, 788, 2613, 15, 23908, 24362, 14, 72, 418, 272, 12378, 63, 27870, 275, 359, 3761, 14, 44, 12006, 61, 272, 4298, 63, 1725, 63, 11329, 275, 469, 288, 16078, 14, 20509, 26, 788, 8258, 995, 288, 16078, 14, 26030, 26, 788, 5135, 12074, 272, 4298, 63, 1725, 63, 8450, 275, 469, 288, 16078, 14, 20509, 26, 788, 773, 23908, 24362, 13, 2676, 708, 995, 288, 16078, 14, 26030, 26, 788, 773, 23908, 24362, 13, 88, 845, 12074, 421, 199, 533, 15665, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 267, 291, 14, 2791, 275, 5549, 14, 11983, 342, 267, 4747, 708, 888, 275, 4094, 8, 277, 14, 2791, 12, 16078, 14, 20509, 9, 267, 18369, 888, 275, 4094, 8, 277, 14, 2791, 12, 16078, 14, 26030, 9, 267, 291, 14, 2676, 708, 13191, 275, 16920, 6663, 8, 2676, 708, 888, 9, 267, 291, 14, 5135, 13191, 275, 16920, 6663, 8, 5135, 888, 9, 398, 291, 14, 2676, 1393, 275, 788, 1393, 15, 23908, 13, 9850, 14, 5803, 297, 283, 1393, 15, 8258, 14, 5803, 418, 267, 291, 14, 5135, 1393, 275, 788, 1393, 15, 23908, 13, 9850, 297, 283, 1393, 15, 5135, 418, 267, 291, 14, 2676, 773, 275, 788, 1393, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 9259, 297, 283, 1393, 15, 773, 23908, 24362, 13, 2676, 708, 14, 9259, 418, 267, 291, 14, 5135, 773, 275, 788, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 1152, 14, 17, 297, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 1152, 14, 17, 418, 267, 291, 14, 2676, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 14, 5803, 418, 267, 291, 14, 5135, 9923, 275, 788, 18195, 297, 283, 773, 1628, 15, 23908, 24362, 13, 16, 14, 709, 15, 5265, 3422, 418, 267, 4866, 1725, 275, 788, 2613, 15, 23908, 24362, 14, 72, 297, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 65, 297, 490, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 416, 418, 398, 291, 14, 2676, 2374, 1725, 275, 4866, 1725, 435, 788, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 65, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 416, 297, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 9259, 14, 65, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 2676, 708, 14, 318, 297, 283, 773, 15, 23908, 24362, 13, 2676, 708, 14, 773, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 9259, 14, 65, 297, 283, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 318, 297, 355, 283, 773, 15, 23908, 24362, 13, 16, 14, 709, 14, 773, 418, 267, 291, 14, 472, 2374, 1725, 275, 4866, 1725, 435, 788, 773, 15, 773, 23908, 24362, 13, 16, 14, 709, 14, 1152, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 65, 297, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 416, 297, 355, 283, 773, 15, 773, 23908, 24362, 13, 88, 845, 14, 1152, 418, 339, 347, 6766, 8, 277, 304, 267, 5145, 14, 9242, 8, 277, 14, 2791, 9, 339, 347, 511, 5535, 28731, 8, 277, 304, 267, 291, 14, 629, 8, 5917, 2941, 11329, 297, 283, 8450, 297, 283, 9923, 297, 283, 27870, 3815, 355, 291, 14, 2676, 708, 13191, 423, 1725, 63, 8906, 1012, 339, 347, 511, 1296, 13394, 3433, 8, 277, 304, 267, 291, 14, 629, 8, 277, 14, 2676, 708, 13191, 14, 1725, 63, 513, 63, 991, 63, 3710, 360, 11329, 659, 355, 3355, 8, 277, 14, 2676, 1393, 430, 267, 291, 14, 629, 8, 277, 14, 5135, 13191, 14, 1725, 63, 513, 63, 991, 63, 3710, 360, 11329, 659, 355, 3355, 8, 277, 14, 5135, 1393, 430, 339, 347, 511, 1296, 23624, 8, 277, 304, 267, 1050, 63, 1725, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
OpenTrons/opentrons_sdk
robot-server/robot_server/service/session/session_types/check_session.py
1
3703
from opentrons.calibration.check.session import CheckCalibrationSession from opentrons.calibration.check import models as calibration_models from opentrons.calibration.session import CalibrationException from robot_server.service.session import models from robot_server.service.session.command_execution import \ CommandQueue, StateMachineExecutor, Command, CompletedCommand from robot_server.service.session.configuration import SessionConfiguration from robot_server.service.session.session_types.base_session \ import BaseSession, SessionMetaData from robot_server.service.session.errors import SessionCreationException, \ CommandExecutionException class CheckSessionStateExecutor(StateMachineExecutor): async def execute(self, command: Command) -> CompletedCommand: try: return await super().execute(command) except CalibrationException as e: raise CommandExecutionException(e) class CheckSession(BaseSession): def __init__(self, configuration: SessionConfiguration, instance_meta: SessionMetaData, calibration_check: CheckCalibrationSession): super().__init__(configuration, instance_meta) self._calibration_check = calibration_check self._command_executor = CheckSessionStateExecutor( self._calibration_check ) self._command_queue = CommandQueue() @classmethod async def create(cls, configuration: SessionConfiguration, instance_meta: SessionMetaData) -> BaseSession: """Create an instance""" try: calibration_check = await CheckCalibrationSession.build( configuration.hardware ) except (AssertionError, CalibrationException) as e: raise SessionCreationException(str(e)) return cls( configuration=configuration, instance_meta=instance_meta, calibration_check=calibration_check) async def clean_up(self): await super().clean_up() await self._calibration_check.delete_session() def _get_response_details(self) -> models.SessionDetails: instruments = { str(k): calibration_models.AttachedPipette( model=v.model, name=v.name, tip_length=v.tip_length, mount=str(v.mount), has_tip=v.has_tip, rank=v.rank, tiprack_id=v.tiprack_id, serial=v.serial) for k, v in self._calibration_check.pipette_status().items() } labware = [ calibration_models.LabwareStatus( alternatives=data.alternatives, slot=data.slot, id=data.id, forMounts=[str(m) for m in data.forMounts], loadName=data.loadName, namespace=data.namespace, version=data.version) for data in self._calibration_check.labware_status.values() ] return calibration_models.CalibrationSessionStatus( instruments=instruments, currentStep=self._calibration_check.current_state_name, comparisonsByStep=self._calibration_check.get_comparisons_by_step(), # noqa: e501 labware=labware, ) @property def command_executor(self) -> StateMachineExecutor: return self._command_executor @property def command_queue(self) -> CommandQueue: return self._command_queue @property def session_type(self) -> models.SessionType: return models.SessionType.calibration_check
apache-2.0
[ 504, 1551, 454, 4654, 14, 25851, 14, 1074, 14, 1730, 492, 2670, 26015, 1754, 4434, 199, 504, 1551, 454, 4654, 14, 25851, 14, 1074, 492, 1709, 465, 25365, 63, 992, 199, 504, 1551, 454, 4654, 14, 25851, 14, 1730, 492, 8256, 1892, 1754, 1726, 199, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 492, 1709, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 1531, 63, 9416, 492, 971, 272, 5817, 3737, 12, 8511, 8412, 16752, 12, 5817, 12, 12515, 471, 3110, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 4758, 492, 8596, 5688, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 1730, 63, 1313, 14, 1095, 63, 1730, 971, 272, 492, 3523, 4434, 12, 8596, 25285, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 2550, 492, 8596, 13921, 1726, 12, 971, 272, 5817, 11310, 1726, 421, 199, 533, 2670, 4434, 2223, 16752, 8, 23535, 16752, 304, 339, 5316, 347, 5341, 8, 277, 12, 1414, 26, 5817, 9, 1035, 12515, 471, 3110, 26, 267, 862, 26, 288, 372, 5517, 1613, 1252, 2526, 8, 1531, 9, 267, 871, 8256, 1892, 1754, 1726, 465, 325, 26, 288, 746, 5817, 11310, 1726, 8, 69, 9, 421, 199, 533, 2670, 4434, 8, 1563, 4434, 304, 339, 347, 636, 826, 721, 277, 12, 326, 2897, 26, 8596, 5688, 12, 326, 1256, 63, 2024, 26, 8596, 25285, 12, 326, 25365, 63, 1074, 26, 2670, 26015, 1754, 4434, 304, 267, 1613, 11027, 826, 721, 4758, 12, 1256, 63, 2024, 9, 267, 291, 423, 25851, 63, 1074, 275, 25365, 63, 1074, 267, 291, 423, 1531, 63, 13471, 275, 2670, 4434, 2223, 16752, 8, 288, 291, 423, 25851, 63, 1074, 267, 776, 267, 291, 423, 1531, 63, 1825, 275, 5817, 3737, 342, 339, 768, 3744, 272, 5316, 347, 1218, 8, 1886, 12, 2151, 2897, 26, 8596, 5688, 12, 2151, 1256, 63, 2024, 26, 8596, 25285, 9, 1035, 3523, 4434, 26, 267, 408, 2499, 376, 1256, 624, 267, 862, 26, 288, 25365, 63, 1074, 275, 5517, 2670, 26015, 1754, 4434, 14, 1506, 8, 355, 2897, 14, 16529, 288, 776, 267, 871, 334, 14844, 12, 8256, 1892, 1754, 1726, 9, 465, 325, 26, 288, 746, 8596, 13921, 1726, 8, 495, 8, 69, 430, 398, 372, 843, 8, 288, 2897, 29, 4758, 12, 288, 1256, 63, 2024, 29, 842, 63, 2024, 12, 288, 25365, 63, 1074, 29, 25851, 63, 1074, 9, 339, 5316, 347, 3633, 63, 384, 8, 277, 304, 267, 5517, 1613, 1252, 3118, 63, 384, 342, 267, 5517, 291, 423, 25851, 63, 1074, 14, 1807, 63, 1730, 342, 339, 347, 485, 362, 63, 1310, 63, 5087, 8, 277, 9, 1035, 1709, 14, 4434, 11347, 26, 267, 14498, 83, 275, 469, 288, 620, 8, 75, 304, 25365, 63, 992, 14, 1271, 7159, 11867, 14586, 8, 355, 1402, 29, 86, 14, 1238, 12, 355, 536, 29, 86, 14, 354, 12, 355, 19201, 63, 1267, 29, 86, 14, 8996, 63, 1267, 12, 355, 10760, 29, 495, 8, 86, 14, 3956, 395, 355, 965, 63, 8996, 29, 86, 14, 1989, 63, 8996, 12, 355, 6915, 29, 86, 14, 4648, 12, 355, 19201, 8085, 63, 344, 29, 86, 14, 8996, 8085, 63, 344, 12, 355, 3012, 29, 86, 14, 2171, 9, 288, 367, 1022, 12, 373, 315, 291, 423, 25851, 63, 1074, 14, 4990, 14586, 63, 1205, 1252, 1744, 342, 267, 789, 267, 19888, 1068, 275, 359, 288, 25365, 63, 992, 14, 22511, 1068, 3694, 8, 355, 8679, 10661, 29, 576, 14, 27584, 12, 355, 9348, 29, 576, 14, 7998, 12, 355, 1305, 29, 576, 14, 344, 12, 355, 367, 24467, 83, 1524, 495, 8, 77, 9, 367, 333, 315, 666, 14, 509, 24467, 83, 467, 355, 2248, 985, 29, 576, 14, 912, 985, 12, 355, 3231, 29, 576, 14, 3251, 12, 355, 1015, 29, 576, 14, 1023, 9, 367, 666, 315, 288, 291, 423, 25851, 63, 1074, 14, 5561, 1068, 63, 1205, 14, 1459, 342, 267, 1622, 398, 372, 25365, 63, 992, 14, 26015, 1754, 4434, 3694, 8, 288, 14498, 83, 29, 13321, 83, 12, 288, 1453, 7801, 29, 277, 423, 25851, 63, 1074, 14, 1818, 63, 929, 63, 354, 12, 288, 20448, 2175, 7801, 29, 277, 423, 25851, 63, 1074, 14, 362, 63, 863, 15864, 63, 991, 63, 2926, 1062, 221, 327, 8151, 26, 325, 8216, 288, 19888, 1068, 29, 5561, 1068, 12, 267, 776, 339, 768, 1829, 272, 347, 1414, 63, 13471, 8, 277, 9, 1035, 8511, 8412, 16752, 26, 267, 372, 291, 423, 1531, 63, 13471, 339, 768, 1829, 272, 347, 1414, 63, 1825, 8, 277, 9, 1035, 5817, 3737, 26, 267, 372, 291, 423, 1531, 63, 1825, 339, 768, 1829, 272, 347, 2351, 63, 466, 8, 277, 9, 1035, 1709, 14, 4434, 804, 26, 267, 372, 1709, 14, 4434, 804, 14, 25851, 63, 1074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1551, 454, 4654, 14, 25851, 14, 1074, 14, 1730, 492, 2670, 26015, 1754, 4434, 199, 504, 1551, 454, 4654, 14, 25851, 14, 1074, 492, 1709, 465, 25365, 63, 992, 199, 504, 1551, 454, 4654, 14, 25851, 14, 1730, 492, 8256, 1892, 1754, 1726, 199, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 492, 1709, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 1531, 63, 9416, 492, 971, 272, 5817, 3737, 12, 8511, 8412, 16752, 12, 5817, 12, 12515, 471, 3110, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 4758, 492, 8596, 5688, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 1730, 63, 1313, 14, 1095, 63, 1730, 971, 272, 492, 3523, 4434, 12, 8596, 25285, 199, 504, 14544, 63, 1000, 14, 1364, 14, 1730, 14, 2550, 492, 8596, 13921, 1726, 12, 971, 272, 5817, 11310, 1726, 421, 199, 533, 2670, 4434, 2223, 16752, 8, 23535, 16752, 304, 339, 5316, 347, 5341, 8, 277, 12, 1414, 26, 5817, 9, 1035, 12515, 471, 3110, 26, 267, 862, 26, 288, 372, 5517, 1613, 1252, 2526, 8, 1531, 9, 267, 871, 8256, 1892, 1754, 1726, 465, 325, 26, 288, 746, 5817, 11310, 1726, 8, 69, 9, 421, 199, 533, 2670, 4434, 8, 1563, 4434, 304, 339, 347, 636, 826, 721, 277, 12, 326, 2897, 26, 8596, 5688, 12, 326, 1256, 63, 2024, 26, 8596, 25285, 12, 326, 25365, 63, 1074, 26, 2670, 26015, 1754, 4434, 304, 267, 1613, 11027, 826, 721, 4758, 12, 1256, 63, 2024, 9, 267, 291, 423, 25851, 63, 1074, 275, 25365, 63, 1074, 267, 291, 423, 1531, 63, 13471, 275, 2670, 4434, 2223, 16752, 8, 288, 291, 423, 25851, 63, 1074, 267, 776, 267, 291, 423, 1531, 63, 1825, 275, 5817, 3737, 342, 339, 768, 3744, 272, 5316, 347, 1218, 8, 1886, 12, 2151, 2897, 26, 8596, 5688, 12, 2151, 1256, 63, 2024, 26, 8596, 25285, 9, 1035, 3523, 4434, 26, 267, 408, 2499, 376, 1256, 624, 267, 862, 26, 288, 25365, 63, 1074, 275, 5517, 2670, 26015, 1754, 4434, 14, 1506, 8, 355, 2897, 14, 16529, 288, 776, 267, 871, 334, 14844, 12, 8256, 1892, 1754, 1726, 9, 465, 325, 26, 288, 746, 8596, 13921, 1726, 8, 495, 8, 69, 430, 398, 372, 843, 8, 288, 2897, 29, 4758, 12, 288, 1256, 63, 2024, 29, 842, 63, 2024, 12, 288, 25365, 63, 1074, 29, 25851, 63, 1074, 9, 339, 5316, 347, 3633, 63, 384, 8, 277, 304, 267, 5517, 1613, 1252, 3118, 63, 384, 342, 267, 5517, 291, 423, 25851, 63, 1074, 14, 1807, 63, 1730, 342, 339, 347, 485, 362, 63, 1310, 63, 5087, 8, 277, 9, 1035, 1709, 14, 4434, 11347, 26, 267, 14498, 83, 275, 469, 288, 620, 8, 75, 304, 25365, 63, 992, 14, 1271, 7159, 11867, 14586, 8, 355, 1402, 29, 86, 14, 1238, 12, 355, 536, 29, 86, 14, 354, 12, 355, 19201, 63, 1267, 29, 86, 14, 8996, 63, 1267, 12, 355, 10760, 29, 495, 8, 86, 14, 3956, 395, 355, 965, 63, 8996, 29, 86, 14, 1989, 63, 8996, 12, 355, 6915, 29, 86, 14, 4648, 12, 355, 19201, 8085, 63, 344, 29, 86, 14, 8996, 8085, 63, 344, 12, 355, 3012, 29, 86, 14, 2171, 9, 288, 367, 1022, 12, 373, 315, 291, 423, 25851, 63, 1074, 14, 4990, 14586, 63, 1205, 1252, 1744, 342, 267, 789, 267, 19888, 1068, 275, 359, 288, 25365, 63, 992, 14, 22511, 1068, 3694, 8, 355, 8679, 10661, 29, 576, 14, 27584, 12, 355, 9348, 29, 576, 14, 7998, 12, 355, 1305, 29, 576, 14, 344, 12, 355, 367, 24467, 83, 1524, 495, 8, 77, 9, 367, 333, 315, 666, 14, 509, 24467, 83, 467, 355, 2248, 985, 29, 576, 14, 912, 985, 12, 355, 3231, 29, 576, 14, 3251, 12, 355, 1015, 29, 576, 14, 1023, 9, 367, 666, 315, 288, 291, 423, 25851, 63, 1074, 14, 5561, 1068, 63, 1205, 14, 1459, 342, 267, 1622, 398, 372, 25365, 63, 992, 14, 26015, 1754, 4434, 3694, 8, 288, 14498, 83, 29, 13321, 83, 12, 288, 1453, 7801, 29, 277, 423, 25851, 63, 1074, 14, 1818, 63, 929, 63, 354, 12, 288, 20448, 2175, 7801, 29, 277, 423, 25851, 63, 1074, 14, 362, 63, 863, 15864, 63, 991, 63, 2926, 1062, 221, 327, 8151, 26, 325, 8216, 288, 19888, 1068, 29, 5561, 1068, 12, 267, 776, 339, 768, 1829, 272, 347, 1414, 63, 13471, 8, 277, 9, 1035, 8511, 8412, 16752, 26, 267, 372, 291, 423, 1531, 63, 13471, 339, 768, 1829, 272, 347, 1414, 63, 1825, 8, 277, 9, 1035, 5817, 3737, 26, 267, 372, 291, 423, 1531, 63, 1825, 339, 768, 1829, 272, 347, 2351, 63, 466, 8, 277, 9, 1035, 1709, 14, 4434, 804, 26, 267, 372, 1709, 14, 4434, 804, 14, 25851, 63, 1074, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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,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EDIR = os.path.split(os.path.realpath(__file__))[0] channleinfo = os.path.join(BASEDIR, '..', '..', '..' ,'channelinfo') POSITION_HOLDER_PACKAGE = '%package%' def makeWXEntryActivity(smaliRoot, channel, newPackage): channelSmali = os.path.join(channleinfo, channel, 'script', 'WXEntryActivity.smali') if not os.path.exists(channelSmali): return with open(channelSmali, encoding='utf-8') as f: smaliStr = f.read() oldPackage = POSITION_HOLDER_PACKAGE pathArray = newPackage.split('.') newPackage = pathArray[0] for x in pathArray[1:]: newPackage+='/'+x smaliStr = smaliStr.replace(oldPackage, newPackage) #从newPackage中拿到要创建的文件夹 smaliPath = os.path.join(smaliRoot, *pathArray) smaliPath = os.path.join(smaliPath, 'wxapi') #print('this dir will be make:' + smaliPath) #判断文件夹是否存在 不存在就创建相关文件夹 if not os.path.exists(smaliPath): os.makedirs(smaliPath) #print('make dir : ' + smaliPath) smaliFile = os.path.join(smaliPath, 'WXEntryActivity.smali') fp = open(smaliFile, mode = 'w') fp.write(smaliStr) fp.close()
mit
[ 646, 747, 12, 1274, 199, 199, 5825, 3022, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 59, 16, 61, 199, 335, 1189, 274, 815, 275, 747, 14, 515, 14, 904, 8, 5825, 3022, 12, 19155, 19155, 11541, 7, 20606, 2775, 815, 358, 199, 199, 15717, 63, 40, 15744, 63, 19265, 275, 1543, 2491, 5, 7, 199, 199, 318, 1852, 16783, 3900, 14350, 8, 24460, 73, 6405, 12, 3623, 12, 892, 8599, 304, 339, 3623, 51, 2174, 73, 275, 747, 14, 515, 14, 904, 8, 335, 1189, 274, 815, 12, 3623, 12, 283, 1579, 297, 283, 16783, 3900, 14350, 14, 24460, 73, 358, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2775, 51, 2174, 73, 304, 267, 372, 272, 543, 1551, 8, 2775, 51, 2174, 73, 12, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 267, 9588, 73, 2848, 275, 289, 14, 739, 342, 339, 2269, 8599, 275, 510, 3100, 12039, 63, 40, 15744, 63, 19265, 272, 931, 3836, 275, 892, 8599, 14, 1294, 7563, 272, 892, 8599, 275, 931, 3836, 59, 16, 61, 272, 367, 671, 315, 931, 3836, 59, 17, 10688, 267, 892, 8599, 11, 534, 19047, 88, 339, 9588, 73, 2848, 275, 9588, 73, 2848, 14, 1814, 8, 1753, 8599, 12, 892, 8599, 9, 339, 327, 5498, 237, 1222, 8599, 17088, 163, 234, 124, 29507, 22274, 9051, 250, 29427, 119, 8106, 29303, 11546, 118, 339, 9588, 73, 2042, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 6405, 12, 627, 515, 3836, 9, 339, 9588, 73, 2042, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 2042, 12, 283, 6323, 1246, 358, 339, 327, 1361, 360, 3749, 2935, 911, 506, 1852, 25742, 7, 435, 9588, 73, 2042, 9, 339, 327, 9051, 98, 10310, 256, 29303, 11546, 118, 9729, 8197, 100, 29846, 21448, 221, 221, 19594, 29846, 21448, 15348, 110, 9051, 250, 29427, 119, 15545, 117, 8379, 112, 29303, 11546, 118, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 24460, 73, 2042, 304, 267, 747, 14, 8347, 8, 24460, 73, 2042, 9, 339, 327, 1361, 360, 1875, 2935, 520, 283, 435, 9588, 73, 2042, 9, 339, 9588, 73, 1173, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 2042, 12, 283, 16783, 3900, 14350, 14, 24460, 73, 358, 272, 4090, 275, 1551, 8, 24460, 73, 1173, 12, 818, 275, 283, 87, 358, 272, 4090, 14, 952, 8, 24460, 73, 2848, 9, 272, 4090, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 747, 12, 1274, 199, 199, 5825, 3022, 275, 747, 14, 515, 14, 1294, 8, 736, 14, 515, 14, 11091, 3460, 493, 8964, 59, 16, 61, 199, 335, 1189, 274, 815, 275, 747, 14, 515, 14, 904, 8, 5825, 3022, 12, 19155, 19155, 11541, 7, 20606, 2775, 815, 358, 199, 199, 15717, 63, 40, 15744, 63, 19265, 275, 1543, 2491, 5, 7, 199, 199, 318, 1852, 16783, 3900, 14350, 8, 24460, 73, 6405, 12, 3623, 12, 892, 8599, 304, 339, 3623, 51, 2174, 73, 275, 747, 14, 515, 14, 904, 8, 335, 1189, 274, 815, 12, 3623, 12, 283, 1579, 297, 283, 16783, 3900, 14350, 14, 24460, 73, 358, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 2775, 51, 2174, 73, 304, 267, 372, 272, 543, 1551, 8, 2775, 51, 2174, 73, 12, 2644, 534, 1624, 13, 24, 358, 465, 289, 26, 267, 9588, 73, 2848, 275, 289, 14, 739, 342, 339, 2269, 8599, 275, 510, 3100, 12039, 63, 40, 15744, 63, 19265, 272, 931, 3836, 275, 892, 8599, 14, 1294, 7563, 272, 892, 8599, 275, 931, 3836, 59, 16, 61, 272, 367, 671, 315, 931, 3836, 59, 17, 10688, 267, 892, 8599, 11, 534, 19047, 88, 339, 9588, 73, 2848, 275, 9588, 73, 2848, 14, 1814, 8, 1753, 8599, 12, 892, 8599, 9, 339, 327, 5498, 237, 1222, 8599, 17088, 163, 234, 124, 29507, 22274, 9051, 250, 29427, 119, 8106, 29303, 11546, 118, 339, 9588, 73, 2042, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 6405, 12, 627, 515, 3836, 9, 339, 9588, 73, 2042, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 2042, 12, 283, 6323, 1246, 358, 339, 327, 1361, 360, 3749, 2935, 911, 506, 1852, 25742, 7, 435, 9588, 73, 2042, 9, 339, 327, 9051, 98, 10310, 256, 29303, 11546, 118, 9729, 8197, 100, 29846, 21448, 221, 221, 19594, 29846, 21448, 15348, 110, 9051, 250, 29427, 119, 15545, 117, 8379, 112, 29303, 11546, 118, 272, 340, 440, 747, 14, 515, 14, 2444, 8, 24460, 73, 2042, 304, 267, 747, 14, 8347, 8, 24460, 73, 2042, 9, 339, 327, 1361, 360, 1875, 2935, 520, 283, 435, 9588, 73, 2042, 9, 339, 9588, 73, 1173, 275, 747, 14, 515, 14, 904, 8, 24460, 73, 2042, 12, 283, 16783, 3900, 14350, 14, 24460, 73, 358, 272, 4090, 275, 1551, 8, 24460, 73, 1173, 12, 818, 275, 283, 87, 358, 272, 4090, 14, 952, 8, 24460, 73, 2848, 9, 272, 4090, 14, 1600, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0 ]
qvazzler/Flexget
flexget/plugins/cli/t411.py
1
4526
from __future__ import unicode_literals, division, absolute_import from builtins import * # pylint: disable=unused-import, redefined-builtin from flexget import options, plugin from flexget.event import event from flexget.logger import console from flexget.manager import Session try: from flexget.plugins.api_t411 import (T411Proxy) except: raise plugin.DependencyError(issued_by='cli_series', missing='api_t411', message='Torrent411 commandline interface not loaded') def do_cli(manager, options): """ Dispach cli action :param manager: :param options: :return: """ if options.t411_action == 'list-cats': print_categories(parent_category_name=options.category) elif options.t411_action == 'add-auth': add_credential(username=options.username, password=options.password) elif options.t411_action == 'list-auth': pass elif options.t411_action == 'list-terms': print_terms(category_name=options.category, term_type_name=options.type) def add_credential(username, password): """ Add (or update) credential into database :param username: :param password: :return: """ proxy = T411Proxy() is_new = proxy.add_credential(username=username, password=password) if is_new: console('Credential successfully added') else: console('Credential successfully updated') def print_terms(category_name=None, term_type_name=None): proxy = T411Proxy() proxy.set_credential() formatting_main = '%-60s %-5s %-5s' formatting_sub = ' %-55s %-5s %-5s' console(formatting_main % ('Name', 'PID', 'ID')) if term_type_name: console("Not yet implemented !") else: with Session() as session: categories = proxy.find_categories(category_name=category_name, is_sub_category=True, session=session) for category in categories: console(formatting_main % (category.name, category.parent_id, category.id)) for term_type in category.term_types: console(formatting_main % (term_type.name, '', term_type.id)) for term in term_type.terms: console(formatting_sub % (term.name, term_type.id, term.id)) def print_categories(parent_category_name=None): """ Print category and its sub-categories :param parent_category_name: if None, all categories will be displayed :return: """ proxy = T411Proxy() proxy.set_credential() with Session() as session: if parent_category_name is None: categories = proxy.main_categories(session=session) else: categories = proxy.find_categories(parent_category_name, session=session) formatting_main = '%-30s %-5s %-5s' formatting_sub = ' %-25s %-5s %-5s' console(formatting_main % ('Category name', 'PID', 'ID')) for category in categories: console(formatting_main % (category.name, category.parent_id, category.id)) for sub_category in category.sub_categories: console(formatting_sub % (sub_category.name, sub_category.parent_id, sub_category.id)) @event('options.register') def register_parser_arguments(): # Register the command parser = options.register_command('t411', do_cli, help='view and manipulate the Torrent411 plugin database') # Set up our subparsers action_parsers = parser.add_subparsers(title='actions', metavar='<action>', dest='t411_action') auth_parser = action_parsers.add_parser('add-auth', help='authorize Flexget to access your Torrent411 account') auth_parser.add_argument('username', metavar='<username>', help='Your t411 username') auth_parser.add_argument('password', metavar='<password>', help='Your t411 password') list_categories_parser = action_parsers.add_parser('list-cats', help='list available categories on Torrent411') list_categories_parser.add_argument('category', nargs='?', metavar='<category>', help='limit list to all, main or sub categories (default: %(default)s)') list_terms = action_parsers.add_parser('list-terms', help='list available terms usable on Torrent411') list_terms.add_argument('--category', help='show terms only for this category') list_terms.add_argument('--type', help='show terms only for this term type')
mit
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 504, 12963, 492, 627, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 12, 295, 4037, 13, 5351, 199, 199, 504, 20758, 362, 492, 1511, 12, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 2921, 492, 8559, 199, 504, 20758, 362, 14, 2609, 492, 8596, 199, 199, 893, 26, 272, 687, 20758, 362, 14, 5265, 14, 1246, 63, 84, 25390, 492, 334, 52, 25390, 4936, 9, 199, 2590, 26, 272, 746, 3589, 14, 14403, 547, 8, 5237, 68, 63, 991, 534, 2764, 63, 5602, 297, 4124, 534, 1246, 63, 84, 25390, 297, 639, 1245, 534, 32004, 25390, 28279, 3217, 440, 6511, 358, 421, 199, 318, 886, 63, 2764, 8, 2609, 12, 1511, 304, 272, 408, 272, 5289, 387, 335, 5053, 1595, 272, 520, 635, 5256, 26, 272, 520, 635, 1511, 26, 272, 520, 1107, 26, 272, 408, 272, 340, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 25729, 356, 267, 870, 63, 8906, 8, 1708, 63, 3710, 63, 354, 29, 1419, 14, 3710, 9, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 525, 13, 1178, 356, 267, 1050, 63, 15591, 8, 2473, 29, 1419, 14, 2473, 12, 2505, 29, 1419, 14, 2060, 9, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 1178, 356, 267, 986, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 9187, 356, 267, 870, 63, 9187, 8, 3710, 63, 354, 29, 1419, 14, 3710, 12, 6707, 63, 466, 63, 354, 29, 1419, 14, 466, 9, 421, 199, 318, 1050, 63, 15591, 8, 2473, 12, 2505, 304, 272, 408, 272, 2654, 334, 269, 1678, 9, 16338, 1901, 3050, 272, 520, 635, 3434, 26, 272, 520, 635, 2505, 26, 272, 520, 1107, 26, 272, 408, 272, 4566, 275, 377, 25390, 4936, 342, 272, 365, 63, 1222, 275, 4566, 14, 525, 63, 15591, 8, 2473, 29, 2473, 12, 2505, 29, 2060, 9, 272, 340, 365, 63, 1222, 26, 267, 8559, 360, 23330, 8792, 3483, 358, 272, 587, 26, 267, 8559, 360, 23330, 8792, 4588, 358, 421, 199, 318, 870, 63, 9187, 8, 3710, 63, 354, 29, 403, 12, 6707, 63, 466, 63, 354, 29, 403, 304, 272, 4566, 275, 377, 25390, 4936, 342, 272, 4566, 14, 409, 63, 15591, 342, 272, 10803, 63, 973, 275, 1543, 13, 2259, 83, 19752, 21, 83, 19752, 21, 83, 7, 272, 10803, 63, 954, 275, 283, 258, 19752, 1229, 83, 19752, 21, 83, 19752, 21, 83, 7, 272, 8559, 8, 20034, 63, 973, 450, 661, 985, 297, 283, 16098, 297, 283, 998, 1333, 339, 340, 6707, 63, 466, 63, 354, 26, 267, 8559, 480, 1763, 5966, 6366, 8546, 531, 272, 587, 26, 267, 543, 8596, 342, 465, 2351, 26, 288, 9695, 275, 4566, 14, 1623, 63, 8906, 8, 3710, 63, 354, 29, 3710, 63, 354, 12, 365, 63, 954, 63, 3710, 29, 549, 12, 2351, 29, 1730, 9, 288, 367, 4637, 315, 9695, 26, 355, 8559, 8, 20034, 63, 973, 450, 334, 3710, 14, 354, 12, 4637, 14, 1708, 63, 344, 12, 4637, 14, 344, 430, 355, 367, 6707, 63, 466, 315, 4637, 14, 5125, 63, 1313, 26, 490, 8559, 8, 20034, 63, 973, 450, 334, 5125, 63, 466, 14, 354, 12, 3260, 6707, 63, 466, 14, 344, 430, 490, 367, 6707, 315, 6707, 63, 466, 14, 9187, 26, 717, 8559, 8, 20034, 63, 954, 450, 334, 5125, 14, 354, 12, 6707, 63, 466, 14, 344, 12, 6707, 14, 344, 430, 421, 199, 318, 870, 63, 8906, 8, 1708, 63, 3710, 63, 354, 29, 403, 304, 272, 408, 272, 9101, 4637, 436, 2399, 1007, 13, 8906, 272, 520, 635, 1676, 63, 3710, 63, 354, 26, 340, 488, 12, 1006, 9695, 911, 506, 9080, 272, 520, 1107, 26, 272, 408, 272, 4566, 275, 377, 25390, 4936, 342, 272, 4566, 14, 409, 63, 15591, 342, 272, 543, 8596, 342, 465, 2351, 26, 267, 340, 1676, 63, 3710, 63, 354, 365, 488, 26, 288, 9695, 275, 4566, 14, 973, 63, 8906, 8, 1730, 29, 1730, 9, 267, 587, 26, 288, 9695, 275, 4566, 14, 1623, 63, 8906, 8, 1708, 63, 3710, 63, 354, 12, 2351, 29, 1730, 9, 267, 10803, 63, 973, 275, 1543, 13, 1216, 83, 19752, 21, 83, 19752, 21, 83, 7, 267, 10803, 63, 954, 275, 283, 258, 19752, 821, 83, 19752, 21, 83, 19752, 21, 83, 7, 267, 8559, 8, 20034, 63, 973, 450, 661, 7841, 536, 297, 283, 16098, 297, 283, 998, 1333, 267, 367, 4637, 315, 9695, 26, 288, 8559, 8, 20034, 63, 973, 450, 334, 3710, 14, 354, 12, 4637, 14, 1708, 63, 344, 12, 4637, 14, 344, 430, 288, 367, 1007, 63, 3710, 315, 4637, 14, 954, 63, 8906, 26, 355, 8559, 8, 20034, 63, 954, 450, 334, 954, 63, 3710, 14, 354, 12, 1007, 63, 3710, 14, 1708, 63, 344, 12, 1007, 63, 3710, 14, 344, 430, 421, 199, 32, 1430, 360, 1419, 14, 2683, 358, 199, 318, 2274, 63, 2087, 63, 4958, 837, 272, 327, 11828, 314, 1414, 272, 1798, 275, 1511, 14, 2683, 63, 1531, 360, 84, 25390, 297, 886, 63, 2764, 12, 1720, 534, 1345, 436, 27232, 314, 29659, 640, 25390, 3589, 3050, 358, 339, 327, 2494, 1536, 4154, 26763, 272, 1595, 63, 11531, 275, 1798, 14, 525, 63, 954, 11531, 8, 1213, 534, 3723, 297, 8214, 15829, 1287, 4206, 2053, 534, 84, 25390, 63, 1287, 358, 272, 1790, 63, 2087, 275, 1595, 63, 11531, 14, 525, 63, 2087, 360, 525, 13, 1178, 297, 1720, 534, 14204, 481, 3113, 362, 370, 2879, 2195, 29659, 640, 25390, 2933, 358, 272, 1790, 63, 2087, 14, 525, 63, 2094, 360, 2473, 297, 8214, 15829, 2473, 4206, 1720, 534, 14398, 307, 25390, 3434, 358, 272, 1790, 63, 2087, 14, 525, 63, 2094, 360, 2060, 297, 8214, 15829, 2060, 4206, 1720, 534, 14398, 307, 25390, 2505, 358, 339, 769, 63, 8906, 63, 2087, 275, 1595, 63, 11531, 14, 525, 63, 2087, 360, 513, 13, 25729, 297, 1720, 534, 513, 2808, 9695, 641, 29659, 640, 25390, 358, 272, 769, 63, 8906, 63, 2087, 14, 525, 63, 2094, 360, 3710, 297, 3147, 9237 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 12, 4629, 12, 3679, 63, 646, 199, 504, 12963, 492, 627, 221, 327, 4287, 26, 3507, 29, 8618, 13, 646, 12, 295, 4037, 13, 5351, 199, 199, 504, 20758, 362, 492, 1511, 12, 3589, 199, 504, 20758, 362, 14, 1430, 492, 1566, 199, 504, 20758, 362, 14, 2921, 492, 8559, 199, 504, 20758, 362, 14, 2609, 492, 8596, 199, 199, 893, 26, 272, 687, 20758, 362, 14, 5265, 14, 1246, 63, 84, 25390, 492, 334, 52, 25390, 4936, 9, 199, 2590, 26, 272, 746, 3589, 14, 14403, 547, 8, 5237, 68, 63, 991, 534, 2764, 63, 5602, 297, 4124, 534, 1246, 63, 84, 25390, 297, 639, 1245, 534, 32004, 25390, 28279, 3217, 440, 6511, 358, 421, 199, 318, 886, 63, 2764, 8, 2609, 12, 1511, 304, 272, 408, 272, 5289, 387, 335, 5053, 1595, 272, 520, 635, 5256, 26, 272, 520, 635, 1511, 26, 272, 520, 1107, 26, 272, 408, 272, 340, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 25729, 356, 267, 870, 63, 8906, 8, 1708, 63, 3710, 63, 354, 29, 1419, 14, 3710, 9, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 525, 13, 1178, 356, 267, 1050, 63, 15591, 8, 2473, 29, 1419, 14, 2473, 12, 2505, 29, 1419, 14, 2060, 9, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 1178, 356, 267, 986, 272, 916, 1511, 14, 84, 25390, 63, 1287, 508, 283, 513, 13, 9187, 356, 267, 870, 63, 9187, 8, 3710, 63, 354, 29, 1419, 14, 3710, 12, 6707, 63, 466, 63, 354, 29, 1419, 14, 466, 9, 421, 199, 318, 1050, 63, 15591, 8, 2473, 12, 2505, 304, 272, 408, 272, 2654, 334, 269, 1678, 9, 16338, 1901, 3050, 272, 520, 635, 3434, 26, 272, 520, 635, 2505, 26, 272, 520, 1107, 26, 272, 408, 272, 4566, 275, 377, 25390, 4936, 342, 272, 365, 63, 1222, 275, 4566, 14, 525, 63, 15591, 8, 2473, 29, 2473, 12, 2505, 29, 2060, 9, 272, 340, 365, 63, 1222, 26, 267, 8559, 360, 23330, 8792, 3483, 358, 272, 587, 26, 267, 8559, 360, 23330, 8792, 4588, 358, 421, 199, 318, 870, 63, 9187, 8, 3710, 63, 354, 29, 403, 12, 6707, 63, 466, 63, 354, 29, 403, 304, 272, 4566, 275, 377, 25390, 4936, 342, 272, 4566, 14, 409, 63, 15591, 342, 272, 10803, 63, 973, 275, 1543, 13, 2259, 83, 19752, 21, 83, 19752, 21, 83, 7, 272, 10803, 63, 954, 275, 283, 258, 19752, 1229, 83, 19752, 21, 83, 19752, 21, 83, 7, 272, 8559, 8, 20034, 63, 973, 450, 661, 985, 297, 283, 16098, 297, 283, 998, 1333, 339, 340, 6707, 63, 466, 63, 354, 26, 267, 8559, 480, 1763, 5966, 6366, 8546, 531, 272, 587, 26, 267, 543, 8596, 342, 465, 2351, 26, 288, 9695, 275, 4566, 14, 1623, 63, 8906, 8, 3710, 63, 354, 29, 3710, 63, 354, 12, 365, 63, 954, 63, 3710, 29, 549, 12, 2351, 29, 1730, 9, 288, 367, 4637, 315, 9695, 26, 355, 8559, 8, 20034, 63, 973, 450, 334, 3710, 14, 354, 12, 4637, 14, 1708, 63, 344, 12, 4637, 14, 344, 430, 355, 367, 6707, 63, 466, 315, 4637, 14, 5125, 63, 1313, 26, 490, 8559, 8, 20034, 63, 973, 450, 334, 5125, 63, 466, 14, 354, 12, 3260, 6707, 63, 466, 14, 344, 430, 490, 367, 6707, 315, 6707, 63, 466, 14, 9187, 26, 717, 8559, 8, 20034, 63, 954, 450, 334, 5125, 14, 354, 12, 6707, 63, 466, 14, 344, 12, 6707, 14, 344, 430, 421, 199, 318, 870, 63, 8906, 8, 1708, 63, 3710, 63, 354, 29, 403, 304, 272, 408, 272, 9101, 4637, 436, 2399, 1007, 13, 8906, 272, 520, 635, 1676, 63, 3710, 63, 354, 26, 340, 488, 12, 1006, 9695, 911, 506, 9080, 272, 520, 1107, 26, 272, 408, 272, 4566, 275, 377, 25390, 4936, 342, 272, 4566, 14, 409, 63, 15591, 342, 272, 543, 8596, 342, 465, 2351, 26, 267, 340, 1676, 63, 3710, 63, 354, 365, 488, 26, 288, 9695, 275, 4566, 14, 973, 63, 8906, 8, 1730, 29, 1730, 9, 267, 587, 26, 288, 9695, 275, 4566, 14, 1623, 63, 8906, 8, 1708, 63, 3710, 63, 354, 12, 2351, 29, 1730, 9, 267, 10803, 63, 973, 275, 1543, 13, 1216, 83, 19752, 21, 83, 19752, 21, 83, 7, 267, 10803, 63, 954, 275, 283, 258, 19752, 821, 83, 19752, 21, 83, 19752, 21, 83, 7, 267, 8559, 8, 20034, 63, 973, 450, 661, 7841, 536, 297, 283, 16098, 297, 283, 998, 1333, 267, 367, 4637, 315, 9695, 26, 288, 8559, 8, 20034, 63, 973, 450, 334, 3710, 14, 354, 12, 4637, 14, 1708, 63, 344, 12, 4637, 14, 344, 430, 288, 367, 1007, 63, 3710, 315, 4637, 14, 954, 63, 8906, 26, 355, 8559, 8, 20034, 63, 954, 450, 334, 954, 63, 3710, 14, 354, 12, 1007, 63, 3710, 14, 1708, 63, 344, 12, 1007, 63, 3710, 14, 344, 430, 421, 199, 32, 1430, 360, 1419, 14, 2683, 358, 199, 318, 2274, 63, 2087, 63, 4958, 837, 272, 327, 11828, 314, 1414, 272, 1798, 275, 1511, 14, 2683, 63, 1531, 360, 84, 25390, 297, 886, 63, 2764, 12, 1720, 534, 1345, 436, 27232, 314, 29659, 640, 25390, 3589, 3050, 358, 339, 327, 2494, 1536, 4154, 26763, 272, 1595, 63, 11531, 275, 1798, 14, 525, 63, 954, 11531, 8, 1213, 534, 3723, 297, 8214, 15829, 1287, 4206, 2053, 534, 84, 25390, 63, 1287, 358, 272, 1790, 63, 2087, 275, 1595, 63, 11531, 14, 525, 63, 2087, 360, 525, 13, 1178, 297, 1720, 534, 14204, 481, 3113, 362, 370, 2879, 2195, 29659, 640, 25390, 2933, 358, 272, 1790, 63, 2087, 14, 525, 63, 2094, 360, 2473, 297, 8214, 15829, 2473, 4206, 1720, 534, 14398, 307, 25390, 3434, 358, 272, 1790, 63, 2087, 14, 525, 63, 2094, 360, 2060, 297, 8214, 15829, 2060, 4206, 1720, 534, 14398, 307, 25390, 2505, 358, 339, 769, 63, 8906, 63, 2087, 275, 1595, 63, 11531, 14, 525, 63, 2087, 360, 513, 13, 25729, 297, 1720, 534, 513, 2808, 9695, 641, 29659, 640, 25390, 358, 272, 769, 63, 8906, 63, 2087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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
provaleks/o8
addons/l10n_eu_service/wizard/wizard.py
242
8513
# -*- coding: utf-8 -*- ############################################################################## # # Odoo, Open Source Business Applications # Copyright (C) 2015 Odoo S.A. <http://www.odoo.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.exceptions import Warning from openerp import fields, models, api from openerp.tools.translate import _ class l10n_eu_service(models.TransientModel): """Create fiscal positions for EU Service VAT""" _name = "l10n_eu_service.wizard" _description = __doc__ def _get_eu_res_country_group(self): eu_group = self.env.ref("base.europe", raise_if_not_found=False) if not eu_group: raise Warning(_('The Europe country group cannot be found. ' 'Please update the base module.')) return eu_group def _default_chart_id(self): user = self.env.user return self.env['account.account'].search( [('company_id', '=', user.company_id.id), ('parent_id', '=', False)], limit=1) def _default_fiscal_position_id(self): user = self.env.user eu_id = self._get_eu_res_country_group() return self.env['account.fiscal.position'].search( [('company_id', '=', user.company_id.id), ('vat_required', '=', True), ('country_group_id.id', '=', eu_id.id)], limit=1) def _default_tax_id(self): user = self.env.user return self.env['account.tax'].search( [('company_id', '=', user.company_id.id), ('type_tax_use', '=', 'sale'), ('type', '=', 'percent'), ('account_collected_id', '!=', False), ('tax_code_id', '!=', False)], limit=1, order='amount desc') def _default_done_country_ids(self): user = self.env.user eu_country_group = self._get_eu_res_country_group() return eu_country_group.country_ids - self._default_todo_country_ids() - user.company_id.country_id def _default_todo_country_ids(self): user = self.env.user eu_country_group = self._get_eu_res_country_group() eu_fiscal = self.env['account.fiscal.position'].search( [('country_id', 'in', eu_country_group.country_ids.ids), ('vat_required', '=', False), ('auto_apply', '=', True), ('company_id', '=', user.company_id.id)]) return eu_country_group.country_ids - eu_fiscal.mapped('country_id') - user.company_id.country_id chart_id = fields.Many2one( "account.account", string="Chart of Accounts", required=True, default=_default_chart_id) company_id = fields.Many2one( 'res.company', string='Company', required=True, related='chart_id.company_id', readonly=True) fiscal_position_id = fields.Many2one( 'account.fiscal.position', string='Fiscal Position', default=_default_fiscal_position_id, help="Optional fiscal position to use as template for general account mapping. " "Should usually be your current Intra-EU B2B fiscal position. " "If not set, no general account mapping will be configured for EU fiscal positions.") tax_id = fields.Many2one( 'account.tax', string='Service VAT', required=True, default=_default_tax_id, help="Select your current VAT tax for services. This is the tax that will be mapped " "to the corresponding VAT tax in each EU country selected below.") account_collected_id = fields.Many2one( "account.account", string="Tax Collection Account", help="Optional account to use for collecting tax amounts when selling services in " "each EU country selected below. If not set, the current collecting account of " "your Service VAT will be used.") done_country_ids = fields.Many2many( 'res.country', 'l10n_eu_service_country_rel_done', default=_default_done_country_ids, string='Already Supported') todo_country_ids = fields.Many2many( 'res.country', 'l10n_eu_service_country_rel_todo', default=_default_todo_country_ids, string='EU Customers From', required=True) @api.multi def generate_eu_service(self): imd = self.env['ir.model.data'] tax_code = self.env['account.tax.code'] tax_rate = self.env["l10n_eu_service.service_tax_rate"] account_tax = self.env['account.tax'] fpos = self.env['account.fiscal.position'] chart_xid = 'l10n_eu_service.tax_chart_service_eu_company_%s' % self.company_id.name chart = self.env.ref(chart_xid, raise_if_not_found=False) if not chart: vals = { 'name': _("EU MOSS VAT Chart - %(company)s") % {'company': self.company_id.name}, 'company_id': self.company_id.id, 'parent_id': False } chart_id = tax_code.create(vals).id vals_data = { 'name': 'tax_chart_service_eu_company_%s'%(self.company_id.name), 'model': 'account.tax.code', 'module': 'l10n_eu_service', 'res_id': chart_id, 'noupdate': True, # Don't drop it when module is updated } imd.create(vals_data) else: chart_id = chart.id for country in self.todo_country_ids: format_params = {'country_name': country.name} tx_base_code_data = { 'name': _("Base - VAT for EU Services to %(country_name)s") % format_params, 'code': "BASE-EU-VAT-%s" % country.code, 'parent_id': chart_id, } tax_name = _("VAT for EU Services to %(country_name)s") % format_params tx_code_data = { 'name': tax_name, 'code': "EU-VAT-%s" % country.code, 'parent_id': chart_id, } tx_base_code = tax_code.create(tx_base_code_data) tx_code = tax_code.create(tx_code_data) #create a new tax based on the selected service tax data_tax = { 'name': tax_name, 'amount': tax_rate.search([('country_id', '=', country.id)]).rate, 'base_code_id': self.tax_id.base_code_id.id, 'account_collected_id': self.account_collected_id.id or self.tax_id.account_collected_id.id, 'account_paid_id': self.account_collected_id.id or self.tax_id.account_collected_id.id, 'type_tax_use': 'sale', 'base_code_id': tx_base_code.id, 'ref_base_code_id': tx_base_code.id, 'tax_code_id': tx_code.id, 'ref_tax_code_id': tx_code.id, 'ref_base_sign': -1, 'ref_tax_sign': -1, 'description': "EU-VAT-%s-S" % country.code, 'sequence': 1000, } tax = account_tax.create(data_tax) if self.fiscal_position_id: account_ids = [(6, 0, self.fiscal_position_id.account_ids.ids)] else: account_ids = False #create a fiscal position for the country fiscal_pos_name = _("Intra-EU B2C in %(country_name)s") % {'country_name': country.name} fiscal_pos_name += " (EU-VAT-%s)" % country.code data_fiscal = { 'name': fiscal_pos_name, 'company_id': self.chart_id.company_id.id, 'vat_required': False, 'auto_apply': True, 'country_id': country.id, 'account_ids': account_ids, 'tax_ids': [(0, 0, {'tax_src_id': self.tax_id.id, 'tax_dest_id': tax.id})], } fpos.create(data_fiscal) return {'type': 'ir.actions.act_window_close'}
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 28935, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 35, 9, 6900, 28935, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 22058, 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, 199, 199, 504, 5166, 14, 3924, 492, 15902, 199, 504, 5166, 492, 1504, 12, 1709, 12, 2986, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 634, 709, 78, 63, 16913, 63, 1364, 8, 992, 14, 14612, 14928, 1685, 304, 339, 408, 2499, 18672, 12266, 367, 26007, 7591, 812, 619, 624, 339, 485, 354, 275, 298, 76, 709, 78, 63, 16913, 63, 1364, 14, 9819, 2, 272, 485, 1802, 275, 636, 1301, 363, 339, 347, 485, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 8, 277, 304, 267, 325, 85, 63, 923, 275, 291, 14, 1813, 14, 1121, 480, 1095, 14, 69, 12646, 401, 746, 63, 692, 63, 1397, 63, 4214, 29, 797, 9, 267, 340, 440, 325, 85, 63, 923, 26, 288, 746, 15902, 6723, 1918, 31615, 9023, 1572, 3913, 506, 1911, 14, 283, 1169, 283, 8254, 1678, 314, 1300, 859, 12459, 267, 372, 325, 85, 63, 923, 339, 347, 485, 885, 63, 9019, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 372, 291, 14, 1813, 459, 2048, 14, 2048, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 1708, 63, 344, 297, 6291, 756, 4360, 2304, 29, 17, 9, 339, 347, 485, 885, 63, 18646, 63, 3124, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 344, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 372, 291, 14, 1813, 459, 2048, 14, 18646, 14, 3124, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 16305, 63, 2427, 297, 6291, 715, 395, 1467, 661, 6063, 63, 923, 63, 344, 14, 344, 297, 6291, 325, 85, 63, 344, 14, 344, 4360, 2304, 29, 17, 9, 339, 347, 485, 885, 63, 5530, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 372, 291, 14, 1813, 459, 2048, 14, 5530, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 466, 63, 5530, 63, 1180, 297, 6291, 283, 8515, 659, 1467, 661, 466, 297, 6291, 283, 7045, 659, 661, 2048, 63, 22766, 63, 344, 297, 31326, 756, 395, 1467, 661, 5530, 63, 600, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 12, 1865, 534, 4606, 4328, 358, 339, 347, 485, 885, 63, 4456, 63, 6063, 63, 1580, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 6063, 63, 923, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 372, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 446, 291, 423, 885, 63, 11396, 63, 6063, 63, 1580, 342, 446, 922, 14, 4627, 63, 344, 14, 6063, 63, 344, 339, 347, 485, 885, 63, 11396, 63, 6063, 63, 1580, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 6063, 63, 923, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 325, 85, 63, 18646, 275, 291, 14, 1813, 459, 2048, 14, 18646, 14, 3124, 2278, 1733, 8, 288, 4274, 6063, 63, 344, 297, 283, 262, 297, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 14, 1580, 395, 1467, 661, 16305, 63, 2427, 297, 6291, 756, 395, 661, 2495, 63, 4998, 297, 6291, 715, 395, 1467, 661, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 3948, 267, 372, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 446, 325, 85, 63, 18646, 14, 11663, 360, 6063, 63, 344, 358, 446, 922, 14, 4627, 63, 344, 14, 6063, 63, 344, 2286, 10943, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 298, 2048, 14, 2048, 401, 1059, 628, 16372, 402, 4473, 6851, 401, 1415, 29, 549, 12, 849, 3699, 885, 63, 9019, 63, 344, 9, 272, 7233, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 470, 14, 4627, 297, 1059, 534, 16063, 297, 1415, 29, 549, 12, 4960, 4048, 534, 9019, 63, 344, 14, 4627, 63, 344, 297, 6863, 29, 549, 9, 272, 18672, 63, 3124, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 2048, 14, 18646, 14, 3124, 297, 1059, 534, 38, 15734, 15483, 297, 849, 3699, 885, 63, 18646, 63, 3124, 63, 344, 12, 267, 1720, 628, 7012, 18672, 3421, 370, 675, 465, 1978, 367, 8605, 2933, 4412, 14, 298, 1467, 298, 11408, 9987, 506, 2195, 1453, 9805, 345, 13, 23539, 699, 18, 34, 18672, 3421, 14, 298, 1467, 298, 3917, 440, 663, 12, 949, 8605, 2933, 4412, 911, 506, 7526, 367, 26007, 18672, 12266, 2685, 272, 9067, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 2048, 14, 5530, 297, 1059, 534, 3167, 812, 619, 297 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 28935, 12, 3232, 5800, 23813, 24636, 199, 3, 259, 1898, 334, 35, 9, 6900, 28935, 428, 14, 33, 14, 665, 1014, 921, 1544, 14, 22058, 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, 199, 199, 504, 5166, 14, 3924, 492, 15902, 199, 504, 5166, 492, 1504, 12, 1709, 12, 2986, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 533, 634, 709, 78, 63, 16913, 63, 1364, 8, 992, 14, 14612, 14928, 1685, 304, 339, 408, 2499, 18672, 12266, 367, 26007, 7591, 812, 619, 624, 339, 485, 354, 275, 298, 76, 709, 78, 63, 16913, 63, 1364, 14, 9819, 2, 272, 485, 1802, 275, 636, 1301, 363, 339, 347, 485, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 8, 277, 304, 267, 325, 85, 63, 923, 275, 291, 14, 1813, 14, 1121, 480, 1095, 14, 69, 12646, 401, 746, 63, 692, 63, 1397, 63, 4214, 29, 797, 9, 267, 340, 440, 325, 85, 63, 923, 26, 288, 746, 15902, 6723, 1918, 31615, 9023, 1572, 3913, 506, 1911, 14, 283, 1169, 283, 8254, 1678, 314, 1300, 859, 12459, 267, 372, 325, 85, 63, 923, 339, 347, 485, 885, 63, 9019, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 372, 291, 14, 1813, 459, 2048, 14, 2048, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 1708, 63, 344, 297, 6291, 756, 4360, 2304, 29, 17, 9, 339, 347, 485, 885, 63, 18646, 63, 3124, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 344, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 372, 291, 14, 1813, 459, 2048, 14, 18646, 14, 3124, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 16305, 63, 2427, 297, 6291, 715, 395, 1467, 661, 6063, 63, 923, 63, 344, 14, 344, 297, 6291, 325, 85, 63, 344, 14, 344, 4360, 2304, 29, 17, 9, 339, 347, 485, 885, 63, 5530, 63, 344, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 372, 291, 14, 1813, 459, 2048, 14, 5530, 2278, 1733, 8, 288, 4274, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 395, 661, 466, 63, 5530, 63, 1180, 297, 6291, 283, 8515, 659, 1467, 661, 466, 297, 6291, 283, 7045, 659, 661, 2048, 63, 22766, 63, 344, 297, 31326, 756, 395, 1467, 661, 5530, 63, 600, 63, 344, 297, 31326, 756, 4360, 2304, 29, 17, 12, 1865, 534, 4606, 4328, 358, 339, 347, 485, 885, 63, 4456, 63, 6063, 63, 1580, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 6063, 63, 923, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 372, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 446, 291, 423, 885, 63, 11396, 63, 6063, 63, 1580, 342, 446, 922, 14, 4627, 63, 344, 14, 6063, 63, 344, 339, 347, 485, 885, 63, 11396, 63, 6063, 63, 1580, 8, 277, 304, 267, 922, 275, 291, 14, 1813, 14, 751, 267, 325, 85, 63, 6063, 63, 923, 275, 291, 423, 362, 63, 16913, 63, 470, 63, 6063, 63, 923, 342, 267, 325, 85, 63, 18646, 275, 291, 14, 1813, 459, 2048, 14, 18646, 14, 3124, 2278, 1733, 8, 288, 4274, 6063, 63, 344, 297, 283, 262, 297, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 14, 1580, 395, 1467, 661, 16305, 63, 2427, 297, 6291, 756, 395, 661, 2495, 63, 4998, 297, 6291, 715, 395, 1467, 661, 4627, 63, 344, 297, 6291, 922, 14, 4627, 63, 344, 14, 344, 3948, 267, 372, 325, 85, 63, 6063, 63, 923, 14, 6063, 63, 1580, 446, 325, 85, 63, 18646, 14, 11663, 360, 6063, 63, 344, 358, 446, 922, 14, 4627, 63, 344, 14, 6063, 63, 344, 2286, 10943, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 298, 2048, 14, 2048, 401, 1059, 628, 16372, 402, 4473, 6851, 401, 1415, 29, 549, 12, 849, 3699, 885, 63, 9019, 63, 344, 9, 272, 7233, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 470, 14, 4627, 297, 1059, 534, 16063, 297, 1415, 29, 549, 12, 4960, 4048, 534, 9019, 63, 344, 14, 4627, 63, 344, 297, 6863, 29, 549, 9, 272, 18672, 63, 3124, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 2048, 14, 18646, 14, 3124, 297, 1059, 534, 38, 15734, 15483, 297, 849, 3699, 885, 63, 18646, 63, 3124, 63, 344, 12, 267, 1720, 628, 7012, 18672, 3421, 370, 675, 465, 1978, 367, 8605, 2933, 4412, 14, 298, 1467, 298, 11408, 9987, 506, 2195, 1453, 9805, 345, 13, 23539, 699, 18, 34, 18672, 3421, 14, 298, 1467, 298, 3917, 440, 663, 12, 949, 8605, 2933, 4412, 911, 506, 7526, 367, 26007, 18672, 12266, 2685, 272, 9067, 63, 344, 275, 1504, 14, 4089, 18, 368, 8, 267, 283, 2048, 14, 5530, 297, 1059, 534, 3167, 812, 619, 297, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
naylor-b/aserver
analysis_server/cfg_wrapper.py
1
6200
import os import sys import time import logging from inspect import getmembers, ismethod, isfunction from itertools import chain from fnmatch import fnmatchcase from six import iteritems from openmdao.core.problem import Problem import openmdao.util.log from analysis_server.varwrapper import _find_var_wrapper from analysis_server.proxy import _setup_obj _CONFIG_DEFAULTS = { 'version': '', 'comment': '', 'author': '', 'description': '', 'help_url': '', 'keywords': '', 'requirements': '', 'args': '', 'directory': None, 'filename': None, 'in_attrs': '', 'out_attrs': '', 'in_vars': '', 'out_vars': '*', 'methods': '', } # maps option names from cfg file to attribute names in the wrapper _CFG_MAP = { 'in_vars': 'in_var_patterns', 'out_vars': 'out_var_patterns', } def _str2list(string): lst = [] for s in string.split(): ss = s.strip() if ss: lst.append(ss) return lst def _get_match(name, patterns): for p in patterns: if fnmatchcase(name, p): return name.replace(':', '.') def _deep_getattr(obj, name): for n in name.split('.'): obj = getattr(obj, n) return obj class _ConfigWrapper(object): """ Retains configuration data for a wrapped component class. config: :class:`ConfigParser.ConfigParser` Configuration data. instance: Component Temporary wrapped instance to interrogate. cfg_path: string Path to the configuration file. """ def __init__(self, classname, config, timestamp): # Get description info. # Get Python class and create temporary instance. for option in _CONFIG_DEFAULTS: setattr(self, _CFG_MAP.get(option, option), config.get('AnalysisServer', option)) self.args = _str2list(self.args) self.in_var_patterns = _str2list(self.in_var_patterns) self.out_var_patterns = _str2list(self.out_var_patterns) self.in_attrs = _str2list(self.in_attrs) self.out_attrs = _str2list(self.out_attrs) self.methods = _str2list(self.methods) instance = _setup_obj(classname, 'comp', self.filename, args=self.args) # Check for optional diectory path. if self.directory: if os.path.isabs(self.directory) or self.directory.startswith('..'): raise ValueError('directory %r must be a subdirectory' % self.directory) self.classname = classname # Timestamp from config file timestamp self.timestamp = timestamp self.checksum = 0 self.has_icon = False # Default description from instance.__doc__. if not self.description: if instance.__doc__ is not None: self.description = instance.__doc__ # Get properties. self.inputs = self._setup_mapping(instance, 'invar') self.outputs = self._setup_mapping(instance, 'outvar') self.in_attrs = self._setup_mapping(instance, 'inattr') self.out_attrs = self._setup_mapping(instance, 'outattr') # overlapping glob patterns result in outputs for name in self.out_attrs: if name in self.in_attrs: del self.in_attrs self.properties = {} self.properties.update(self.inputs) self.properties.update(self.outputs) self.properties.update(self.in_attrs) self.properties.update(self.out_attrs) # Get methods. methods = self.methods self.methods = {} for name in methods: logging.debug(' register %s()', name) self.methods[name] = name instance.cleanup() if hasattr(instance, 'pre_delete'): instance.pre_delete() def _setup_mapping(self, instance, iotype): """ Return dictionary mapping external paths to internal paths. instance: Problem Temporary wrapped Problem to interrogate. iotype: str String indicating type [invar, outvar, inattr, outattr] """ mapping = {} if iotype in ('inattr', 'outattr'): attrs = self.in_attrs if iotype == 'inattr' else self.out_attrs for attr in attrs: try: val = _deep_getattr(instance, attr) except AttributeError as exc: raise AttributeError("Couldn't find '%s' in '%s': %s" % (attr, instance.pathname,str(exc))) wrapper_class = _find_var_wrapper(val) if wrapper_class is None: logging.warning("%s", val) logging.warning('%r not a supported type: %r', attr, type(val).__name__) continue mapping[attr] = attr return mapping to_prom = instance.root._sysdata.to_prom_name if iotype == 'invar': pdict = instance.root._params_dict seen = set() items = [] for k, m in chain(iteritems(pdict), iteritems(instance.root._unknowns_dict)): prom = to_prom[k] if prom not in seen: seen.add(prom) items.append((prom, m['val'])) patterns = self.in_var_patterns elif iotype == 'outvar': items = [(to_prom[k],m['val']) for k,m in iteritems(instance.root._unknowns_dict)] patterns = self.out_var_patterns else: raise TypeError("bad iotype (%s). Should be one of [invar, outvar, inattr, outattr]" % iotype) for name, val in sorted(items, key=lambda x: x[0]): # Only register if it's a supported type. wrapper_class = _find_var_wrapper(val) if wrapper_class is None: logging.warning("%s", val) logging.warning('%r not a supported type: %r', name, type(val).__name__) continue m = _get_match(name, patterns) if m is not None: mapping[m] = name return mapping
apache-2.0
[ 199, 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 2050, 199, 504, 6485, 492, 664, 6334, 12, 365, 765, 12, 365, 1593, 199, 504, 7975, 492, 6036, 199, 504, 15951, 492, 15951, 2546, 199, 199, 504, 3816, 492, 10849, 199, 199, 504, 1551, 77, 20431, 14, 1018, 14, 6462, 492, 20980, 199, 646, 1551, 77, 20431, 14, 1974, 14, 793, 199, 199, 504, 11284, 63, 1000, 14, 1391, 5029, 492, 485, 1623, 63, 1391, 63, 5029, 199, 504, 11284, 63, 1000, 14, 3280, 492, 485, 2758, 63, 1113, 199, 199, 63, 5569, 63, 30773, 275, 469, 272, 283, 1023, 356, 3260, 272, 283, 3349, 356, 3260, 272, 283, 2502, 356, 3260, 272, 283, 1802, 356, 3260, 272, 283, 3437, 63, 633, 356, 3260, 272, 283, 7511, 356, 3260, 272, 283, 7538, 356, 3260, 272, 283, 589, 356, 3260, 272, 283, 3619, 356, 488, 12, 272, 283, 1501, 356, 488, 12, 272, 283, 262, 63, 3288, 356, 3260, 272, 283, 548, 63, 3288, 356, 3260, 272, 283, 262, 63, 2936, 356, 3260, 272, 283, 548, 63, 2936, 356, 24999, 272, 283, 2474, 356, 3260, 199, 93, 199, 199, 3, 9033, 945, 1561, 687, 4810, 570, 370, 2225, 1561, 315, 314, 4975, 199, 63, 10118, 63, 5443, 275, 469, 272, 283, 262, 63, 2936, 356, 283, 262, 63, 1391, 63, 7435, 297, 272, 283, 548, 63, 2936, 356, 283, 548, 63, 1391, 63, 7435, 297, 199, 93, 199, 199, 318, 485, 495, 18, 513, 8, 875, 304, 272, 9877, 275, 942, 272, 367, 308, 315, 1059, 14, 1294, 837, 267, 10110, 275, 308, 14, 1913, 342, 267, 340, 10110, 26, 288, 9877, 14, 740, 8, 385, 9, 272, 372, 9877, 199, 199, 318, 485, 362, 63, 1431, 8, 354, 12, 7970, 304, 272, 367, 299, 315, 7970, 26, 267, 340, 15951, 2546, 8, 354, 12, 299, 304, 288, 372, 536, 14, 1814, 16451, 20093, 199, 199, 318, 485, 16131, 63, 5675, 8, 1113, 12, 536, 304, 272, 367, 302, 315, 536, 14, 1294, 26461, 267, 1559, 275, 2519, 8, 1113, 12, 302, 9, 272, 372, 1559, 199, 199, 533, 485, 2028, 4590, 8, 785, 304, 272, 408, 272, 8747, 1581, 83, 2897, 666, 367, 282, 8072, 3931, 1021, 14, 339, 1101, 26, 520, 533, 1705, 15218, 14, 15218, 64, 267, 11595, 666, 14, 339, 1256, 26, 12727, 267, 21791, 8072, 1256, 370, 1640, 13095, 14, 339, 4810, 63, 515, 26, 1059, 267, 6912, 370, 314, 2897, 570, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 15876, 12, 1101, 12, 4913, 304, 398, 327, 2372, 1369, 2256, 14, 267, 327, 2372, 2018, 1021, 436, 1218, 7937, 1256, 14, 267, 367, 945, 315, 485, 5569, 63, 30773, 26, 288, 5371, 8, 277, 12, 485, 10118, 63, 5443, 14, 362, 8, 1422, 12, 945, 395, 1101, 14, 362, 360, 13182, 3120, 297, 945, 430, 398, 291, 14, 589, 275, 485, 495, 18, 513, 8, 277, 14, 589, 9, 267, 291, 14, 262, 63, 1391, 63, 7435, 275, 485, 495, 18, 513, 8, 277, 14, 262, 63, 1391, 63, 7435, 9, 267, 291, 14, 548, 63, 1391, 63, 7435, 275, 485, 495, 18, 513, 8, 277, 14, 548, 63, 1391, 63, 7435, 9, 267, 291, 14, 262, 63, 3288, 275, 485, 495, 18, 513, 8, 277, 14, 262, 63, 3288, 9, 267, 291, 14, 548, 63, 3288, 275, 485, 495, 18, 513, 8, 277, 14, 548, 63, 3288, 9, 267, 291, 14, 2474, 275, 485, 495, 18, 513, 8, 277, 14, 2474, 9, 398, 1256, 275, 485, 2758, 63, 1113, 8, 19851, 12, 283, 863, 297, 291, 14, 1501, 12, 1249, 29, 277, 14, 589, 9, 398, 327, 2670, 367, 2716, 487, 449, 1089, 931, 14, 267, 340, 291, 14, 3619, 26, 288, 340, 747, 14, 515, 14, 17896, 8, 277, 14, 3619, 9, 503, 291, 14, 3619, 14, 2460, 24893, 735, 355, 746, 1722, 360, 3619, 450, 82, 1471, 506, 282, 25094, 7, 639, 450, 291, 14, 3619, 9, 398, 291, 14, 19851, 275, 15876, 398, 327, 18267, 687, 1101, 570, 4913, 267, 291, 14, 3954, 275, 4913, 267, 291, 14, 8928, 275, 378, 267, 291, 14, 1989, 63, 4677, 275, 756, 398, 327, 3758, 1369, 687, 1256, 855, 1301, 4343, 267, 340, 440, 291, 14, 1802, 26, 288, 340, 1256, 855, 1301, 363, 365, 440, 488, 26, 355, 291, 14, 1802, 275, 1256, 855, 1301, 363, 398, 327, 2372, 4382, 14, 267, 291, 14, 3711, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 262, 1391, 358, 267, 291, 14, 4467, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 548, 1391, 358, 267, 291, 14, 262, 63, 3288, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 262, 962, 358, 267, 291, 14, 548, 63, 3288, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 548, 962, 358, 398, 327, 28281, 5739, 7970, 754, 315, 4704, 267, 367, 536, 315, 291, 14, 548, 63, 3288, 26, 288, 340, 536, 315, 291, 14, 262, 63, 3288, 26, 355, 2150, 291, 14, 262, 63, 3288, 398, 291, 14, 3282, 275, 1052, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 3711, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 4467, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 262, 63, 3288, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 548, 63, 3288, 9, 398, 327, 2372, 3102, 14, 267, 3102, 275, 291, 14, 2474, 267, 291, 14, 2474, 275, 1052, 267, 367, 536, 315, 3102, 26, 288, 2050, 14, 1757, 360, 259, 2274, 450, 83, 19633, 536, 9, 288, 291, 14, 2474, 59, 354, 61, 275, 536, 398, 1256, 14, 7661, 342, 267, 340, 2688, 8, 842, 12, 283, 657, 63, 1807, 735, 288, 1256, 14, 657, 63, 1807, 342, 339, 347, 485, 2758, 63, 4745, 8, 277, 12, 1256, 12, 284, 7818, 304, 267, 408, 267, 1432, 2600, 4412, 5957, 3792, 370, 5007, 3792, 14, 398, 1256, 26, 20980, 288, 21791, 8072, 20980, 370, 1640, 13095, 14, 398, 284, 7818, 26, 620, 288, 2624, 9297, 730, 359, 262, 1391, 12, 734, 1391, 12, 315, 962, 12, 734, 962, 61, 267, 408, 267, 4412, 275 ]
[ 646, 747, 199, 646, 984, 199, 646, 900, 199, 646, 2050, 199, 504, 6485, 492, 664, 6334, 12, 365, 765, 12, 365, 1593, 199, 504, 7975, 492, 6036, 199, 504, 15951, 492, 15951, 2546, 199, 199, 504, 3816, 492, 10849, 199, 199, 504, 1551, 77, 20431, 14, 1018, 14, 6462, 492, 20980, 199, 646, 1551, 77, 20431, 14, 1974, 14, 793, 199, 199, 504, 11284, 63, 1000, 14, 1391, 5029, 492, 485, 1623, 63, 1391, 63, 5029, 199, 504, 11284, 63, 1000, 14, 3280, 492, 485, 2758, 63, 1113, 199, 199, 63, 5569, 63, 30773, 275, 469, 272, 283, 1023, 356, 3260, 272, 283, 3349, 356, 3260, 272, 283, 2502, 356, 3260, 272, 283, 1802, 356, 3260, 272, 283, 3437, 63, 633, 356, 3260, 272, 283, 7511, 356, 3260, 272, 283, 7538, 356, 3260, 272, 283, 589, 356, 3260, 272, 283, 3619, 356, 488, 12, 272, 283, 1501, 356, 488, 12, 272, 283, 262, 63, 3288, 356, 3260, 272, 283, 548, 63, 3288, 356, 3260, 272, 283, 262, 63, 2936, 356, 3260, 272, 283, 548, 63, 2936, 356, 24999, 272, 283, 2474, 356, 3260, 199, 93, 199, 199, 3, 9033, 945, 1561, 687, 4810, 570, 370, 2225, 1561, 315, 314, 4975, 199, 63, 10118, 63, 5443, 275, 469, 272, 283, 262, 63, 2936, 356, 283, 262, 63, 1391, 63, 7435, 297, 272, 283, 548, 63, 2936, 356, 283, 548, 63, 1391, 63, 7435, 297, 199, 93, 199, 199, 318, 485, 495, 18, 513, 8, 875, 304, 272, 9877, 275, 942, 272, 367, 308, 315, 1059, 14, 1294, 837, 267, 10110, 275, 308, 14, 1913, 342, 267, 340, 10110, 26, 288, 9877, 14, 740, 8, 385, 9, 272, 372, 9877, 199, 199, 318, 485, 362, 63, 1431, 8, 354, 12, 7970, 304, 272, 367, 299, 315, 7970, 26, 267, 340, 15951, 2546, 8, 354, 12, 299, 304, 288, 372, 536, 14, 1814, 16451, 20093, 199, 199, 318, 485, 16131, 63, 5675, 8, 1113, 12, 536, 304, 272, 367, 302, 315, 536, 14, 1294, 26461, 267, 1559, 275, 2519, 8, 1113, 12, 302, 9, 272, 372, 1559, 199, 199, 533, 485, 2028, 4590, 8, 785, 304, 272, 408, 272, 8747, 1581, 83, 2897, 666, 367, 282, 8072, 3931, 1021, 14, 339, 1101, 26, 520, 533, 1705, 15218, 14, 15218, 64, 267, 11595, 666, 14, 339, 1256, 26, 12727, 267, 21791, 8072, 1256, 370, 1640, 13095, 14, 339, 4810, 63, 515, 26, 1059, 267, 6912, 370, 314, 2897, 570, 14, 339, 408, 339, 347, 636, 826, 721, 277, 12, 15876, 12, 1101, 12, 4913, 304, 398, 327, 2372, 1369, 2256, 14, 267, 327, 2372, 2018, 1021, 436, 1218, 7937, 1256, 14, 267, 367, 945, 315, 485, 5569, 63, 30773, 26, 288, 5371, 8, 277, 12, 485, 10118, 63, 5443, 14, 362, 8, 1422, 12, 945, 395, 1101, 14, 362, 360, 13182, 3120, 297, 945, 430, 398, 291, 14, 589, 275, 485, 495, 18, 513, 8, 277, 14, 589, 9, 267, 291, 14, 262, 63, 1391, 63, 7435, 275, 485, 495, 18, 513, 8, 277, 14, 262, 63, 1391, 63, 7435, 9, 267, 291, 14, 548, 63, 1391, 63, 7435, 275, 485, 495, 18, 513, 8, 277, 14, 548, 63, 1391, 63, 7435, 9, 267, 291, 14, 262, 63, 3288, 275, 485, 495, 18, 513, 8, 277, 14, 262, 63, 3288, 9, 267, 291, 14, 548, 63, 3288, 275, 485, 495, 18, 513, 8, 277, 14, 548, 63, 3288, 9, 267, 291, 14, 2474, 275, 485, 495, 18, 513, 8, 277, 14, 2474, 9, 398, 1256, 275, 485, 2758, 63, 1113, 8, 19851, 12, 283, 863, 297, 291, 14, 1501, 12, 1249, 29, 277, 14, 589, 9, 398, 327, 2670, 367, 2716, 487, 449, 1089, 931, 14, 267, 340, 291, 14, 3619, 26, 288, 340, 747, 14, 515, 14, 17896, 8, 277, 14, 3619, 9, 503, 291, 14, 3619, 14, 2460, 24893, 735, 355, 746, 1722, 360, 3619, 450, 82, 1471, 506, 282, 25094, 7, 639, 450, 291, 14, 3619, 9, 398, 291, 14, 19851, 275, 15876, 398, 327, 18267, 687, 1101, 570, 4913, 267, 291, 14, 3954, 275, 4913, 267, 291, 14, 8928, 275, 378, 267, 291, 14, 1989, 63, 4677, 275, 756, 398, 327, 3758, 1369, 687, 1256, 855, 1301, 4343, 267, 340, 440, 291, 14, 1802, 26, 288, 340, 1256, 855, 1301, 363, 365, 440, 488, 26, 355, 291, 14, 1802, 275, 1256, 855, 1301, 363, 398, 327, 2372, 4382, 14, 267, 291, 14, 3711, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 262, 1391, 358, 267, 291, 14, 4467, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 548, 1391, 358, 267, 291, 14, 262, 63, 3288, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 262, 962, 358, 267, 291, 14, 548, 63, 3288, 275, 291, 423, 2758, 63, 4745, 8, 842, 12, 283, 548, 962, 358, 398, 327, 28281, 5739, 7970, 754, 315, 4704, 267, 367, 536, 315, 291, 14, 548, 63, 3288, 26, 288, 340, 536, 315, 291, 14, 262, 63, 3288, 26, 355, 2150, 291, 14, 262, 63, 3288, 398, 291, 14, 3282, 275, 1052, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 3711, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 4467, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 262, 63, 3288, 9, 267, 291, 14, 3282, 14, 873, 8, 277, 14, 548, 63, 3288, 9, 398, 327, 2372, 3102, 14, 267, 3102, 275, 291, 14, 2474, 267, 291, 14, 2474, 275, 1052, 267, 367, 536, 315, 3102, 26, 288, 2050, 14, 1757, 360, 259, 2274, 450, 83, 19633, 536, 9, 288, 291, 14, 2474, 59, 354, 61, 275, 536, 398, 1256, 14, 7661, 342, 267, 340, 2688, 8, 842, 12, 283, 657, 63, 1807, 735, 288, 1256, 14, 657, 63, 1807, 342, 339, 347, 485, 2758, 63, 4745, 8, 277, 12, 1256, 12, 284, 7818, 304, 267, 408, 267, 1432, 2600, 4412, 5957, 3792, 370, 5007, 3792, 14, 398, 1256, 26, 20980, 288, 21791, 8072, 20980, 370, 1640, 13095, 14, 398, 284, 7818, 26, 620, 288, 2624, 9297, 730, 359, 262, 1391, 12, 734, 1391, 12, 315, 962, 12, 734, 962, 61, 267, 408, 267, 4412, 275, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
quxiaolong1504/django
django/utils/safestring.py
478
4414
""" Functions for working with "safe strings": strings that can be displayed safely without further escaping in HTML. Marking something as a "safe string" means that the producer of the string has already turned characters that should not be interpreted by the HTML engine (e.g. '<') into the appropriate entities. """ from django.utils import six from django.utils.functional import Promise, curry class EscapeData(object): pass class EscapeBytes(bytes, EscapeData): """ A byte string that should be HTML-escaped when output. """ pass class EscapeText(six.text_type, EscapeData): """ A unicode string object that should be HTML-escaped when output. """ pass if six.PY3: EscapeString = EscapeText else: EscapeString = EscapeBytes # backwards compatibility for Python 2 EscapeUnicode = EscapeText class SafeData(object): def __html__(self): """ Returns the html representation of a string for interoperability. This allows other template engines to understand Django's SafeData. """ return self class SafeBytes(bytes, SafeData): """ A bytes subclass that has been specifically marked as "safe" (requires no further escaping) for HTML output purposes. """ def __add__(self, rhs): """ Concatenating a safe byte string with another safe byte string or safe unicode string is safe. Otherwise, the result is no longer safe. """ t = super(SafeBytes, self).__add__(rhs) if isinstance(rhs, SafeText): return SafeText(t) elif isinstance(rhs, SafeBytes): return SafeBytes(t) return t def _proxy_method(self, *args, **kwargs): """ Wrap a call to a normal unicode method up so that we return safe results. The method that is being wrapped is passed in the 'method' argument. """ method = kwargs.pop('method') data = method(self, *args, **kwargs) if isinstance(data, bytes): return SafeBytes(data) else: return SafeText(data) decode = curry(_proxy_method, method=bytes.decode) class SafeText(six.text_type, SafeData): """ A unicode (Python 2) / str (Python 3) subclass that has been specifically marked as "safe" for HTML output purposes. """ def __add__(self, rhs): """ Concatenating a safe unicode string with another safe byte string or safe unicode string is safe. Otherwise, the result is no longer safe. """ t = super(SafeText, self).__add__(rhs) if isinstance(rhs, SafeData): return SafeText(t) return t def _proxy_method(self, *args, **kwargs): """ Wrap a call to a normal unicode method up so that we return safe results. The method that is being wrapped is passed in the 'method' argument. """ method = kwargs.pop('method') data = method(self, *args, **kwargs) if isinstance(data, bytes): return SafeBytes(data) else: return SafeText(data) encode = curry(_proxy_method, method=six.text_type.encode) if six.PY3: SafeString = SafeText else: SafeString = SafeBytes # backwards compatibility for Python 2 SafeUnicode = SafeText def mark_safe(s): """ Explicitly mark a string as safe for (HTML) output purposes. The returned object can be used everywhere a string or unicode object is appropriate. Can be called multiple times on a single string. """ if hasattr(s, '__html__'): return s if isinstance(s, bytes) or (isinstance(s, Promise) and s._delegate_bytes): return SafeBytes(s) if isinstance(s, (six.text_type, Promise)): return SafeText(s) return SafeString(str(s)) def mark_for_escaping(s): """ Explicitly mark a string as requiring HTML escaping upon output. Has no effect on SafeData subclasses. Can be called multiple times on a single string (the resulting escaping is only applied once). """ if hasattr(s, '__html__') or isinstance(s, EscapeData): return s if isinstance(s, bytes) or (isinstance(s, Promise) and s._delegate_bytes): return EscapeBytes(s) if isinstance(s, (six.text_type, Promise)): return EscapeText(s) return EscapeString(str(s))
bsd-3-clause
[ 624, 199, 13967, 367, 6449, 543, 298, 3489, 3326, 582, 3326, 626, 883, 506, 9080, 19353, 199, 7395, 9848, 21375, 315, 4163, 14, 7173, 316, 6020, 465, 282, 298, 3489, 1059, 2, 4910, 199, 9099, 314, 17339, 402, 314, 1059, 965, 2575, 19136, 4110, 626, 1077, 440, 199, 1235, 11922, 701, 314, 4163, 6869, 334, 69, 14, 71, 14, 2650, 358, 1901, 314, 5827, 9045, 14, 199, 624, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15481, 492, 27724, 572, 12, 1094, 651, 421, 199, 533, 21067, 1451, 8, 785, 304, 272, 986, 421, 199, 533, 21067, 5571, 8, 2394, 12, 21067, 1451, 304, 272, 408, 272, 437, 3696, 1059, 626, 1077, 506, 4163, 13, 13572, 1380, 1072, 14, 272, 408, 272, 986, 421, 199, 533, 21067, 1872, 8, 4174, 14, 505, 63, 466, 12, 21067, 1451, 304, 272, 408, 272, 437, 2649, 1059, 909, 626, 1077, 506, 4163, 13, 13572, 1380, 1072, 14, 272, 408, 272, 986, 199, 199, 692, 3816, 14, 4521, 19, 26, 272, 21067, 1558, 275, 21067, 1872, 199, 2836, 26, 272, 21067, 1558, 275, 21067, 5571, 272, 327, 8552, 7163, 367, 2018, 499, 272, 21067, 7087, 275, 21067, 1872, 421, 199, 533, 14969, 1451, 8, 785, 304, 272, 347, 636, 1360, 721, 277, 304, 267, 408, 267, 1803, 314, 3517, 6025, 402, 282, 1059, 367, 4661, 9198, 3616, 14, 398, 961, 6127, 1163, 1978, 28156, 370, 20647, 5634, 1159, 14969, 1451, 14, 267, 408, 267, 372, 291, 421, 199, 533, 14969, 5571, 8, 2394, 12, 14969, 1451, 304, 272, 408, 272, 437, 2783, 5516, 626, 965, 2757, 22543, 11584, 465, 298, 3489, 2, 334, 6537, 949, 272, 9848, 21375, 9, 367, 4163, 1072, 12901, 14, 272, 408, 272, 347, 636, 525, 721, 277, 12, 9085, 304, 267, 408, 267, 1448, 7805, 1958, 282, 5048, 3696, 1059, 543, 4573, 5048, 3696, 1059, 503, 5048, 267, 2649, 1059, 365, 5048, 14, 6630, 12, 314, 754, 365, 949, 8088, 5048, 14, 267, 408, 267, 307, 275, 1613, 8, 11090, 5571, 12, 291, 2843, 525, 721, 12071, 9, 267, 340, 1228, 8, 12071, 12, 14969, 1872, 304, 288, 372, 14969, 1872, 8, 84, 9, 267, 916, 1228, 8, 12071, 12, 14969, 5571, 304, 288, 372, 14969, 5571, 8, 84, 9, 267, 372, 307, 339, 347, 485, 3280, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 20322, 282, 1240, 370, 282, 3293, 2649, 1083, 1536, 880, 626, 781, 372, 5048, 267, 2058, 14, 710, 1083, 626, 365, 3769, 8072, 365, 3032, 315, 314, 283, 765, 7, 267, 1423, 14, 267, 408, 267, 1083, 275, 2074, 14, 1935, 360, 765, 358, 267, 666, 275, 1083, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 1228, 8, 576, 12, 2783, 304, 288, 372, 14969, 5571, 8, 576, 9, 267, 587, 26, 288, 372, 14969, 1872, 8, 576, 9, 339, 4849, 275, 1094, 651, 1547, 3280, 63, 765, 12, 1083, 29, 2394, 14, 2708, 9, 421, 199, 533, 14969, 1872, 8, 4174, 14, 505, 63, 466, 12, 14969, 1451, 304, 272, 408, 272, 437, 2649, 334, 4718, 499, 9, 1182, 620, 334, 4718, 650, 9, 5516, 626, 965, 2757, 22543, 272, 11584, 465, 298, 3489, 2, 367, 4163, 1072, 12901, 14, 272, 408, 272, 347, 636, 525, 721, 277, 12, 9085, 304, 267, 408, 267, 1448, 7805, 1958, 282, 5048, 2649, 1059, 543, 4573, 5048, 3696, 1059, 503, 267, 5048, 2649, 1059, 365, 5048, 14, 6630, 12, 314, 754, 365, 949, 8088, 5048, 14, 267, 408, 267, 307, 275, 1613, 8, 11090, 1872, 12, 291, 2843, 525, 721, 12071, 9, 267, 340, 1228, 8, 12071, 12, 14969, 1451, 304, 288, 372, 14969, 1872, 8, 84, 9, 267, 372, 307, 339, 347, 485, 3280, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 20322, 282, 1240, 370, 282, 3293, 2649, 1083, 1536, 880, 626, 781, 372, 5048, 267, 2058, 14, 710, 1083, 626, 365, 3769, 8072, 365, 3032, 315, 314, 283, 765, 7, 267, 1423, 14, 267, 408, 267, 1083, 275, 2074, 14, 1935, 360, 765, 358, 267, 666, 275, 1083, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 1228, 8, 576, 12, 2783, 304, 288, 372, 14969, 5571, 8, 576, 9, 267, 587, 26, 288, 372, 14969, 1872, 8, 576, 9, 339, 3752, 275, 1094, 651, 1547, 3280, 63, 765, 12, 1083, 29, 4174, 14, 505, 63, 466, 14, 2143, 9, 199, 199, 692, 3816, 14, 4521, 19, 26, 272, 14969, 1558, 275, 14969, 1872, 199, 2836, 26, 272, 14969, 1558, 275, 14969, 5571, 272, 327, 8552, 7163, 367, 2018, 499, 272, 14969, 7087, 275, 14969, 1872, 421, 199, 318, 2216, 63, 3489, 8, 83, 304, 272, 408, 272, 23872, 590, 2216, 282, 1059, 465, 5048, 367, 334, 4943, 9, 1072, 12901, 14, 710, 2138, 272, 909, 883, 506, 1202, 4036, 4509, 282, 1059, 503, 2649, 909, 365, 5827, 14, 339, 6855, 506, 2797, 3663, 5431, 641, 282, 2849, 1059, 14, 272, 408, 272, 340, 2688, 8, 83, 12, 2560, 1360, 12168, 267, 372, 308, 272, 340, 1228, 8, 83, 12, 2783, 9, 503, 334, 6074, 8, 83, 12, 27724, 572, 9, 436, 308, 423, 15286, 63, 2394, 304, 267, 372, 14969, 5571, 8, 83, 9, 272, 340, 1228, 8, 83, 12, 334, 4174, 14, 505, 63, 466, 12, 27724, 572, 2298, 267, 372, 14969, 1872, 8, 83, 9, 272, 372, 14969, 1558, 8, 495, 8, 83, 430, 421, 199, 318, 2216, 63, 509, 63, 26306, 8, 83, 304, 272, 408, 272, 23872, 590, 2216, 282, 1059, 465, 29963, 4163, 21375, 12188, 1072, 14, 13481, 949, 272, 7763, 641, 14969, 1451, 9180, 14, 339, 6855, 506, 2797, 3663, 5431, 641, 282, 2849, 1059, 334, 1589, 9183, 21375, 365, 272, 1454, 6781, 5403, 680, 272, 408, 272, 340, 2688, 8, 83, 12, 2560, 1360, 13766, 503, 1228, 8, 83, 12, 21067, 1451, 304, 267, 372, 308, 272, 340, 1228, 8, 83, 12, 2783, 9, 503, 334, 6074, 8, 83, 12, 27724, 572, 9, 436, 308, 423, 15286, 63, 2394, 304, 267, 372, 21067, 5571, 8, 83, 9, 272, 340, 1228, 8, 83, 12, 334, 4174, 14, 505 ]
[ 199, 13967, 367, 6449, 543, 298, 3489, 3326, 582, 3326, 626, 883, 506, 9080, 19353, 199, 7395, 9848, 21375, 315, 4163, 14, 7173, 316, 6020, 465, 282, 298, 3489, 1059, 2, 4910, 199, 9099, 314, 17339, 402, 314, 1059, 965, 2575, 19136, 4110, 626, 1077, 440, 199, 1235, 11922, 701, 314, 4163, 6869, 334, 69, 14, 71, 14, 2650, 358, 1901, 314, 5827, 9045, 14, 199, 624, 199, 504, 1639, 14, 1208, 492, 3816, 199, 504, 1639, 14, 1208, 14, 15481, 492, 27724, 572, 12, 1094, 651, 421, 199, 533, 21067, 1451, 8, 785, 304, 272, 986, 421, 199, 533, 21067, 5571, 8, 2394, 12, 21067, 1451, 304, 272, 408, 272, 437, 3696, 1059, 626, 1077, 506, 4163, 13, 13572, 1380, 1072, 14, 272, 408, 272, 986, 421, 199, 533, 21067, 1872, 8, 4174, 14, 505, 63, 466, 12, 21067, 1451, 304, 272, 408, 272, 437, 2649, 1059, 909, 626, 1077, 506, 4163, 13, 13572, 1380, 1072, 14, 272, 408, 272, 986, 199, 199, 692, 3816, 14, 4521, 19, 26, 272, 21067, 1558, 275, 21067, 1872, 199, 2836, 26, 272, 21067, 1558, 275, 21067, 5571, 272, 327, 8552, 7163, 367, 2018, 499, 272, 21067, 7087, 275, 21067, 1872, 421, 199, 533, 14969, 1451, 8, 785, 304, 272, 347, 636, 1360, 721, 277, 304, 267, 408, 267, 1803, 314, 3517, 6025, 402, 282, 1059, 367, 4661, 9198, 3616, 14, 398, 961, 6127, 1163, 1978, 28156, 370, 20647, 5634, 1159, 14969, 1451, 14, 267, 408, 267, 372, 291, 421, 199, 533, 14969, 5571, 8, 2394, 12, 14969, 1451, 304, 272, 408, 272, 437, 2783, 5516, 626, 965, 2757, 22543, 11584, 465, 298, 3489, 2, 334, 6537, 949, 272, 9848, 21375, 9, 367, 4163, 1072, 12901, 14, 272, 408, 272, 347, 636, 525, 721, 277, 12, 9085, 304, 267, 408, 267, 1448, 7805, 1958, 282, 5048, 3696, 1059, 543, 4573, 5048, 3696, 1059, 503, 5048, 267, 2649, 1059, 365, 5048, 14, 6630, 12, 314, 754, 365, 949, 8088, 5048, 14, 267, 408, 267, 307, 275, 1613, 8, 11090, 5571, 12, 291, 2843, 525, 721, 12071, 9, 267, 340, 1228, 8, 12071, 12, 14969, 1872, 304, 288, 372, 14969, 1872, 8, 84, 9, 267, 916, 1228, 8, 12071, 12, 14969, 5571, 304, 288, 372, 14969, 5571, 8, 84, 9, 267, 372, 307, 339, 347, 485, 3280, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 20322, 282, 1240, 370, 282, 3293, 2649, 1083, 1536, 880, 626, 781, 372, 5048, 267, 2058, 14, 710, 1083, 626, 365, 3769, 8072, 365, 3032, 315, 314, 283, 765, 7, 267, 1423, 14, 267, 408, 267, 1083, 275, 2074, 14, 1935, 360, 765, 358, 267, 666, 275, 1083, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 1228, 8, 576, 12, 2783, 304, 288, 372, 14969, 5571, 8, 576, 9, 267, 587, 26, 288, 372, 14969, 1872, 8, 576, 9, 339, 4849, 275, 1094, 651, 1547, 3280, 63, 765, 12, 1083, 29, 2394, 14, 2708, 9, 421, 199, 533, 14969, 1872, 8, 4174, 14, 505, 63, 466, 12, 14969, 1451, 304, 272, 408, 272, 437, 2649, 334, 4718, 499, 9, 1182, 620, 334, 4718, 650, 9, 5516, 626, 965, 2757, 22543, 272, 11584, 465, 298, 3489, 2, 367, 4163, 1072, 12901, 14, 272, 408, 272, 347, 636, 525, 721, 277, 12, 9085, 304, 267, 408, 267, 1448, 7805, 1958, 282, 5048, 2649, 1059, 543, 4573, 5048, 3696, 1059, 503, 267, 5048, 2649, 1059, 365, 5048, 14, 6630, 12, 314, 754, 365, 949, 8088, 5048, 14, 267, 408, 267, 307, 275, 1613, 8, 11090, 1872, 12, 291, 2843, 525, 721, 12071, 9, 267, 340, 1228, 8, 12071, 12, 14969, 1451, 304, 288, 372, 14969, 1872, 8, 84, 9, 267, 372, 307, 339, 347, 485, 3280, 63, 765, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 267, 20322, 282, 1240, 370, 282, 3293, 2649, 1083, 1536, 880, 626, 781, 372, 5048, 267, 2058, 14, 710, 1083, 626, 365, 3769, 8072, 365, 3032, 315, 314, 283, 765, 7, 267, 1423, 14, 267, 408, 267, 1083, 275, 2074, 14, 1935, 360, 765, 358, 267, 666, 275, 1083, 8, 277, 12, 627, 589, 12, 1011, 958, 9, 267, 340, 1228, 8, 576, 12, 2783, 304, 288, 372, 14969, 5571, 8, 576, 9, 267, 587, 26, 288, 372, 14969, 1872, 8, 576, 9, 339, 3752, 275, 1094, 651, 1547, 3280, 63, 765, 12, 1083, 29, 4174, 14, 505, 63, 466, 14, 2143, 9, 199, 199, 692, 3816, 14, 4521, 19, 26, 272, 14969, 1558, 275, 14969, 1872, 199, 2836, 26, 272, 14969, 1558, 275, 14969, 5571, 272, 327, 8552, 7163, 367, 2018, 499, 272, 14969, 7087, 275, 14969, 1872, 421, 199, 318, 2216, 63, 3489, 8, 83, 304, 272, 408, 272, 23872, 590, 2216, 282, 1059, 465, 5048, 367, 334, 4943, 9, 1072, 12901, 14, 710, 2138, 272, 909, 883, 506, 1202, 4036, 4509, 282, 1059, 503, 2649, 909, 365, 5827, 14, 339, 6855, 506, 2797, 3663, 5431, 641, 282, 2849, 1059, 14, 272, 408, 272, 340, 2688, 8, 83, 12, 2560, 1360, 12168, 267, 372, 308, 272, 340, 1228, 8, 83, 12, 2783, 9, 503, 334, 6074, 8, 83, 12, 27724, 572, 9, 436, 308, 423, 15286, 63, 2394, 304, 267, 372, 14969, 5571, 8, 83, 9, 272, 340, 1228, 8, 83, 12, 334, 4174, 14, 505, 63, 466, 12, 27724, 572, 2298, 267, 372, 14969, 1872, 8, 83, 9, 272, 372, 14969, 1558, 8, 495, 8, 83, 430, 421, 199, 318, 2216, 63, 509, 63, 26306, 8, 83, 304, 272, 408, 272, 23872, 590, 2216, 282, 1059, 465, 29963, 4163, 21375, 12188, 1072, 14, 13481, 949, 272, 7763, 641, 14969, 1451, 9180, 14, 339, 6855, 506, 2797, 3663, 5431, 641, 282, 2849, 1059, 334, 1589, 9183, 21375, 365, 272, 1454, 6781, 5403, 680, 272, 408, 272, 340, 2688, 8, 83, 12, 2560, 1360, 13766, 503, 1228, 8, 83, 12, 21067, 1451, 304, 267, 372, 308, 272, 340, 1228, 8, 83, 12, 2783, 9, 503, 334, 6074, 8, 83, 12, 27724, 572, 9, 436, 308, 423, 15286, 63, 2394, 304, 267, 372, 21067, 5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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
srjoglekar246/sympy
sympy/printing/conventions.py
2
1781
""" A few practical conventions common to all printers. """ import re def split_super_sub(text): """Split a symbol name into a name, superscripts and subscripts The first part of the symbol name is considered to be its actual 'name', followed by super- and subscripts. Each superscript is preceded with a "^" character or by "__". Each subscript is preceded by a "_" character. The three return values are the actual name, a list with superscripts and a list with subscripts. >>> from sympy.printing.conventions import split_super_sub >>> split_super_sub('a_x^1') ('a', ['1'], ['x']) >>> split_super_sub('var_sub1__sup_sub2') ('var', ['sup'], ['sub1', 'sub2']) """ pos = 0 name = None supers = [] subs = [] while pos < len(text): start = pos+1 if text[pos:pos+2] == "__": start += 1 pos_hat = text.find("^", start) if pos_hat < 0: pos_hat = len(text) pos_usc = text.find("_", start) if pos_usc < 0: pos_usc = len(text) pos_next = min(pos_hat, pos_usc) part = text[pos:pos_next] pos = pos_next if name is None: name = part elif part.startswith("^"): supers.append(part[1:]) elif part.startswith("__"): supers.append(part[2:]) elif part.startswith("_"): subs.append(part[1:]) else: raise RuntimeError("This should never happen.") # make a little exception when a name ends with digits, i.e. treat them # as a subscript too. m = re.match('(^[a-zA-Z]+)([0-9]+)$', name) if m is not None: name, sub = m.groups() subs.insert(0, sub) return name, supers, subs
bsd-3-clause
[ 624, 199, 33, 9284, 20594, 3294, 8758, 852, 2863, 370, 1006, 5448, 11005, 14, 199, 624, 421, 199, 646, 295, 421, 199, 318, 3715, 63, 4792, 63, 954, 8, 505, 304, 272, 408, 8862, 282, 5272, 536, 1901, 282, 536, 12, 1613, 6429, 436, 1007, 6429, 10817, 710, 1642, 1777, 402, 314, 5272, 536, 365, 8652, 370, 506, 2399, 3503, 2126, 283, 354, 297, 9437, 701, 1613, 13, 436, 1007, 6429, 14, 7048, 1613, 1579, 365, 2126, 9222, 770, 543, 282, 18129, 2, 4528, 503, 701, 4396, 1674, 7048, 1007, 1579, 365, 9222, 770, 2126, 701, 282, 14220, 4528, 14, 221, 710, 7795, 372, 1338, 787, 314, 3503, 536, 12, 282, 2126, 769, 543, 1613, 6429, 436, 282, 769, 543, 1007, 6429, 14, 10817, 1306, 687, 5840, 14, 26514, 14, 388, 1856, 852, 492, 3715, 63, 4792, 63, 954, 2126, 1306, 3715, 63, 4792, 63, 954, 360, 65, 63, 88, 62, 17, 358, 2126, 661, 65, 297, 788, 17, 995, 788, 88, 1105, 2126, 1306, 3715, 63, 4792, 63, 954, 360, 1391, 63, 954, 17, 363, 1961, 63, 954, 18, 358, 2126, 661, 1391, 297, 788, 1961, 995, 788, 954, 17, 297, 283, 954, 18, 1105, 339, 408, 272, 2086, 275, 378, 272, 536, 275, 488, 272, 1029, 1192, 275, 942, 272, 13868, 275, 942, 272, 1830, 2086, 665, 822, 8, 505, 304, 267, 1343, 275, 2086, 11, 17, 267, 340, 1318, 59, 1712, 26, 1712, 11, 18, 61, 508, 4396, 582, 288, 1343, 847, 413, 267, 2086, 63, 8554, 275, 1318, 14, 1623, 18523, 401, 1343, 9, 267, 340, 2086, 63, 8554, 665, 378, 26, 2086, 63, 8554, 275, 822, 8, 505, 9, 267, 2086, 63, 527, 67, 275, 1318, 14, 1623, 11008, 401, 1343, 9, 267, 340, 2086, 63, 527, 67, 665, 378, 26, 2086, 63, 527, 67, 275, 822, 8, 505, 9, 267, 2086, 63, 2184, 275, 1748, 8, 1712, 63, 8554, 12, 2086, 63, 527, 67, 9, 267, 1777, 275, 1318, 59, 1712, 26, 1712, 63, 2184, 61, 267, 2086, 275, 2086, 63, 2184, 267, 340, 536, 365, 488, 26, 288, 536, 275, 1777, 267, 916, 1777, 14, 2460, 18523, 2349, 288, 1029, 1192, 14, 740, 8, 2064, 59, 17, 5728, 267, 916, 1777, 14, 2460, 16232, 2349, 288, 1029, 1192, 14, 740, 8, 2064, 59, 18, 5728, 267, 916, 1777, 14, 2460, 11008, 2349, 288, 13868, 14, 740, 8, 2064, 59, 17, 5728, 267, 587, 26, 288, 746, 6064, 480, 2765, 1077, 7078, 5992, 2685, 339, 327, 1852, 282, 12050, 1919, 1380, 282, 536, 11187, 543, 7576, 12, 284, 14, 69, 14, 14312, 3062, 272, 327, 465, 282, 1007, 1579, 4634, 14, 272, 333, 275, 295, 14, 1431, 14097, 62, 59, 65, 13, 6353, 13, 58, 11896, 779, 16, 13, 25, 11896, 4268, 536, 9, 272, 340, 333, 365, 440, 488, 26, 267, 536, 12, 1007, 275, 333, 14, 2634, 342, 267, 13868, 14, 3176, 8, 16, 12, 1007, 9, 339, 372, 536, 12, 1029, 1192, 12, 13868, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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, 33, 9284, 20594, 3294, 8758, 852, 2863, 370, 1006, 5448, 11005, 14, 199, 624, 421, 199, 646, 295, 421, 199, 318, 3715, 63, 4792, 63, 954, 8, 505, 304, 272, 408, 8862, 282, 5272, 536, 1901, 282, 536, 12, 1613, 6429, 436, 1007, 6429, 10817, 710, 1642, 1777, 402, 314, 5272, 536, 365, 8652, 370, 506, 2399, 3503, 2126, 283, 354, 297, 9437, 701, 1613, 13, 436, 1007, 6429, 14, 7048, 1613, 1579, 365, 2126, 9222, 770, 543, 282, 18129, 2, 4528, 503, 701, 4396, 1674, 7048, 1007, 1579, 365, 9222, 770, 2126, 701, 282, 14220, 4528, 14, 221, 710, 7795, 372, 1338, 787, 314, 3503, 536, 12, 282, 2126, 769, 543, 1613, 6429, 436, 282, 769, 543, 1007, 6429, 14, 10817, 1306, 687, 5840, 14, 26514, 14, 388, 1856, 852, 492, 3715, 63, 4792, 63, 954, 2126, 1306, 3715, 63, 4792, 63, 954, 360, 65, 63, 88, 62, 17, 358, 2126, 661, 65, 297, 788, 17, 995, 788, 88, 1105, 2126, 1306, 3715, 63, 4792, 63, 954, 360, 1391, 63, 954, 17, 363, 1961, 63, 954, 18, 358, 2126, 661, 1391, 297, 788, 1961, 995, 788, 954, 17, 297, 283, 954, 18, 1105, 339, 408, 272, 2086, 275, 378, 272, 536, 275, 488, 272, 1029, 1192, 275, 942, 272, 13868, 275, 942, 272, 1830, 2086, 665, 822, 8, 505, 304, 267, 1343, 275, 2086, 11, 17, 267, 340, 1318, 59, 1712, 26, 1712, 11, 18, 61, 508, 4396, 582, 288, 1343, 847, 413, 267, 2086, 63, 8554, 275, 1318, 14, 1623, 18523, 401, 1343, 9, 267, 340, 2086, 63, 8554, 665, 378, 26, 2086, 63, 8554, 275, 822, 8, 505, 9, 267, 2086, 63, 527, 67, 275, 1318, 14, 1623, 11008, 401, 1343, 9, 267, 340, 2086, 63, 527, 67, 665, 378, 26, 2086, 63, 527, 67, 275, 822, 8, 505, 9, 267, 2086, 63, 2184, 275, 1748, 8, 1712, 63, 8554, 12, 2086, 63, 527, 67, 9, 267, 1777, 275, 1318, 59, 1712, 26, 1712, 63, 2184, 61, 267, 2086, 275, 2086, 63, 2184, 267, 340, 536, 365, 488, 26, 288, 536, 275, 1777, 267, 916, 1777, 14, 2460, 18523, 2349, 288, 1029, 1192, 14, 740, 8, 2064, 59, 17, 5728, 267, 916, 1777, 14, 2460, 16232, 2349, 288, 1029, 1192, 14, 740, 8, 2064, 59, 18, 5728, 267, 916, 1777, 14, 2460, 11008, 2349, 288, 13868, 14, 740, 8, 2064, 59, 17, 5728, 267, 587, 26, 288, 746, 6064, 480, 2765, 1077, 7078, 5992, 2685, 339, 327, 1852, 282, 12050, 1919, 1380, 282, 536, 11187, 543, 7576, 12, 284, 14, 69, 14, 14312, 3062, 272, 327, 465, 282, 1007, 1579, 4634, 14, 272, 333, 275, 295, 14, 1431, 14097, 62, 59, 65, 13, 6353, 13, 58, 11896, 779, 16, 13, 25, 11896, 4268, 536, 9, 272, 340, 333, 365, 440, 488, 26, 267, 536, 12, 1007, 275, 333, 14, 2634, 342, 267, 13868, 14, 3176, 8, 16, 12, 1007, 9, 339, 372, 536, 12, 1029, 1192, 12, 13868, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 ]
wangcan04/chatbot
NeuralChat/util/vocabutils.py
1
3245
import pickle from tensorflow.python.platform import gfile import util.tokenizer import re import os import special_vocab as config _PAD = config._PAD _GO = config._GO _EOS = config._EOS _UNK = config._UNK _START_VOCAB = config._START_VOCAB PAD_ID = config.PAD_ID EOS_ID = config.EOS_ID GO_ID = config.GO_ID UNK_ID = config.UNK_ID # Regular expressions used to tokenize. _WORD_SPLIT = re.compile(b"([.,!?\"':;)(])") _DIGIT_RE = re.compile(br"\d") class VocabBuilder(object): def __init__(self,max_vocab_size, data_path, tokenizer = None, normalize_digits = True): ''' This class enables dynamic building of vocabulary file ''' if tokenizer is None: self.tokenizer = util.tokenizer.basic_tokenizer else: self.tokenizer = tokenizer self.vocab = {} self.max_vocab_size = max_vocab_size self.data_path = data_path def grow_vocab(self, text, normalize_digits = True): tokens = self.tokenizer(text) for w in tokens: word = re.sub(_DIGIT_RE, b"0", w) if normalize_digits else w if word in self.vocab: self.vocab[word] += 1 else: self.vocab[word] = 1 def create_vocab_file(self): vocab_list = _START_VOCAB + sorted(self.vocab, key=self.vocab.get, reverse=True) if len(vocab_list) > self.max_vocab_size: vocab_list = vocab_list[:self.max_vocab_size] vocab_path = os.path.join(self.data_path, "vocab.txt") with gfile.GFile(vocab_path, mode="wb") as vocab_file: for w in vocab_list: vocab_file.write(w + b"\n") class VocabMapper(object): def __init__(self, data_path, tokenizer = None): if tokenizer is None: self.tokenizer = util.tokenizer.basic_tokenizer else: self.tokenizer = tokenizer vocab_path = os.path.join(data_path, "vocab.txt") if gfile.Exists(vocab_path): rev_vocab = [] with gfile.GFile(vocab_path, mode = "rb") as f: rev_vocab.extend(f.readlines()) rev_vocab = [line.strip() for line in rev_vocab] vocab = dict([(x, y) for (y, x) in enumerate(rev_vocab)]) self.vocab = vocab self.rev_vocab = rev_vocab else: raise ValueError("Vocab file not found!") def get_vocab_size(self): return len(self.rev_vocab) def token_2_indices(self, text): ''' Inputs text: list of tokens (or a string) Returns: a list of ints representing token indices ''' if type(text) == type("string"): text = self.tokenizer(text) indices = [] for token in text: if token in self.vocab: indices.append(self.vocab[token]) else: indices.append(UNK_ID) return indices def indices_2_tokens(self, indices): ''' Inputs indices: a list of ints representing token indices Returns: tokens: a list of tokens ''' tokens = [] for index in indices: tokens.append(self.rev_vocab[index]) return tokens
apache-2.0
[ 646, 5927, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 646, 4884, 14, 13771, 199, 646, 295, 199, 646, 747, 199, 646, 4539, 63, 9953, 465, 1101, 199, 199, 63, 32420, 275, 1101, 423, 32420, 199, 63, 13160, 275, 1101, 423, 13160, 199, 63, 37, 3100, 275, 1101, 423, 37, 3100, 199, 63, 8019, 275, 1101, 423, 8019, 199, 63, 7363, 63, 10662, 35, 1217, 275, 1101, 423, 7363, 63, 10662, 35, 1217, 199, 199, 32420, 63, 998, 275, 1101, 14, 32420, 63, 998, 199, 37, 3100, 63, 998, 275, 1101, 14, 37, 3100, 63, 998, 199, 13160, 63, 998, 275, 1101, 14, 13160, 63, 998, 199, 8019, 63, 998, 275, 1101, 14, 8019, 63, 998, 199, 199, 3, 18528, 8455, 1202, 370, 13343, 14, 199, 63, 5172, 63, 30538, 275, 295, 14, 2014, 8, 66, 2, 779, 2020, 1, 31, 4451, 356, 27, 5130, 566, 531, 199, 63, 36, 6995, 63, 907, 275, 295, 14, 2014, 8, 3289, 3212, 68, 531, 199, 199, 533, 812, 6607, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 988, 63, 9953, 63, 890, 12, 666, 63, 515, 12, 14803, 275, 488, 12, 7666, 63, 7022, 275, 715, 304, 267, 1449, 267, 961, 1021, 22741, 8336, 10015, 402, 17515, 570, 267, 1449, 267, 340, 14803, 365, 488, 26, 288, 291, 14, 13771, 275, 4884, 14, 13771, 14, 4316, 63, 13771, 267, 587, 26, 288, 291, 14, 13771, 275, 14803, 267, 291, 14, 9953, 275, 1052, 267, 291, 14, 988, 63, 9953, 63, 890, 275, 1390, 63, 9953, 63, 890, 267, 291, 14, 576, 63, 515, 275, 666, 63, 515, 339, 347, 20772, 63, 9953, 8, 277, 12, 1318, 12, 7666, 63, 7022, 275, 715, 304, 267, 4645, 275, 291, 14, 13771, 8, 505, 9, 267, 367, 336, 315, 4645, 26, 288, 4349, 275, 295, 14, 954, 1547, 36, 6995, 63, 907, 12, 330, 2, 16, 401, 336, 9, 340, 7666, 63, 7022, 587, 336, 288, 340, 4349, 315, 291, 14, 9953, 26, 355, 291, 14, 9953, 59, 1027, 61, 847, 413, 288, 587, 26, 355, 291, 14, 9953, 59, 1027, 61, 275, 413, 339, 347, 1218, 63, 9953, 63, 493, 8, 277, 304, 267, 11181, 63, 513, 275, 485, 7363, 63, 10662, 35, 1217, 435, 3355, 8, 277, 14, 9953, 12, 790, 29, 277, 14, 9953, 14, 362, 12, 3837, 29, 549, 9, 267, 340, 822, 8, 9953, 63, 513, 9, 690, 291, 14, 988, 63, 9953, 63, 890, 26, 288, 11181, 63, 513, 275, 11181, 63, 513, 1491, 277, 14, 988, 63, 9953, 63, 890, 61, 267, 11181, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 576, 63, 515, 12, 298, 9953, 14, 2424, 531, 267, 543, 26532, 14, 39, 1173, 8, 9953, 63, 515, 12, 818, 628, 6603, 531, 465, 11181, 63, 493, 26, 288, 367, 336, 315, 11181, 63, 513, 26, 355, 11181, 63, 493, 14, 952, 8, 87, 435, 330, 3212, 78, 531, 421, 199, 533, 812, 6607, 11880, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 63, 515, 12, 14803, 275, 488, 304, 267, 340, 14803, 365, 488, 26, 288, 291, 14, 13771, 275, 4884, 14, 13771, 14, 4316, 63, 13771, 267, 587, 26, 288, 291, 14, 13771, 275, 14803, 267, 11181, 63, 515, 275, 747, 14, 515, 14, 904, 8, 576, 63, 515, 12, 298, 9953, 14, 2424, 531, 267, 340, 26532, 14, 7965, 8, 9953, 63, 515, 304, 288, 6822, 63, 9953, 275, 942, 288, 543, 26532, 14, 39, 1173, 8, 9953, 63, 515, 12, 818, 275, 298, 4848, 531, 465, 289, 26, 355, 6822, 63, 9953, 14, 2880, 8, 70, 14, 9684, 1012, 288, 6822, 63, 9953, 275, 359, 604, 14, 1913, 342, 367, 1004, 315, 6822, 63, 9953, 61, 288, 11181, 275, 1211, 7694, 88, 12, 612, 9, 367, 334, 89, 12, 671, 9, 315, 3874, 8, 4964, 63, 9953, 3948, 288, 291, 14, 9953, 275, 11181, 288, 291, 14, 4964, 63, 9953, 275, 6822, 63, 9953, 267, 587, 26, 288, 746, 1722, 480, 54, 6607, 570, 440, 1911, 9124, 339, 347, 664, 63, 9953, 63, 890, 8, 277, 304, 267, 372, 822, 8, 277, 14, 4964, 63, 9953, 9, 339, 347, 1526, 63, 18, 63, 4108, 8, 277, 12, 1318, 304, 267, 1449, 267, 30520, 267, 1318, 26, 769, 402, 4645, 334, 269, 282, 1059, 9, 267, 1803, 26, 267, 282, 769, 402, 14526, 6144, 1526, 4918, 267, 1449, 267, 340, 730, 8, 505, 9, 508, 730, 480, 875, 2349, 288, 1318, 275, 291, 14, 13771, 8, 505, 9, 267, 4918, 275, 942, 267, 367, 1526, 315, 1318, 26, 288, 340, 1526, 315, 291, 14, 9953, 26, 355, 4918, 14, 740, 8, 277, 14, 9953, 59, 1418, 566, 288, 587, 26, 355, 4918, 14, 740, 8, 8019, 63, 998, 9, 267, 372, 4918, 339, 347, 4918, 63, 18, 63, 4504, 8, 277, 12, 4918, 304, 267, 1449, 267, 30520, 267, 4918, 26, 282, 769, 402, 14526, 6144, 1526, 4918, 267, 1803, 26, 267, 4645, 26, 282, 769, 402, 4645, 267, 1449, 267, 4645, 275, 942, 267, 367, 1478, 315, 4918, 26, 288, 4645, 14, 740, 8, 277, 14, 4964, 63, 9953, 59, 1080, 566, 267, 372, 4645, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 5927, 199, 504, 3228, 14, 1548, 14, 3246, 492, 26532, 199, 646, 4884, 14, 13771, 199, 646, 295, 199, 646, 747, 199, 646, 4539, 63, 9953, 465, 1101, 199, 199, 63, 32420, 275, 1101, 423, 32420, 199, 63, 13160, 275, 1101, 423, 13160, 199, 63, 37, 3100, 275, 1101, 423, 37, 3100, 199, 63, 8019, 275, 1101, 423, 8019, 199, 63, 7363, 63, 10662, 35, 1217, 275, 1101, 423, 7363, 63, 10662, 35, 1217, 199, 199, 32420, 63, 998, 275, 1101, 14, 32420, 63, 998, 199, 37, 3100, 63, 998, 275, 1101, 14, 37, 3100, 63, 998, 199, 13160, 63, 998, 275, 1101, 14, 13160, 63, 998, 199, 8019, 63, 998, 275, 1101, 14, 8019, 63, 998, 199, 199, 3, 18528, 8455, 1202, 370, 13343, 14, 199, 63, 5172, 63, 30538, 275, 295, 14, 2014, 8, 66, 2, 779, 2020, 1, 31, 4451, 356, 27, 5130, 566, 531, 199, 63, 36, 6995, 63, 907, 275, 295, 14, 2014, 8, 3289, 3212, 68, 531, 199, 199, 533, 812, 6607, 6437, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 988, 63, 9953, 63, 890, 12, 666, 63, 515, 12, 14803, 275, 488, 12, 7666, 63, 7022, 275, 715, 304, 267, 1449, 267, 961, 1021, 22741, 8336, 10015, 402, 17515, 570, 267, 1449, 267, 340, 14803, 365, 488, 26, 288, 291, 14, 13771, 275, 4884, 14, 13771, 14, 4316, 63, 13771, 267, 587, 26, 288, 291, 14, 13771, 275, 14803, 267, 291, 14, 9953, 275, 1052, 267, 291, 14, 988, 63, 9953, 63, 890, 275, 1390, 63, 9953, 63, 890, 267, 291, 14, 576, 63, 515, 275, 666, 63, 515, 339, 347, 20772, 63, 9953, 8, 277, 12, 1318, 12, 7666, 63, 7022, 275, 715, 304, 267, 4645, 275, 291, 14, 13771, 8, 505, 9, 267, 367, 336, 315, 4645, 26, 288, 4349, 275, 295, 14, 954, 1547, 36, 6995, 63, 907, 12, 330, 2, 16, 401, 336, 9, 340, 7666, 63, 7022, 587, 336, 288, 340, 4349, 315, 291, 14, 9953, 26, 355, 291, 14, 9953, 59, 1027, 61, 847, 413, 288, 587, 26, 355, 291, 14, 9953, 59, 1027, 61, 275, 413, 339, 347, 1218, 63, 9953, 63, 493, 8, 277, 304, 267, 11181, 63, 513, 275, 485, 7363, 63, 10662, 35, 1217, 435, 3355, 8, 277, 14, 9953, 12, 790, 29, 277, 14, 9953, 14, 362, 12, 3837, 29, 549, 9, 267, 340, 822, 8, 9953, 63, 513, 9, 690, 291, 14, 988, 63, 9953, 63, 890, 26, 288, 11181, 63, 513, 275, 11181, 63, 513, 1491, 277, 14, 988, 63, 9953, 63, 890, 61, 267, 11181, 63, 515, 275, 747, 14, 515, 14, 904, 8, 277, 14, 576, 63, 515, 12, 298, 9953, 14, 2424, 531, 267, 543, 26532, 14, 39, 1173, 8, 9953, 63, 515, 12, 818, 628, 6603, 531, 465, 11181, 63, 493, 26, 288, 367, 336, 315, 11181, 63, 513, 26, 355, 11181, 63, 493, 14, 952, 8, 87, 435, 330, 3212, 78, 531, 421, 199, 533, 812, 6607, 11880, 8, 785, 304, 272, 347, 636, 826, 721, 277, 12, 666, 63, 515, 12, 14803, 275, 488, 304, 267, 340, 14803, 365, 488, 26, 288, 291, 14, 13771, 275, 4884, 14, 13771, 14, 4316, 63, 13771, 267, 587, 26, 288, 291, 14, 13771, 275, 14803, 267, 11181, 63, 515, 275, 747, 14, 515, 14, 904, 8, 576, 63, 515, 12, 298, 9953, 14, 2424, 531, 267, 340, 26532, 14, 7965, 8, 9953, 63, 515, 304, 288, 6822, 63, 9953, 275, 942, 288, 543, 26532, 14, 39, 1173, 8, 9953, 63, 515, 12, 818, 275, 298, 4848, 531, 465, 289, 26, 355, 6822, 63, 9953, 14, 2880, 8, 70, 14, 9684, 1012, 288, 6822, 63, 9953, 275, 359, 604, 14, 1913, 342, 367, 1004, 315, 6822, 63, 9953, 61, 288, 11181, 275, 1211, 7694, 88, 12, 612, 9, 367, 334, 89, 12, 671, 9, 315, 3874, 8, 4964, 63, 9953, 3948, 288, 291, 14, 9953, 275, 11181, 288, 291, 14, 4964, 63, 9953, 275, 6822, 63, 9953, 267, 587, 26, 288, 746, 1722, 480, 54, 6607, 570, 440, 1911, 9124, 339, 347, 664, 63, 9953, 63, 890, 8, 277, 304, 267, 372, 822, 8, 277, 14, 4964, 63, 9953, 9, 339, 347, 1526, 63, 18, 63, 4108, 8, 277, 12, 1318, 304, 267, 1449, 267, 30520, 267, 1318, 26, 769, 402, 4645, 334, 269, 282, 1059, 9, 267, 1803, 26, 267, 282, 769, 402, 14526, 6144, 1526, 4918, 267, 1449, 267, 340, 730, 8, 505, 9, 508, 730, 480, 875, 2349, 288, 1318, 275, 291, 14, 13771, 8, 505, 9, 267, 4918, 275, 942, 267, 367, 1526, 315, 1318, 26, 288, 340, 1526, 315, 291, 14, 9953, 26, 355, 4918, 14, 740, 8, 277, 14, 9953, 59, 1418, 566, 288, 587, 26, 355, 4918, 14, 740, 8, 8019, 63, 998, 9, 267, 372, 4918, 339, 347, 4918, 63, 18, 63, 4504, 8, 277, 12, 4918, 304, 267, 1449, 267, 30520, 267, 4918, 26, 282, 769, 402, 14526, 6144, 1526, 4918, 267, 1803, 26, 267, 4645, 26, 282, 769, 402, 4645, 267, 1449, 267, 4645, 275, 942, 267, 367, 1478, 315, 4918, 26, 288, 4645, 14, 740, 8, 277, 14, 4964, 63, 9953, 59, 1080, 566, 267, 372, 4645, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1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